private void finishHand() { var handStrengths = new List <int>(); foreach (var botGameState in _botGameStates) { if (_botGameStates[0].getBoard().Count == 5) // TODO CHeeeeeeeeeeck { var handStrength = botGameState.calculateHeroHandStrength(); handStrengths.Add(handStrength.Value()); } else { handStrengths.Add(0); } } var winnings = Pot.calculateWinnings(getPlayers(), handStrengths); for (int i = 0; i < winnings.Count; i++) { if (winnings[i] > 0) { var player = getPlayers()[i]; _gameTableControl.log(player.Name + " wins " + moneyToString(winnings[i])); } } foreach (var botGameState in _botGameStates) { botGameState.finishHand(winnings); } _opponentModeling.addHand(_botGameStates[0].getCurrentHand()); }
private dynamic finishHand() { var handStrengths = new List <int>(); if (_botGameStates[0].getBoard().Count == 5) { foreach (var botGameState in _botGameStates) { var handStrength = botGameState.calculateHeroHandStrength(); handStrengths.Add(handStrength.Value()); Console.WriteLine(botGameState.getHero().Name + " " + botGameState.getHero().StatusInHand + " (" + botGameState.getHeroHoleCards() + "): " + handStrength); } } else { foreach (var botGameState in _botGameStates) { handStrengths.Add(0); } } var winnings = Pot.calculateWinnings(getPlayers(), handStrengths); for (int i = 0; i < winnings.Count; i++) { if (winnings[i] > 0) { Console.WriteLine(getPlayers()[i].Name + " wins: " + winnings[i]); } } foreach (var botGameState in _botGameStates) { botGameState.finishHand(winnings); } // Update opponent modeling... if (!_isFakeHand) { var startTime = DateTime.Now; _opponentModeling?.addHand(_botGameStates[0].getCurrentHand()); Console.WriteLine($"Opponent modelling added hand [{DateTime.Now - startTime}]"); } var saldo = new int[_numPlayers]; for (int i = 0; i < _numPlayers; i++) { saldo[i] = getPlayers()[i].Stack - _startStackSize; } return(new { status = "hand_finished", winnings = winnings, saldo = saldo }); }
public void finishHand() { if (_prevMatchState == null) { return; } Console.WriteLine("Ending preveous hand"); var handStrengths = new List <int>(); if (_prevMatchState.board.Count == 5) { for (int i = 0; i < _botGameState.getPlayers().Count; i++) { var player = _botGameState.getPlayers()[i]; var playerHoleCards = _prevMatchState.playerHoleCards(player.PreFlopPosition, _numPlayers); if (playerHoleCards == null) { handStrengths.Add(0); continue; } var handStrength = HandStrength.calculateHandStrength(playerHoleCards, _prevMatchState.board); var holeCardsGuess = (player.Range.getHoleCardsProb(playerHoleCards) * 100).ToString("f1") + "%"; var plNameAndAction = ""; if (player.StatusInHand != Status.Folded) { plNameAndAction = player.Name + " shows"; } else { plNameAndAction = player.Name + " folded"; } Console.WriteLine(plNameAndAction + " (" + playerHoleCards + "): " + handStrength + " [Guess: " + holeCardsGuess + "]"); handStrengths.Add(handStrength.Value()); } } else { foreach (var player in _botGameState.getPlayers()) { handStrengths.Add(0); } } var winnings = Pot.calculateWinnings(_botGameState.getPlayers(), handStrengths); _botGameState.finishHand(winnings); for (int i = 0; i < _botGameState.getPlayers().Count; i++) { if (winnings[i] > 0) { Console.WriteLine(_botGameState.getPlayers()[i].Name + " wins: " + winnings[i]); } } int thisHandSaldo = hero().Stack - _startStackSize; _totalSaldo += thisHandSaldo; Console.WriteLine("This hand saldo: {0}, Total saldo: {1}", thisHandSaldo, _totalSaldo); var startTime = DateTime.Now; _opponentModeling.addHand(_botGameState.getCurrentHand()); Console.WriteLine("Opponent modelling added hand " + timeToString(DateTime.Now - startTime)); }