我正在制作一个可以在游戏中测试一些纸牌战术的机器人,该机器人可以工作,但我有一个问题。我的抽卡方法不是很好。我这样摇牌:
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;
}
问题是当我计算在摇牌过程之间没有停顿时,少数玩家会赢得很多游戏。例如
Player 1: 8 games
Player 2: 2 games
Player 3: 0 games
Player 4: 0 games
但是当我在摇牌过程之前添加一个对话框时,胜利将分散在玩家身上:
Player 1: 3 games
Player 2: 2 games
Player 3: 1 game
Player 4: 4 games
我猜 Random 类对于这样的蛮力来说还不够好。我怎样才能洗牌没有这样的问题?
更新:我已经尝试过使用 1 个随机类,并且我也尝试过只摇一次牌。