Ejemplo n.º 1
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 32
            };

            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);
        }
Ejemplo n.º 2
0
        public void GetAction(HandHistory history, out holdem_engine.Action.ActionTypes type, out double amount)
        {
            PokerHandHistory.PokerHand xml = history.ToXmlHand();

            PokerHandHistory.PokerHandXML hands = new PokerHandHistory.PokerHandXML()
            {
                Hands = new PokerHandHistory.PokerHand[] { xml }
            };

            StringBuilder sb = new StringBuilder();

            using (TextWriter writer = new StringWriter(sb))
            {
                XmlSerializer ser = new XmlSerializer(typeof(PokerHandHistory.PokerHandXML));
                ser.Serialize(writer, hands);
            }

            Console.WriteLine(sb.ToString());
            if (actions != null && curAction < actions.Length)
            {
                holdem_engine.Action action = actions[curAction++];
                type   = action.ActionType;
                amount = action.Amount;
            }
            else
            {
                type   = holdem_engine.Action.ActionTypes.Fold;
                amount = 0;
            }
        }
Ejemplo n.º 3
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, 100),
                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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 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
        }
Ejemplo n.º 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
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 10
0
        public void SetUp()
        {
            engine = new HandEngine();

            #region Setup the actions
            Action[] jcloub = new Action[]{
                new Action("jcloub", Action.ActionTypes.Raise, 15),
                new Action("jcloub", Action.ActionTypes.Bet, 10),
                new Action("jcloub", Action.ActionTypes.Bet, 20),
                new Action("jcloub", Action.ActionTypes.Bet, 20),
            };

            Action[] makelgrus = new Action[]{
                new Action("MakelGrus", Action.ActionTypes.Call, 10),
                new Action("MakelGrus", Action.ActionTypes.Call, 10),
                new Action("MakelGrus", Action.ActionTypes.Call, 20),
                new Action("MakelGrus", Action.ActionTypes.Fold),
            };

            Action[] hustler_ed = new Action[]{
                new Action("Hustler_Ed", Action.ActionTypes.Call, 10),
                new Action("Hustler_Ed", Action.ActionTypes.Call, 10),
                new Action("Hustler_Ed", Action.ActionTypes.Call, 10),
                new Action("Hustler_Ed", Action.ActionTypes.Call, 20),
                new Action("Hustler_Ed", Action.ActionTypes.Fold),
            };

            Action[] shammybaby = new Action[]{
                new Action("Shammybaby", Action.ActionTypes.Fold),
            };

            Action[] marine0193 = new Action[]{
                new Action("marine0193", Action.ActionTypes.Fold),
            };

            Action[] teejayortj5 = new Action[]{
                new Action("TeeJayorTJ5", Action.ActionTypes.Fold),
            };
            #endregion

            #region Setup players
            SequencePlayer[] brains = new SequencePlayer[]{
                new SequencePlayer(jcloub),
                new SequencePlayer(makelgrus),
                new SequencePlayer(hustler_ed),
                new SequencePlayer(shammybaby),
                new SequencePlayer(marine0193),
                new SequencePlayer(teejayortj5)
            };

            var seqPlayers = new Seat[]{
                new Seat(1, "jcloub", 2044.5, brains[0]),
                new Seat(3, "MakelGrus", 498, brains[1]),
                new Seat(5, "Hustler_Ed", 470, brains[2]),
                new Seat(6, "Shammybaby", 551, brains[3]),
                new Seat(8, "marine0193", 538, brains[4]),
                new Seat(10, "TeeJayorTJ5", 484, brains[5])
            };
            #endregion

            var blinds = new double[] { 5, 10 };

            engine = new HandEngine();
            hist = new HandHistory(seqPlayers, 1, 10, blinds, 0, BettingStructure.Limit);
            engine.PlayHand(hist);
        }
Ejemplo n.º 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;


            IList <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);
        }
Ejemplo n.º 12
0
        public void SetUp()
        {
            engine = new HandEngine();

            #region Setup the actions
            Action[] jcloub = new Action[] {
                new Action("jcloub", Action.ActionTypes.Raise, 15),
                new Action("jcloub", Action.ActionTypes.Bet, 10),
                new Action("jcloub", Action.ActionTypes.Bet, 20),
                new Action("jcloub", Action.ActionTypes.Bet, 20),
            };

            Action[] makelgrus = new Action[] {
                new Action("MakelGrus", Action.ActionTypes.Call, 10),
                new Action("MakelGrus", Action.ActionTypes.Call, 10),
                new Action("MakelGrus", Action.ActionTypes.Call, 20),
                new Action("MakelGrus", Action.ActionTypes.Fold),
            };

            Action[] hustler_ed = new Action[] {
                new Action("Hustler_Ed", Action.ActionTypes.Call, 10),
                new Action("Hustler_Ed", Action.ActionTypes.Call, 10),
                new Action("Hustler_Ed", Action.ActionTypes.Call, 10),
                new Action("Hustler_Ed", Action.ActionTypes.Call, 20),
                new Action("Hustler_Ed", Action.ActionTypes.Fold),
            };

            Action[] shammybaby = new Action[] {
                new Action("Shammybaby", Action.ActionTypes.Fold),
            };

            Action[] marine0193 = new Action[] {
                new Action("marine0193", Action.ActionTypes.Fold),
            };

            Action[] teejayortj5 = new Action[] {
                new Action("TeeJayorTJ5", Action.ActionTypes.Fold),
            };
            #endregion

            #region Setup players
            SequencePlayer[] brains = new SequencePlayer[] {
                new SequencePlayer(jcloub),
                new SequencePlayer(makelgrus),
                new SequencePlayer(hustler_ed),
                new SequencePlayer(shammybaby),
                new SequencePlayer(marine0193),
                new SequencePlayer(teejayortj5)
            };

            var seqPlayers = new Seat[] {
                new Seat(1, "jcloub", 2044.5, brains[0]),
                new Seat(3, "MakelGrus", 498, brains[1]),
                new Seat(5, "Hustler_Ed", 470, brains[2]),
                new Seat(6, "Shammybaby", 551, brains[3]),
                new Seat(8, "marine0193", 538, brains[4]),
                new Seat(10, "TeeJayorTJ5", 484, brains[5])
            };
            #endregion

            var blinds = new double[] { 5, 10 };

            engine = new HandEngine();
            hist   = new HandHistory(seqPlayers, 1, 10, blinds, 0, BettingStructure.Limit);
            engine.PlayHand(hist);
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
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 32
            };

            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);
        }