Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
 public void GetAction(HandHistory history,
                       out FastPokerEngine.Action.ActionTypes type, out double amount)
 {
     if (actions != null && curAction < actions.Length)
     {
         FastPokerEngine.Action action = actions[curAction++];
         type   = action.ActionType;
         amount = action.Amount;
     }
     else
     {
         type   = FastPokerEngine.Action.ActionTypes.Fold;
         amount = 0;
     }
 }
Beispiel #7
0
        public void TestPlayHand()
        {
            //The hand will be
            //Preflop:
            //Seq0 UTG, raises to $4
            //Seq4 is on BB and will reraise to $6
            //Seq0 flat calls
            //Flop:
            //Seq4 goes all-in for $194
            //Seq0 folds.

            Action[] actions0 = new Action[] {
                new Action("Seq0", Action.ActionTypes.Raise, 4),
                new Action("Seq0", Action.ActionTypes.Call),
                new Action("Seq0", Action.ActionTypes.Fold)
            };
            seqPlayers[0].Brain = new SequencePlayer(actions0);

            seqPlayers[1].Brain = new SequencePlayer();
            seqPlayers[2].Brain = new SequencePlayer();
            seqPlayers[3].Brain = new SequencePlayer();

            Action[] actions4 = new Action[] {
                new Action("Seq4", Action.ActionTypes.Raise, 4),
                new Action("Seq4", Action.ActionTypes.Raise, 194)
            };
            seqPlayers[4].Brain = new SequencePlayer(actions4);

            //seq2 is on buttonIdx (seat 3), seq3 is small blind ($1), seq4 is big blind ($2), hand number is 42
            HandHistory results = new TournamentHandHistory(seqPlayers, 42, 3, blinds, 0, BettingStructure.NoLimit);

            engine.PlayHand(results);

            Console.WriteLine(results);

            Assert.AreEqual(194.0, seqPlayers[0].Chips); //raised to $4, called a $2 reraise and folded flop
            Assert.AreEqual(200.0, seqPlayers[1].Chips); //folded preflop
            Assert.AreEqual(200.0, seqPlayers[2].Chips); //folded preflop
            Assert.AreEqual(199.0, seqPlayers[3].Chips); //folded preflop, but paid $1 small blind
            Assert.AreEqual(207.0, seqPlayers[4].Chips); //won the hand, including $6 from seq0 and $1 small blind
        }
Beispiel #8
0
        public void TestPlayHand()
        {
            //The hand will be
            //Preflop:
            //Seq0 UTG, raises to $4
            //Seq4 is on BB and will reraise to $6
            //Seq0 flat calls
            //Flop:
            //Seq4 goes all-in for $194
            //Seq0 folds.

            Action[] actions0 = new Action[] {
                new Action("Seq0", Action.ActionTypes.Raise, 4),
                new Action("Seq0", Action.ActionTypes.Call),
                new Action("Seq0", Action.ActionTypes.Fold)
            };
            seqPlayers[0].Brain = new SequencePlayer(actions0);

            seqPlayers[1].Brain = new SequencePlayer();
            seqPlayers[2].Brain = new SequencePlayer();
            seqPlayers[3].Brain = new SequencePlayer();

            Action[] actions4 = new Action[] {
                new Action("Seq4", Action.ActionTypes.Raise, 4),
                new Action("Seq4", Action.ActionTypes.Raise, 194)
            };
            seqPlayers[4].Brain = new SequencePlayer(actions4);

            //seq2 is on buttonIdx (seat 3), seq3 is small blind ($1), seq4 is big blind ($2), hand number is 42
            HandHistory results = new TournamentHandHistory(seqPlayers, 42, 3, blinds, 0, BettingStructure.NoLimit);
            engine.PlayHand(results);

            Console.WriteLine(results);

            Assert.AreEqual(194.0, seqPlayers[0].Chips);//raised to $4, called a $2 reraise and folded flop
            Assert.AreEqual(200.0, seqPlayers[1].Chips);//folded preflop
            Assert.AreEqual(200.0, seqPlayers[2].Chips);//folded preflop
            Assert.AreEqual(199.0, seqPlayers[3].Chips);//folded preflop, but paid $1 small blind
            Assert.AreEqual(207.0, seqPlayers[4].Chips);//won the hand, including $6 from seq0 and $1 small blind
        }
