public void TestBlinds() { double[] blinds = new double[]{1,2}; betMan = new BetManager(namesToChips, BettingStructure.NoLimit, blinds, 0); FastPokerAction[] actions = new FastPokerAction[] { new FastPokerAction("Player3", FastPokerAction.ActionTypes.PostSmallBlind, 25), new FastPokerAction("Player4", FastPokerAction.ActionTypes.PostBigBlind, 62), new FastPokerAction("Player0", FastPokerAction.ActionTypes.Raise, 1), }; FastPokerAction action = betMan.GetValidatedAction(actions[0]); Assert.AreEqual(1, action.Amount); Assert.AreEqual(FastPokerAction.ActionTypes.PostSmallBlind, action.ActionType); betMan.Commit(action); Assert.IsFalse(betMan.RoundOver); action = betMan.GetValidatedAction(actions[1]); Assert.AreEqual(2, action.Amount); Assert.AreEqual(FastPokerAction.ActionTypes.PostBigBlind, action.ActionType); betMan.Commit(action); Assert.IsFalse(betMan.RoundOver); action = betMan.GetValidatedAction(actions[2]); Assert.AreEqual(4, action.Amount); Assert.AreEqual(Action.ActionTypes.Raise, action.ActionType); betMan.Commit(action); Assert.IsFalse(betMan.RoundOver); }
public void TestAntes() { double[] blinds = new double[] { 2, 4 }; betMan = new BetManager(namesToChips, BettingStructure.NoLimit, blinds, 1); Action[] actions = new Action[] { new Action("Player3", Action.ActionTypes.PostAnte, 25),//should be 1 new Action("Player4", Action.ActionTypes.PostAnte, 0.5),// should be 1 new Action("Player0", Action.ActionTypes.PostAnte, 2),//should be PostAnte and 1 }; Action action = betMan.GetValidatedAction(actions[0]); Assert.AreEqual(1, action.Amount); Assert.AreEqual(Action.ActionTypes.PostAnte, action.ActionType); betMan.Commit(action); Assert.IsFalse(betMan.RoundOver); action = betMan.GetValidatedAction(actions[1]); Assert.AreEqual(1, action.Amount); Assert.AreEqual(Action.ActionTypes.PostAnte, action.ActionType); betMan.Commit(action); Assert.IsFalse(betMan.RoundOver); action = betMan.GetValidatedAction(actions[2]); Assert.AreEqual(1, action.Amount); Assert.AreEqual(Action.ActionTypes.PostAnte, action.ActionType); betMan.Commit(action); Assert.IsFalse(betMan.RoundOver); }
public void PlayHand(HandHistory handHistory) { #region Hand Setup seats = handHistory.Players; handHistory.HoleCards = new ulong[seats.Length]; handHistory.DealtCards = 0UL; handHistory.Flop = 0UL; handHistory.Turn = 0UL; handHistory.River = 0UL; //Setup the hand history this.history = handHistory; //Create a new map from player names to player chips for the BetManager Dictionary <string, double> namesToChips = new Dictionary <string, double>(); //Create a new list of players for the PlayerManager playerIndices = new CircularList <int>(); playerIndices.Loop = true; //Create a map of player names to their seat numbers //seatNumbers = new Dictionary<string, int>(); for (int i = 0; i < seats.Length; i++) { namesToChips[seats[i].Name] = seats[i].Chips; if (seats[i].SeatNumber == history.Button) { buttonIdx = i; utgIdx = (i + 1) % seats.Length; } } for (int i = (buttonIdx + 1) % seats.Length; playerIndices.Count < seats.Length;) { playerIndices.Add(i); i = (i + 1) % seats.Length; } betManager = new BetManager(namesToChips, history.BettingStructure, history.AllBlinds, history.Ante); potManager = new PotManager(seats); #endregion if (betManager.In > 1) { GetBlinds(); DealHoleCards(); } history.CurrentRound = Round.Preflop; if (betManager.CanStillBet > 1) { GetBets(history.PreflopActions); } if (betManager.In <= 1) { payWinners(); return; } DealFlop(); history.CurrentRound = Round.Flop; if (betManager.CanStillBet > 1) { GetBets(history.FlopActions); } if (betManager.In <= 1) { payWinners(); return; } DealTurn(); history.CurrentRound = Round.Turn; if (betManager.CanStillBet > 1) { GetBets(history.TurnActions); } if (betManager.In <= 1) { payWinners(); return; } DealRiver(); history.CurrentRound = Round.River; if (betManager.CanStillBet > 1) { GetBets(history.RiverActions); } if (betManager.In <= 1) { payWinners(); return; } payWinners(); history.ShowDown = true; history.CurrentRound = Round.Over; }
public void TestNoLimitRaising() { double[] blinds = new double[] { 2, 4 }; betMan = new BetManager(namesToChips, BettingStructure.NoLimit, blinds, 0); Action[] actions = new Action[] { new Action("Player0", Action.ActionTypes.PostSmallBlind, 2), new Action("Player1", Action.ActionTypes.PostBigBlind, 4), new Action("Player2", Action.ActionTypes.Bet, 6),//should be corrected to Raise 8 new Action("Player3", Action.ActionTypes.Raise, 20), new Action("Player4", Action.ActionTypes.Raise, 0)//should be corrected to 34 }; betMan.Commit(actions[0]); betMan.Commit(actions[1]); Action action = betMan.GetValidatedAction(actions[2]); Assert.AreEqual(8, action.Amount); Assert.AreEqual(Action.ActionTypes.Raise, action.ActionType); betMan.Commit(action); Assert.IsFalse(betMan.RoundOver); action = betMan.GetValidatedAction(actions[3]); Assert.AreEqual(20, action.Amount); Assert.AreEqual(Action.ActionTypes.Raise, action.ActionType); betMan.Commit(action); Assert.IsFalse(betMan.RoundOver); action = betMan.GetValidatedAction(actions[4]); Assert.AreEqual(32, action.Amount); Assert.AreEqual(Action.ActionTypes.Raise, action.ActionType); betMan.Commit(action); Assert.IsFalse(betMan.RoundOver); }
public void PlayHand(HandHistory handHistory) { #region Hand Setup seats = handHistory.Players; handHistory.HoleCards = new ulong[seats.Length]; handHistory.DealtCards = 0UL; handHistory.Flop = 0UL; handHistory.Turn = 0UL; handHistory.River = 0UL; //Setup the hand history this.history = handHistory; //Create a new map from player names to player chips for the BetManager Dictionary<string, double> namesToChips = new Dictionary<string, double>(); //Create a new list of players for the PlayerManager playerIndices = new CircularList<int>(); playerIndices.Loop = true; //Create a map of player names to their seat numbers //seatNumbers = new Dictionary<string, int>(); for (int i = 0; i < seats.Length; i++) { namesToChips[seats[i].Name] = seats[i].Chips; if (seats[i].SeatNumber == history.Button) { buttonIdx = i; utgIdx = (i + 1) % seats.Length; } } for (int i = (buttonIdx + 1) % seats.Length; playerIndices.Count < seats.Length;) { playerIndices.Add(i); i = (i + 1) % seats.Length; } betManager = new BetManager(namesToChips, history.BettingStructure, history.AllBlinds, history.Ante); potManager = new PotManager(seats); #endregion if (betManager.In > 1) { GetBlinds(); DealHoleCards(); } history.CurrentRound = Round.Preflop; if (betManager.CanStillBet > 1) { GetBets(history.PreflopActions); } if (betManager.In <= 1) { payWinners(); return; } DealFlop(); history.CurrentRound = Round.Flop; if (betManager.CanStillBet > 1) { GetBets(history.FlopActions); } if (betManager.In <= 1) { payWinners(); return; } DealTurn(); history.CurrentRound = Round.Turn; if (betManager.CanStillBet > 1) { GetBets(history.TurnActions); } if (betManager.In <= 1) { payWinners(); return; } DealRiver(); history.CurrentRound = Round.River; if (betManager.CanStillBet > 1) { GetBets(history.RiverActions); } if (betManager.In <= 1) { payWinners(); return; } payWinners(); history.ShowDown = true; history.CurrentRound = Round.Over; }