Exemplo n.º 1
0
        public void AddAction(int pIdx, BitPoker.Engine.Action action)
        {
            action = _betManager.GetValidatedAction(action);
            _betManager.Commit(action);

            this.CurrentActions.Add(action); //CHECK THIS

            if (action.Amount > 0)
            {
                _seats[pIdx].Chips -= action.Amount;
            }

            //update the pots
            _potManager.AddAction(pIdx, action);

            if (action.ActionType == BitPoker.Engine.Action.ActionTypes.None)
            {
                throw new Exception("Must have an action");
            }

            //if the player either folded or went all-in, they can no longer
            //bet so remove them from the player pool
            if (action.ActionType == BitPoker.Engine.Action.ActionTypes.Fold)
            {
                _playerIndices.Remove(pIdx);
                this.Folded[pIdx] = true;
            }
            else if (action.AllIn)
            {
                _playerIndices.Remove(pIdx);
                this.AllIn[pIdx] = true;
            }
        }
Exemplo n.º 2
0
        public void Should_Add_Big_Blind()
        {
            // namesToChips["Player0"] = 200;
            // namesToChips["Player1"] = 200;
            // namesToChips["Player2"] = 200;
            // namesToChips["Player3"] = 200;
            // namesToChips["Player4"] = 200;

            UInt64[]   blinds = new UInt64[] { 1, 2 };
            BetManager betMan = new BetManager(namesToChips, BettingStructure.NoLimit, blinds, 0);

            FastPokerAction action = betMan.GetValidatedAction(new FastPokerAction("Player0", FastPokerAction.ActionTypes.PostSmallBlind, 1));

            Assert.True(1 == action.Amount);
            Assert.Equal(FastPokerAction.ActionTypes.PostSmallBlind, action.ActionType);

            Assert.False(betMan.RoundOver);

            betMan.Commit(action);
            Assert.False(betMan.RoundOver);

            action = betMan.GetValidatedAction(new FastPokerAction("Player1", FastPokerAction.ActionTypes.PostSmallBlind, 1));
            Assert.True(2 == action.Amount);
            Assert.Equal(FastPokerAction.ActionTypes.PostBigBlind, action.ActionType);
        }
Exemplo n.º 3
0
        public void Should_Add_Big_Blind()
        {
            namesToChips            = new Dictionary <string, UInt64>();
            namesToChips["Player0"] = 200;
            namesToChips["Player1"] = 200;
            namesToChips["Player2"] = 200;
            namesToChips["Player3"] = 200;
            namesToChips["Player4"] = 200;

            UInt64[]   blinds = new UInt64[] { 1, 2 };
            BetManager betMan = new BetManager(namesToChips, BettingStructure.NoLimit, blinds, 0);

            FastPokerAction action = betMan.GetValidatedAction(new FastPokerAction("Player3", FastPokerAction.ActionTypes.PostSmallBlind, 1));

            Assert.True(1 == action.Amount);
            Assert.Equal(FastPokerAction.ActionTypes.PostSmallBlind, action.ActionType);
        }
Exemplo n.º 4
0
        public IEnumerable <BitPoker.Engine.Action> GetValidActions()
        {
            List <BitPoker.Engine.Action> validActions = new List <BitPoker.Engine.Action>();

            //TODO:  CHECK ROUND OVER OR HAND OVER
            if (!HandOver)
            {
                int pIdx = 0; //GetFirstToAct();
                var name = _seats[pIdx].Name;

                BitPoker.Engine.Action fold = new BitPoker.Engine.Action(name, BitPoker.Engine.Action.ActionTypes.Fold);
                fold = _betManager.GetValidatedAction(fold);
                validActions.Add(fold);//may be check or fold

                if (fold.ActionType == BitPoker.Engine.Action.ActionTypes.Fold)
                {
                    BitPoker.Engine.Action call = new BitPoker.Engine.Action(name, BitPoker.Engine.Action.ActionTypes.Call);
                    call = _betManager.GetValidatedAction(call);
                    validActions.Add(call);
                }

                BitPoker.Engine.Action minRaise = new BitPoker.Engine.Action(name, BitPoker.Engine.Action.ActionTypes.Raise, 0);
                minRaise = _betManager.GetValidatedAction(minRaise);

                if (minRaise.ActionType == BitPoker.Engine.Action.ActionTypes.Bet || minRaise.ActionType == BitPoker.Engine.Action.ActionTypes.Raise)
                {
                    validActions.Add(minRaise);

                    // In no-limit and pot-limit, we return the valid raises as a pair of
                    // (min, max) bets.
                    if (!minRaise.AllIn && this.BettingStructure != BettingStructure.Limit)
                    {
                        BitPoker.Engine.Action maxRaise = new BitPoker.Engine.Action(name, BitPoker.Engine.Action.ActionTypes.Raise, _seats[pIdx].Chips);
                        maxRaise = _betManager.GetValidatedAction(maxRaise);
                        if (maxRaise.Amount > minRaise.Amount)
                        {
                            validActions.Add(maxRaise);
                        }
                    }
                }
            }

            return(validActions);
        }
Exemplo n.º 5
0
        public void Should_Add_Valid_Blinds()
        {
            namesToChips            = new Dictionary <string, UInt64>();
            namesToChips["Player0"] = 200;
            namesToChips["Player1"] = 200;
            namesToChips["Player2"] = 200;
            namesToChips["Player3"] = 200;
            namesToChips["Player4"] = 200;

            UInt64[]   blinds = new UInt64[] { 1, 2 };
            BetManager 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, 50),
                new FastPokerAction("Player0", FastPokerAction.ActionTypes.Raise, 1),
            };

            FastPokerAction action = betMan.GetValidatedAction(new FastPokerAction("Player3", FastPokerAction.ActionTypes.PostSmallBlind, 1));

            Assert.True(1 == action.Amount);
            Assert.Equal(FastPokerAction.ActionTypes.PostSmallBlind, action.ActionType);

            betMan.Commit(action);
            Assert.False(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[1]);
            Assert.True(2 == action.Amount);
            Assert.Equal(FastPokerAction.ActionTypes.PostBigBlind, action.ActionType);

            betMan.Commit(action);
            Assert.False(betMan.RoundOver);

            action = betMan.GetValidatedAction(actions[2]);
            Assert.True(4 == action.Amount);
            Assert.Equal(Engine.Action.ActionTypes.Raise, action.ActionType);

            betMan.Commit(action);
            Assert.False(betMan.RoundOver);
        }