I am making a bot that can test some tactics of cards in the game, the bot works, but I have one problem. My way of shaking the card 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 that I count without a pause between the process of shaking the card, several players will win many games. for instance
Player 1: 8 games
Player 2: 2 games
Player 3: 0 games
Player 4: 0 games
But when I add a dialogue before the card shake process, the winnings will be distributed among the players:
Player 1: 3 games
Player 2: 2 games
Player 3: 1 game
Player 4: 4 games
I guess the Random class is not suitable for such brute force. How can I shuffle cards without problems?
Update: I already tried to use 1 Random class, and I also tried to shake cards only once.
source
share