Beispiel #9
0
        public void TestTotal()
        {
            Action[] actions = new Action[] {
                new Action("Player3", Action.ActionTypes.PostSmallBlind, 1),
                new Action("Player4", Action.ActionTypes.PostBigBlind, 2),
                new Action("Player0", Action.ActionTypes.Raise, 4),
                new Action("Player1", Action.ActionTypes.Fold),
                new Action("Player2", Action.ActionTypes.Fold),
                new Action("Player3", Action.ActionTypes.Fold),
                new Action("Player4", Action.ActionTypes.Raise, 4),
                new Action("Player0", Action.ActionTypes.Call, 2),
                new Action("Player4", Action.ActionTypes.Raise, 194, true),
                new Action("Player0", Action.ActionTypes.Fold)
            };

            potMan.AddAction(3, actions[0]);
            Assert.AreEqual(1, potMan.Total);
            potMan.AddAction(4, actions[1]);
            Assert.AreEqual(3, potMan.Total);
            potMan.AddAction(0, actions[2]);
            Assert.AreEqual(7, potMan.Total);
            potMan.AddAction(1, actions[3]);
            Assert.AreEqual(7, potMan.Total);
            potMan.AddAction(2, actions[4]);
            Assert.AreEqual(7, potMan.Total);
            potMan.AddAction(3, actions[5]);
            Assert.AreEqual(7, potMan.Total);
            potMan.AddAction(4, actions[6]);
            Assert.AreEqual(11, potMan.Total);
            potMan.AddAction(0, actions[7]);
            Assert.AreEqual(13, potMan.Total);
            potMan.AddAction(4, actions[8]);
            Assert.AreEqual(207, potMan.Total);
            potMan.AddAction(0, actions[9]);
            Assert.AreEqual(207, potMan.Total);
        }
Beispiel #10
0
        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);
        }
Beispiel #11
0
        public void TestAllInSidePots()
        {
            Action[] actions = new Action[] {
                new Action("Player3", Action.ActionTypes.PostSmallBlind, 1),
                new Action("Player4", Action.ActionTypes.PostBigBlind, 2),
                new Action("Player0", Action.ActionTypes.Raise, 250, true),
                new Action("Player1", Action.ActionTypes.Raise, 275, true),
                new Action("Player2", Action.ActionTypes.Call, 125, true),
                new Action("Player3", Action.ActionTypes.Raise, 499, true),
                new Action("Player4", Action.ActionTypes.Call, 498, true)
            };

            Assert.AreEqual(0, potMan.Total);
            Assert.AreEqual(1, potMan.PotCount, "Started with something besides 1 pot");

            potMan.AddAction(3, actions[0]);
            Assert.AreEqual(1, potMan.Total, "small blind not added correctly");
            Assert.AreEqual(1, potMan.PotCount, "pots wrong after small blind");

            potMan.AddAction(4, actions[1]);
            Assert.AreEqual(3, potMan.Total);
            Assert.AreEqual(1, potMan.PotCount);

            potMan.AddAction(0, actions[2]);
            Assert.AreEqual(253, potMan.Total);
            Assert.AreEqual(1, potMan.PotCount);

            potMan.AddAction(1, actions[3]);
            Assert.AreEqual(528, potMan.Total);
            Assert.AreEqual(2, potMan.PotCount);
            Assert.AreEqual(503, potMan.Pots[0].Size);
            Assert.AreEqual(25, potMan.Pots[1].Size);

            potMan.AddAction(2, actions[4]);
            Assert.AreEqual(653, potMan.Total);
            Assert.AreEqual(3, potMan.PotCount);
            Assert.AreEqual(378, potMan.Pots[0].Size);
            Assert.AreEqual(250, potMan.Pots[1].Size);
            Assert.AreEqual(25, potMan.Pots[2].Size);

            potMan.AddAction(3, actions[5]);
            Assert.AreEqual(1152, potMan.Total);
            Assert.AreEqual(4, potMan.PotCount);
            Assert.AreEqual(502, potMan.Pots[0].Size);
            Assert.AreEqual(375, potMan.Pots[1].Size);
            Assert.AreEqual(50, potMan.Pots[2].Size);
            Assert.AreEqual(225, potMan.Pots[3].Size);

            potMan.AddAction(4, actions[6]);
            Assert.AreEqual(1650, potMan.Total);
            Assert.AreEqual(4, potMan.PotCount);
            Assert.AreEqual(625, potMan.Pots[0].Size);
            Assert.AreEqual(500, potMan.Pots[1].Size);
            Assert.AreEqual(75, potMan.Pots[2].Size);
            Assert.AreEqual(450, potMan.Pots[3].Size);

            uint[] strengths = new uint[5];
            strengths[0] = 1;
            strengths[1] = 2;
            strengths[2] = 5;
            strengths[3] = 4;
            strengths[4] = 3;


            List <Winner> winners = potMan.GetWinners(strengths);

            Assert.AreEqual(4, winners.Count);

            Assert.AreEqual(625, winners[0].Amount);
            Assert.AreEqual("Player2", winners[0].Player);

            Assert.AreEqual(500, winners[1].Amount);
            Assert.AreEqual("Player3", winners[1].Player);

            Assert.AreEqual(75, winners[2].Amount);
            Assert.AreEqual("Player3", winners[2].Player);

            Assert.AreEqual(450, winners[3].Amount);
            Assert.AreEqual("Player3", winners[3].Player);
        }
