GetValidatedAction() 공개 메소드

Checks the given Action object to make sure it's valid. Invalid actions will be changed to the closest corresponding action. The convention used to change invalid actions is as follows: - Actions of type None, JoinTable, SitOut, LeaveTable will automatically become Fold Actions. - Invalid Post* actions will be treated as Checks (see below). - Invalid Checks will be turned into Folds. - Bets which are sent after another player has bet this round will be turned into raises and have to adhear to the same convention (see below). - Raises which are less than MinimumRaise will be changed to be of Amount = MinimumRaise. - Raises which are more than the size of a player's remaining chips will be changed into AllIns and adhear to the same convention (see below). - AllIns will have their Amount changed to the size of a player's remaining stack.
public GetValidatedAction ( System.Action action ) : System.Action
action System.Action The Action which needs to be validated.
리턴 System.Action
예제 #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);
        }
예제 #2
0
        private void AddAction(int pIdx, Action action, List <Action> curRoundActions)
        {
            action = _betManager.GetValidatedAction(action);

            _betManager.Commit(action);
            curRoundActions.Add(action);

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

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

            if (action.ActionType == 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 == Action.ActionTypes.Fold)
            {
                _playerIndices.Remove(pIdx);
                _history.Folded[pIdx] = true;
            }
            else if (action.AllIn)
            {
                _playerIndices.Remove(pIdx);
                _history.AllIn[pIdx] = true;
            }
        }
예제 #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, 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);
        }
예제 #4
0
        public IEnumerable <Action> GetValidActions()
        {
            List <Action> validActions = new List <Action>();

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

                Action fold = new Action(name, Action.ActionTypes.Fold);
                fold = _betManager.GetValidatedAction(fold);
                validActions.Add(fold);//may be check or fold
                if (fold.ActionType == Action.ActionTypes.Fold)
                {
                    Action call = new Action(name, Action.ActionTypes.Call);
                    call = _betManager.GetValidatedAction(call);
                    validActions.Add(call);
                }
                Action minRaise = new Action(name, Action.ActionTypes.Raise, 0);
                minRaise = _betManager.GetValidatedAction(minRaise);
                if (minRaise.ActionType == Action.ActionTypes.Bet || minRaise.ActionType == 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 && _history.BettingStructure != BettingStructure.Limit)
                    {
                        Action maxRaise = new Action(name, Action.ActionTypes.Raise, _seats[pIdx].Chips);
                        maxRaise = _betManager.GetValidatedAction(maxRaise);
                        if (maxRaise.Amount > minRaise.Amount)
                        {
                            validActions.Add(maxRaise);
                        }
                    }
                }
            }

            return(validActions);
        }
예제 #5
0
 public Action Validate(Action nextAction)
 {
     return(_betManager.GetValidatedAction(nextAction));
 }
예제 #6
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);
        }