I’m making a bot that can test some card tactics on a game, the bot works but I have one problem. My card shake method is not very good. I shake the cards this way:
public void ShuffelDeck()
{
for (int i = 0; i < 5; i++)
Cards = ShuffelCards(Cards);
}
private ArrayList ShuffelCards(ArrayList Cards)
{
ArrayList ShuffedCards = new ArrayList();
Random SeedCreator = new Random();
Random RandomNumberCreator = new Random(SeedCreator.Next());
while (Cards.Count != 0)
{
int RandomNumber = RandomNumberCreator.Next(0, Cards.Count);
ShuffedCards.Insert(ShuffedCards.Count, Cards[RandomNumber]);
Cards.RemoveAt(RandomNumber);
}
return ShuffedCards;
}
The problem is when I calculate without a pause between the card shake process , a few players will win a lot of games. For example
Player 1: 8 games
Player 2: 2 games
Player 3: 0 games
Player 4: 0 games
But when I add a dialog before the card shake process the wins will get spread over the players:
Player 1: 3 games
Player 2: 2 games
Player 3: 1 game
Player 4: 4 games
I guess that the Random class is not good enough for a brute force like this. How can I shuffle the cards without a problem like this?
Update: I already tried to use 1 Random class, and I also tried to shake the cards only once.