public HoldemState Transition( int nowMillis, bool[] playerIsSeated, bool[] playerIsReady, int[] bankBySeatOwner, int actingPlayerBet, bool actingPlayerCommited, int[] deck) { object[] newState = HoldemGame.CalculateTransition( tableState, lastTransitionMillis, bettingRound, actingSeat, dealerSeat, currentBet, minimumRaise, headsUp, wonByFold, // clone so we can test old state (int[])playerState.Clone(), (int[])stacks.Clone(), (int[])roundContribution.Clone(), (int[])potContribution.Clone(), flop0, flop1, flop2, turn, river, holeCards0, holeCards1, // external state nowMillis, bigBlind, winnerTimeoutSecs, readyTimeoutSecs, actionTimeoutSecs, headsUpTimeoutSecs, playerIsSeated, playerIsReady, bankBySeatOwner, actingPlayerBet, actingPlayerCommited, deck); HoldemState newS = this; if (newState != null) { newS = new HoldemState(newState); } Validate(newS, this, playerIsSeated[actingSeat], actingPlayerBet, actingPlayerCommited); return(newS); }
void OnMessageReceived(byte[] receivedData) { HoldemState receivedState = new HoldemState(receivedData); Log += string.Format("{0}\n", receivedState); connection.Send(new AutoplayerInstruction(AutoplayerAction.Fold, -1, 0)); }
// safety properties static void Validate(HoldemState s, HoldemState old, bool actingPlayerSeated, int actingPlayerBet, bool actingPlayerCommited) { if (s.tableState == HoldemGame.TABLE_PLAYING) { GameState.Validate(new GameState(s), new GameState(old), actingPlayerSeated, actingPlayerBet, actingPlayerCommited); } }
// extract game state from table for testing public GameState(HoldemState s) { bettingRound = s.bettingRound; actingSeat = s.actingSeat; currentBet = s.currentBet; minimumRaise = s.minimumRaise; headsUp = s.headsUp; wonByFold = s.wonByFold; playerState = s.playerState; stacks = s.stacks; roundContribution = s.roundContribution; potContribution = s.potContribution; }