nine4 | Website Templates Built Next.js
kandi X-RAY | nine4 Summary
kandi X-RAY | nine4 Summary
🎆 Website Templates Built With Next.js & Styled With Tailwind CSS
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of nine4
nine4 Key Features
nine4 Examples and Code Snippets
Community Discussions
Trending Discussions on nine4
QUESTION
My input file looks like
...ANSWER
Answered 2020-Mar-29 at 16:30EDIT: Adding solution with more sensible variable names.
QUESTION
I am making a card game, I started by placing all the cards in an array of tuples with a number 1-52 assigned. But by using a random number generator to pick the cards it becomes difficult to remove a card from the deck because I can't specifically remove that number from my random number generator. Any help is appreciated.
...ANSWER
Answered 2017-Jan-23 at 01:47Maintain an array of cards that are still available and not already picked. For the purpose of this discussion, I will call this the "deal array" (this must be maintained separately to the deck array! It could start off as a mutable copy of the deck array.).
When you randomly pick/deal a card remove it from the deal array.
Your random number generator should be choosing a number between zero and the number of items left in the deal array - NOT between zero and fifty two.
(Assuming the deal array is not empty - check this before randomly choosing a card from the deal array.)
When selecting a card from the deal array use the random number as an index to the array (not as the card numbers you've created, which are not of any real use for picking cards from the deal array randomly).
(Note that I'm not including any example code here, because it's unclear to me what the purpose of some of your code is. If I tried to post code here, the chances are that I would mis-interpret your code and therefore post incorrect code).
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install nine4
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page