Beispiel #12
0
        public void TestAllInSidePots()
        {
            Action[] actions = new Action[] {
                new Action("Player3", Action.ActionTypes.PostSmallBlind, 1),
                new Action("Player4", Action.ActionTypes.PostBigBlind, 2),
                new Action("Player0", Action.ActionTypes.Raise, 250, true),
                new Action("Player1", Action.ActionTypes.Raise, 275, true),
                new Action("Player2", Action.ActionTypes.Call, 125, true),
                new Action("Player3", Action.ActionTypes.Raise, 499, true),
                new Action("Player4", Action.ActionTypes.Call, 498, true)
            };

            Assert.AreEqual(0, potMan.Total);
            Assert.AreEqual(1, potMan.PotCount, "Started with something besides 1 pot");

            potMan.AddAction(3, actions[0]);
            Assert.AreEqual(1, potMan.Total, "small blind not added correctly");
            Assert.AreEqual(1, potMan.PotCount, "pots wrong after small blind");

            potMan.AddAction(4, actions[1]);
            Assert.AreEqual(3, potMan.Total);
            Assert.AreEqual(1, potMan.PotCount);

            potMan.AddAction(0, actions[2]);
            Assert.AreEqual(253, potMan.Total);
            Assert.AreEqual(1, potMan.PotCount);

            potMan.AddAction(1, actions[3]);
            Assert.AreEqual(528, potMan.Total);
            Assert.AreEqual(2, potMan.PotCount);
            Assert.AreEqual(503, potMan.Pots[0].Size);
            Assert.AreEqual(25, potMan.Pots[1].Size);

            potMan.AddAction(2, actions[4]);
            Assert.AreEqual(653, potMan.Total);
            Assert.AreEqual(3, potMan.PotCount);
            Assert.AreEqual(378, potMan.Pots[0].Size);
            Assert.AreEqual(250, potMan.Pots[1].Size);
            Assert.AreEqual(25, potMan.Pots[2].Size);

            potMan.AddAction(3, actions[5]);
            Assert.AreEqual(1152, potMan.Total);
            Assert.AreEqual(4, potMan.PotCount);
            Assert.AreEqual(502, potMan.Pots[0].Size);
            Assert.AreEqual(375, potMan.Pots[1].Size);
            Assert.AreEqual(50, potMan.Pots[2].Size);
            Assert.AreEqual(225, potMan.Pots[3].Size);

            potMan.AddAction(4, actions[6]);
            Assert.AreEqual(1650, potMan.Total);
            Assert.AreEqual(4, potMan.PotCount);
            Assert.AreEqual(625, potMan.Pots[0].Size);
            Assert.AreEqual(500, potMan.Pots[1].Size);
            Assert.AreEqual(75, potMan.Pots[2].Size);
            Assert.AreEqual(450, potMan.Pots[3].Size);

            uint[] strengths = new uint[5];
            strengths[0] = 1;
            strengths[1] = 2;
            strengths[2] = 5;
            strengths[3] = 4;
            strengths[4] = 3;

            List<Winner> winners = potMan.GetWinners(strengths);
            Assert.AreEqual(4, winners.Count);

            Assert.AreEqual(625, winners[0].Amount);
            Assert.AreEqual("Player2", winners[0].Player);

            Assert.AreEqual(500, winners[1].Amount);
            Assert.AreEqual("Player3", winners[1].Player);

            Assert.AreEqual(75, winners[2].Amount);
            Assert.AreEqual("Player3", winners[2].Player);

            Assert.AreEqual(450, winners[3].Amount);
            Assert.AreEqual("Player3", winners[3].Player);
        }
Beispiel #13
0
        public void TestTotal()
        {
            Action[] actions = new Action[] {
                new Action("Player3", Action.ActionTypes.PostSmallBlind, 1),
                new Action("Player4", Action.ActionTypes.PostBigBlind, 2),
                new Action("Player0", Action.ActionTypes.Raise, 4),
                new Action("Player1", Action.ActionTypes.Fold),
                new Action("Player2", Action.ActionTypes.Fold),
                new Action("Player3", Action.ActionTypes.Fold),
                new Action("Player4", Action.ActionTypes.Raise, 4),
                new Action("Player0", Action.ActionTypes.Call, 2),
                new Action("Player4", Action.ActionTypes.Raise, 194, true),
                new Action("Player0", Action.ActionTypes.Fold)
            };

            potMan.AddAction(3, actions[0]);
            Assert.AreEqual(1, potMan.Total);
            potMan.AddAction(4, actions[1]);
            Assert.AreEqual(3, potMan.Total);
            potMan.AddAction(0, actions[2]);
            Assert.AreEqual(7, potMan.Total);
            potMan.AddAction(1, actions[3]);
            Assert.AreEqual(7, potMan.Total);
            potMan.AddAction(2, actions[4]);
            Assert.AreEqual(7, potMan.Total);
            potMan.AddAction(3, actions[5]);
            Assert.AreEqual(7, potMan.Total);
            potMan.AddAction(4, actions[6]);
            Assert.AreEqual(11, potMan.Total);
            potMan.AddAction(0, actions[7]);
            Assert.AreEqual(13, potMan.Total);
            potMan.AddAction(4, actions[8]);
            Assert.AreEqual(207, potMan.Total);
            potMan.AddAction(0, actions[9]);
            Assert.AreEqual(207, potMan.Total);
        }