public Game(int numPlayers = 2) { Deck = new Deck(); Players = new List<Player>(); PlayerWins = new List<long>(); hCalc = new HandCalculator(); iCalc = new IterationCalculator(); Board = new List<Card>(); for (var i = 0; i < numPlayers; i++) { Players.Add(new Player()); PlayerWins.Add(0); } }
public List<long> CalculateRound(List<Hand> hands, List<Card> initBoard, List<Card> deadCards) { var watch = new Stopwatch(); watch.Start(); Timers.Add(watch.Elapsed.TotalSeconds); var chopCount = new List<int>() { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; var playerWins = new List<long>() { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; var playerChops = new List<long>() { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; long totalHands = 0; Deck d = new Deck(); var iCalc = new IterationCalculator(); hands.ForEach(h => { d.RemoveCards(h.Cards); }); d.RemoveCards(deadCards); List<Card> currBoard = new List<Card>(5); List<Card> nextBoard; if(initBoard != null && initBoard.Count > 0) nextBoard = new List<Card>(d.DealNextCards(5)); else nextBoard = new List<Card>(d.DealNextCards(5)); long score = 0; while (nextBoard != null) { d.AddCardsBackToDeckInOrder(currBoard); currBoard = d.DealCards(nextBoard); var result = CalculateWinnerDll(hands, currBoard); score = result.WinningScore; totalHands++; if (result.WinningPlayerNumbers.Count > 1) result.WinningPlayerNumbers.ForEach(n => playerChops[n]++); else playerWins[result.WinningPlayerNumbers[0]]++; nextBoard = iCalc.GetNextHand(nextBoard, d.Cards); } Timers.Add(watch.Elapsed.TotalSeconds); playerWins.AddRange(playerChops); playerWins.Add(totalHands); watch.Stop(); return playerWins; }