This is my first project and I've been thoroughly confused and after about 3 hours of looking and trying Fischer-Yates methods and so forth, I've come up blank.
I am creating a card shuffler and am trying to not copy and paste code especially if I don't understand it. Currently I have placed my cards into an enum called Cards that gives each card a value from 0 - 51.
Now this is what I have come up with for code so far...
class DeckShuffle
{
static Random rndCard = new Random(DateTime.Now.Millisecond);
int currentCard;
int tempCard;
int totalCards = 51;
private int CardShuffler()
{
while (totalCards > -1)
{
tempCard = rndCard.Next(0, 51);
/*I need to write some code that takes the random number and
doesn't repeat it and then want to assign the random number to
the top of an array or list so that when I go to deal cards I
can pull from the already shuffled cards.
*/
totalCards--;
}
}
}
I know this style of question has been answered before but I'm really struggling to understand how the Fischer Yates works and was wondering if someone could help guide me into the next step(s) of getting this to work.
EDIT I'm not sure how to implement Fischer-Yates in to code. I understand the logic behind it but am struggling with the code...
Aucun commentaire:
Enregistrer un commentaire