I am making a blackjack game and I have all the cards stored in an array. How can I randomize the array so that when crads are dealt it is random. Will there be problems drawing the same card twice?
How are you making the cards different? Do you have some kind of an enumeration with all possible kinds or what? If you have an enumaration, it would the easiest way to do, using the Random object.
Check out wyrd's card games for guidance on shuffling your cards.
The Deck class has a Shuffle method that you can look at. It
basically just loops through every card and swaps the current
card in the loop with a random one.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.