Example #1
0
        public void Test_GameString_FromGameDef_Over()
        {
            GameDefinition gameDef = LoadGameDef();

            GameState gs = new GameState(gameDef, 2);

            VerifyGameState(gs, "", false, -1, 1.5, 1, 1, GameState.InvalidPosition, true, 0, 0, 0, false, 2);
            VerifyGameStateMethods(gs, gameDef, new Ak[] { Ak.d });
            VerifyPlayerState(gs.Players[0], "", -0.5, "", 0.5, 0.5, 0, false, false, false, true);
            VerifyPlayerState(gs.Players[1], "", -1, "", 1, 1, 0, false, false, false, true);

            gs.UpdateByAction(PokerAction.d(0, "Ac Ad"), gameDef);
            gs.UpdateByAction(PokerAction.d(1, "2c 3d"), gameDef);

            VerifyPlayerState(gs.Players[0], "", -0.5, "Ac Ad", 0.5, 0.5, 0, false, false, true, true);
            VerifyPlayerState(gs.Players[1], "", -1, "2c 3d", 1, 1, 0, false, false, true, true);

            gs.UpdateByAction(PokerAction.c(0), gameDef);
            gs.UpdateByAction(PokerAction.c(1), gameDef);
            gs.UpdateByAction(PokerAction.d("Ah As Qc"), gameDef);
            gs.UpdateByAction(PokerAction.c(1), gameDef);
            gs.UpdateByAction(PokerAction.c(0), gameDef);
            gs.UpdateByAction(PokerAction.d("Jh"), gameDef);
            gs.UpdateByAction(PokerAction.c(1), gameDef);
            gs.UpdateByAction(PokerAction.c(0), gameDef);
            gs.UpdateByAction(PokerAction.d("Ts"), gameDef);
            gs.UpdateByAction(PokerAction.c(1), gameDef);
            gs.UpdateByAction(PokerAction.c(0), gameDef);
            UInt32[] ranks = new UInt32[] { 2, 1 };
            gs.UpdateByShowdown(ranks, gameDef);
            VerifyGameState(gs, "", true, 3, 2, 0, 0, 0, false, GameState.InvalidPosition, 0, 0, true, 2);
            VerifyGameStateMethods(gs, gameDef, new Ak[] { });
            VerifyPlayerState(gs.Players[0], "", 1, "Ac Ad Ah As Qc Jh Ts", 1, 0, 1, false, false, false, true);
            VerifyPlayerState(gs.Players[1], "", -1, "2c 3d Ah As Qc Jh Ts", 1, 0, -1, false, false, false, true);
        }
Example #2
0
 public override PokerAction OnActionRequired(string gameString)
 {
     base.OnActionRequired(gameString);
     if (CurGameState.BetCount < GameDefinition.BetsCountLimits[CurGameState.Round])
     {
         return(PokerAction.r(0, 0));
     }
     return(PokerAction.c(0));
 }
Example #3
0
        void ParseActionsForHe(ServerMessage msg, GameRecord gr)
        {
            string[] privateCards = msg.GetPrivateCards();
            // Reverse positions for our format
            for (int p = 1; p >= 0; --p)
            {
                string cards = privateCards[p];
                if (cards == "")
                {
                    cards = "? ?";
                }
                else
                {
                    cards = CardsFromAcpc(cards);
                }
                PokerAction a = PokerAction.d(1 - p, cards);
                gr.Actions.Add(a);
            }

            for (int r = 0; r <= msg.Round; ++r)
            {
                if (r > 0)
                {
                    PokerAction a = PokerAction.d(CardsFromAcpc(msg.Cards[r]));
                    gr.Actions.Add(a);
                }
                for (int move = 0; move < msg.Betting[r].Length; ++move)
                {
                    PokerAction a        = null;
                    int         position = r == 0 ? move % 2 : 1 - (move % 2);
                    switch (msg.Betting[r][move])
                    {
                    case 'r':
                        a = PokerAction.r(position, r < 2 ? 1 : 2);
                        break;

                    case 'c':
                        a = PokerAction.c(position);
                        break;

                    case 'f':
                        a = PokerAction.f(position);
                        break;
                    }
                    gr.Actions.Add(a);
                }
            }
        }
Example #4
0
        public void Test_GameString_GameDef_NotOver()
        {
            GameDefinition gameDef = LoadGameDef();

            string gameString = "14; P1{100 .5 0} P2{200 1 0}; 0d{Ac Ad} 1d{Kc Kd};";

            GameState gs = new GameState(gameString, gameDef);

            VerifyGameState(gs, "14", false, 0, 1.5, 1, 1, 1, false, 0, 2, 0, false, 2);
            VerifyGameStateMethods(gs, gameDef, new Ak[] { Ak.f, Ak.c, Ak.r });
            VerifyPlayerState(gs.Players[0], "P1", 99.5, "Ac Ad", 0.5, 0.5, 0, false, false, true, true);
            VerifyPlayerState(gs.Players[1], "P2", 199, "Kc Kd", 1, 1, 0, false, false, true, true);

            gs.UpdateByAction(PokerAction.c(0), gameDef);
            VerifyGameState(gs, "14", false, 0, 2, 1, 1, 0, false, 1, 0, 0, false, 2);
            VerifyGameStateMethods(gs, gameDef, new Ak[] { Ak.c, Ak.r });
            VerifyPlayerState(gs.Players[0], "P1", 99, "Ac Ad", 1, 1, 0, false, false, false, true);
            VerifyPlayerState(gs.Players[1], "P2", 199, "Kc Kd", 1, 1, 0, false, false, true, true);

            gs.UpdateByAction(PokerAction.c(1), gameDef);
            VerifyGameState(gs, "14", false, 0, 2, 1, 1, 1, true, GameState.DealerPosition, 0, 0, false, 2);
            VerifyGameStateMethods(gs, gameDef, new Ak[] { Ak.d });
            VerifyPlayerState(gs.Players[0], "P1", 99, "Ac Ad", 1, 1, 0, false, false, false, true);
            VerifyPlayerState(gs.Players[1], "P2", 199, "Kc Kd", 1, 1, 0, false, false, false, true);

            gs.UpdateByAction(PokerAction.d("As 2d 4d"), gameDef);
            VerifyGameState(gs, "14", false, 1, 2, 0, 0, GameState.DealerPosition, false, 1, 1, 0, false, 2);
            VerifyGameStateMethods(gs, gameDef, new Ak[] { Ak.c, Ak.r });
            VerifyPlayerState(gs.Players[0], "P1", 99, "Ac Ad As 2d 4d", 1, 0, 0, false, false, true, true);
            VerifyPlayerState(gs.Players[1], "P2", 199, "Kc Kd As 2d 4d", 1, 0, 0, false, false, true, true);

            gs.UpdateByAction(PokerAction.r(1, gameDef.BetStructure[1]), gameDef);
            VerifyGameState(gs, "14", false, 1, 3, 1, 1, 1, false, 0, 0, 0, false, 2);
            VerifyGameStateMethods(gs, gameDef, new Ak[] { Ak.f, Ak.c, Ak.r });
            VerifyPlayerState(gs.Players[0], "P1", 99, "Ac Ad As 2d 4d", 1, 0, 0, false, false, true, true);
            VerifyPlayerState(gs.Players[1], "P2", 198, "Kc Kd As 2d 4d", 2, 1, 0, false, false, false, true);

            gs.UpdateByAction(PokerAction.f(0), gameDef);
            VerifyGameState(gs, "14", true, 1, 3, 1, 1, 0, false, GameState.InvalidPosition, 0, 1, false, 2);
            VerifyGameStateMethods(gs, gameDef, new Ak[] {});
            VerifyPlayerState(gs.Players[0], "P1", 99, "Ac Ad As 2d 4d", 1, 0, -1, true, false, false, false);
            VerifyPlayerState(gs.Players[1], "P2", 201, "Kc Kd As 2d 4d", 2, 1, 1, false, false, false, true);
        }
Example #5
0
        private PokerAction GetBestAction(GameState CurGameState)
        {
            Debug.Assert(CurStrategyNode.State.CurrentActor == _pos);
            double         maxVal   = double.MinValue;
            ActionTreeNode bestNode = null;

            foreach (ActionTreeNode child in CurStrategyNode.Children)
            {
                double childValue = CurGameState.Round == 0 ? child.PreflopValues[(int)_pocketKind] : child.Value;
                if (childValue > maxVal)
                {
                    bestNode = child;
                    maxVal   = childValue;
                }
                else if (childValue == maxVal)
                {
                    if (ActionPreference(child.ActionKind) > ActionPreference(bestNode.ActionKind))
                    {
                        bestNode = child;
                    }
                }
            }

            PokerAction result;

            if (bestNode != null)
            {
                result = new PokerAction {
                    Kind = bestNode.ActionKind
                };
            }
            else
            {
                Debug.Assert(CurStrategyNode.Children.Count > 0);
                // We have never been here - just call
                result = PokerAction.c(0);
            }
            return(result);
        }
Example #6
0
        public void Test_GameString_NoGameDef_NotOver()
        {
            // As we do not have GameDef, CurrentActor == invalid and IsDealerAction is false.

            string gameString = "11;P1{100 5 0} P2{200 10 0}; 0d{Ah Ad} 1d{Kh Kd} 0r13 1r10;";

            GameState gs = new GameState(gameString, null);

            VerifyGameState(gs, "11", false, 0, 56, 33, 3, 1, false, GameState.InvalidPosition, 0, 0, false, 2);
            VerifyPlayerState(gs.Players[0], "P1", 77, "Ah Ad", 23, 23, 0, false, false, true, true);
            VerifyPlayerState(gs.Players[1], "P2", 167, "Kh Kd", 33, 33, 0, false, false, false, true);

            gs.UpdateByAction(PokerAction.c(0), null);
            VerifyGameState(gs, "11", false, 0, 66, 33, 3, 0, true, GameState.InvalidPosition, 0, 0, false, 2);
            VerifyPlayerState(gs.Players[0], "P1", 67, "Ah Ad", 33, 33, 0, false, false, false, true);
            VerifyPlayerState(gs.Players[1], "P2", 167, "Kh Kd", 33, 33, 0, false, false, false, true);


            gs.UpdateByAction(PokerAction.d("As 2d 4d"), null);

            VerifyGameState(gs, "11", false, 1, 66, 0, 0,
                            GameState.DealerPosition, false, GameState.InvalidPosition, 1, 0, false, 2);
            VerifyPlayerState(gs.Players[0], "P1", 67, "Ah Ad As 2d 4d", 33, 0, 0, false, false, true, true);
            VerifyPlayerState(gs.Players[1], "P2", 167, "Kh Kd As 2d 4d", 33, 0, 0, false, false, true, true);


            gs.UpdateByAction(PokerAction.r(1, 15), null);
            VerifyGameState(gs, "11", false, 1, 81, 15, 1,
                            1, false, GameState.InvalidPosition, 0, 0, false, 2);
            VerifyPlayerState(gs.Players[0], "P1", 67, "Ah Ad As 2d 4d", 33, 0, 0, false, false, true, true);
            VerifyPlayerState(gs.Players[1], "P2", 152, "Kh Kd As 2d 4d", 48, 15, 0, false, false, false, true);

            gs.UpdateByAction(PokerAction.f(0), null);
            VerifyGameState(gs, "11", true, 1, 81, 15, 1,
                            0, false, GameState.InvalidPosition, 0, 1, false, 2);
            VerifyPlayerState(gs.Players[0], "P1", 67, "Ah Ad As 2d 4d", 33, 0, -33, true, false, false, false);
            VerifyPlayerState(gs.Players[1], "P2", 233, "Kh Kd As 2d 4d", 48, 15, 33, false, false, false, true);
        }
Example #7
0
        private PokerAction ConvertStrActionToPokerAction(int nextStNodeIdx)
        {
            StrategyTreeNode nextStNode = new StrategyTreeNode();

            _strategies[_pos].GetNode(nextStNodeIdx, &nextStNode);
            if (!nextStNode.IsPlayerAction(_pos))
            {
                throw new ApplicationException(String.Format("{0} : wrong move: {1}", GetBotStateDiagText(), nextStNode.ToStrategicString(null)));
            }
            double amount = nextStNode.Amount;

            double raiseAmount = _gameState.Players[_pos].Bet + amount - _gameState.Bet;

            if (raiseAmount > 0)
            {
                return(PokerAction.r(_pos, raiseAmount));
            }
            if (amount == 0 && _gameState.Players[_pos].Bet < _gameState.Bet)
            {
                return(PokerAction.f(_pos));
            }
            return(PokerAction.c(_pos));
        }
        private void LoadStrategy()
        {
            Regex reProbabTriple = new Regex(@"^([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)", RegexOptions.Compiled);

            using (StreamReader reader = new StreamReader(SourceFile))
            {
                // For debugging
                int lineCount = 0;
                for (; ;)
                {
                    string line = reader.ReadLine();
                    lineCount++;
                    // Console.WriteLine(line);
                    if (line.StartsWith("#"))
                    {
                        continue;
                    }

                    Match  m            = reProbabTriple.Match(line);
                    string actionString = m.Groups[1].Value;

                    double probabR = double.Parse(m.Groups[2].Value, CultureInfo.InvariantCulture);
                    double probabC = double.Parse(m.Groups[3].Value, CultureInfo.InvariantCulture);
                    double probabF = double.Parse(m.Groups[4].Value, CultureInfo.InvariantCulture);

                    int round;
                    List <PokerAction> actions = ParseActionString(actionString, out round);

                    GameState gs = new GameState(GameDef);
                    foreach (PokerAction a in actions)
                    {
                        gs.UpdateByAction(a, GameDef);
                    }

                    List <Ak> allowedActions = gs.GetAllowedActions(GameDef);

                    if (allowedActions.Contains(Ak.r))
                    {
                        actions.Add(PokerAction.r(HeroPosition, GetRaiseAmount(round)));
                        UpdateProbability(actions.ToArray(), probabR);
                        actions.RemoveAt(actions.Count - 1);
                    }

                    if (allowedActions.Contains(Ak.c))
                    {
                        actions.Add(PokerAction.c(HeroPosition));
                        UpdateProbability(actions.ToArray(), probabC);
                        actions.RemoveAt(actions.Count - 1);
                    }

                    if (allowedActions.Contains(Ak.f))
                    {
                        actions.Add(PokerAction.f(HeroPosition));
                        UpdateProbability(actions.ToArray(), probabF);
                    }

                    if (reader.EndOfStream)
                    {
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// Parses Open CFG format to PokerAction list. Converts cards to indexes for both abstracted
        /// and non-abstracted games.
        /// </summary>
        List <PokerAction> ParseActionString(string key, out int round)
        {
            List <PokerAction> actions = new List <PokerAction>();

            actions.Add(new PokerAction());
            string[] parts = key.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
            if (parts.Length != 2)
            {
                throw new ApplicationException("Wrong format");
            }
            string pocket = parts[0].Substring(0, 1);
            string board  = parts[0].Length == 1 ? null : parts[0].Substring(1, 1);

            // Add two deals, as this is required to update game state.
            // One deal will be ignored later in the conversion to a strategic string.
            actions.Add(PokerAction.d(0, GameDef.DeckDescr.GetIndex(pocket).ToString()));
            actions.Add(PokerAction.d(1, GameDef.DeckDescr.GetIndex(pocket).ToString()));

            round = 0;
            int pos = 0;

            foreach (char actChar in parts[1].Substring(1))
            {
                switch (actChar)
                {
                case 'r':
                    actions.Add(PokerAction.r(pos, GetRaiseAmount(round)));
                    pos = 1 - pos;
                    break;

                case 'c':
                    actions.Add(PokerAction.c(pos));
                    pos = 1 - pos;
                    break;

                case '/':
                    actions.Add(PokerAction.d(GameDef.DeckDescr.GetIndex(board).ToString()));
                    round++;
                    pos = 0;
                    break;

                default:
                    throw new ApplicationException("Wrong format");
                }
            }
            if (ChanceAbstraction != null)
            {
                int[] hand = new int[2];
                round = -1;
                for (int i = 0; i < actions.Count; ++i)
                {
                    PokerAction a = actions[i];
                    if (a.Kind == Ak.d && a.Position <= 0)
                    {
                        ++round;
                        hand[round] = int.Parse(a.Cards);
                    }
                    if (a.IsDealerAction() && a.Cards != "")
                    {
                        int bucket = ChanceAbstraction.GetAbstractCard(hand, round + 1);
                        a.Cards = bucket.ToString();
                    }
                }
            }

            return(actions);
        }
Example #10
0
 public override PokerAction OnActionRequired(string gameString)
 {
     return(PokerAction.c(0));
 }
Example #11
0
 virtual public PokerAction OnActionRequired(string gameString)
 {
     OnActionRequiredCount++;
     CurGameState = new GameState(gameString, GameDefinition);
     return(PokerAction.c(0));
 }
Example #12
0
        public void Test_HasPlayerActed()
        {
            GameDefinition gameDef = LoadGameDef();
            GameState      gs      = new GameState(gameDef, 2);

            Assert.IsFalse(gs.HasPlayerActed(0));
            Assert.IsFalse(gs.HasPlayerActed(1));

            gs.UpdateByAction(PokerAction.d(0, "Ac Ad"), gameDef);
            Assert.IsFalse(gs.HasPlayerActed(0));
            Assert.IsFalse(gs.HasPlayerActed(1));

            gs.UpdateByAction(PokerAction.d(1, "2c 3d"), gameDef);
            Assert.IsFalse(gs.HasPlayerActed(0));
            Assert.IsFalse(gs.HasPlayerActed(1));

            gs.UpdateByAction(PokerAction.c(0), gameDef);
            Assert.IsTrue(gs.HasPlayerActed(0));
            Assert.IsFalse(gs.HasPlayerActed(1));

            gs.UpdateByAction(PokerAction.c(1), gameDef);
            Assert.IsFalse(gs.HasPlayerActed(0));
            Assert.IsTrue(gs.HasPlayerActed(1));

            gs.UpdateByAction(PokerAction.d("Ah As Qc"), gameDef);
            Assert.IsFalse(gs.HasPlayerActed(0));
            Assert.IsFalse(gs.HasPlayerActed(1));

            gs.UpdateByAction(PokerAction.c(1), gameDef);
            Assert.IsFalse(gs.HasPlayerActed(0));
            Assert.IsTrue(gs.HasPlayerActed(1));

            gs.UpdateByAction(PokerAction.r(0, 1), gameDef);
            Assert.IsTrue(gs.HasPlayerActed(0));
            Assert.IsFalse(gs.HasPlayerActed(1));

            gs.UpdateByAction(PokerAction.c(1), gameDef);
            Assert.IsFalse(gs.HasPlayerActed(0));
            Assert.IsTrue(gs.HasPlayerActed(1));

            gs.UpdateByAction(PokerAction.d("Jh"), gameDef);
            Assert.IsFalse(gs.HasPlayerActed(0));
            Assert.IsFalse(gs.HasPlayerActed(1));

            gs.UpdateByAction(PokerAction.c(1), gameDef);
            Assert.IsFalse(gs.HasPlayerActed(0));
            Assert.IsTrue(gs.HasPlayerActed(1));

            gs.UpdateByAction(PokerAction.c(0), gameDef);
            Assert.IsTrue(gs.HasPlayerActed(0));
            Assert.IsFalse(gs.HasPlayerActed(1));

            gs.UpdateByAction(PokerAction.d("Ts"), gameDef);
            Assert.IsFalse(gs.HasPlayerActed(0));
            Assert.IsFalse(gs.HasPlayerActed(1));

            gs.UpdateByAction(PokerAction.c(1), gameDef);
            Assert.IsFalse(gs.HasPlayerActed(0));
            Assert.IsTrue(gs.HasPlayerActed(1));

            gs.UpdateByAction(PokerAction.c(0), gameDef);
            Assert.IsTrue(gs.HasPlayerActed(0));
            Assert.IsFalse(gs.HasPlayerActed(1));
            Assert.IsTrue(gs.IsGameOver);
        }
Example #13
0
        private static void ProcessGameContext(GameContext context)
        {
            int            nodeId = context.Global.NodeId++;
            GameDefinition gd     = context.Global.GameDef;
            ChanceTree     tree   = context.Global.Tree;

            while (!context.GameState.IsGameOver && !context.GameState.IsDealerActing)
            {
                context.GameState.UpdateByAction(PokerAction.c(context.GameState.CurrentActor), gd);
            }

            if (tree != null)
            {
                tree.SetDepth(nodeId, (byte)context.Depth);
                int position = context.GameState.LastActor;
                if (context.Deal != null && context.Deal.SharedCardsPlayer != -1)
                {
                    position = context.Deal.SharedCardsPlayer;
                }
                if (nodeId == 0)
                {
                    position = gd.MinPlayers;
                }
                tree.Nodes[nodeId].Position = position;
                if (context.Deal == null)
                {
                    tree.Nodes[nodeId].Card = -1;
                }
                else
                {
                    // This double-conversion assures that for decks with duplicates
                    // the same index
                    int stableCardIdx = gd.DeckDescr.GetIndex(gd.DeckDescr.CardNames[context.Deal.CardIdx]);
                    tree.Nodes[nodeId].Card = stableCardIdx;
                }
            }

            if (context.GameState.IsGameOver)
            {
                context.CombCountOfLeaves = context.DealCount;
                if (tree != null)
                {
                    tree.Nodes[nodeId].Probab = (double)context.CombCountOfLeaves / context.Global.TotalCombCountOfLeaves;
                    int     playersCount = gd.MinPlayers;
                    uint[]  ranks        = new uint[playersCount];
                    int[][] hands        = new int[playersCount][];
                    for (int p = 0; p < playersCount; ++p)
                    {
                        hands[p] = gd.DeckDescr.GetIndexes(context.GameState.Players[p].Hand);
                    }
                    gd.GameRules.Showdown(gd, hands, ranks);
                    context.GameState.UpdateByShowdown(ranks, gd);
                    double[] potShares = new double[gd.MinPlayers];
                    for (int p = 0; p < playersCount; ++p)
                    {
                        potShares[p] = (context.GameState.Players[p].Result + context.GameState.Players[p].InPot)
                                       / context.GameState.Pot;
                    }
                    tree.Nodes[nodeId].SetPotShare(context.GameState.GetActivePlayers(), potShares);
                }
                return;
            }

            // Deal next cards.
            List <DealT> deals = DealCards(context);

            foreach (DealT d in deals)
            {
                GameContext childContext = new GameContext(context);
                childContext.Depth++;

                childContext.DealtCards.UnionWith(gd.DeckDescr.CardSets[d.CardIdx]);
                if (d.SharedCardsPlayer == -1)
                {
                    // Non-shared deal - update game state and deal count
                    PokerAction a = PokerAction.d(context.GameState.CurrentActor, d.CardName);
                    childContext.GameState.UpdateByAction(a, gd);
                    childContext.DealCount *= d.Count;
                }
                else if (d.SharedCardsPlayer == gd.MinPlayers - 1)
                {
                    // Shared deal for last player - update game state and deal count once for all.
                    PokerAction a = PokerAction.d(-1, context.Deal.CardName);
                    childContext.GameState.UpdateByAction(a, gd);
                    childContext.DealCount *= d.Count;
                }
                childContext.Deal = d;
                ProcessGameContext(childContext);
                context.CombCountOfLeaves += childContext.CombCountOfLeaves;
                context.ChildCount        += childContext.ChildCount + 1;
            }
            if (tree != null)
            {
                tree.Nodes[nodeId].Probab = (double)context.CombCountOfLeaves / context.Global.TotalCombCountOfLeaves;
            }
        }
 public override PokerAction OnActionRequired(string gameString)
 {
     Assert.AreEqual(Name, CurGameState.Players[Position].Name);
     base.OnActionRequired(gameString);
     return(PokerAction.c(0));
 }
Example #15
0
            public override PokerAction OnActionRequired(string gameString)
            {
                // Program and verify the following moves.
                //
                // 0 Round: SB r, BB r, SB c
                // 1 Round: BB r, SB r, BB c

                base.OnActionRequired(gameString);
                if (Name == "Player0")
                {
                    // Player0 is SB
                    switch (OnActionRequiredCount)
                    {
                    // Round 0
                    case 1:
                        VerifyActions(gameString, 2, null, "? ?");

                        Assert.AreEqual(0, CurGameState.Round);
                        Assert.AreEqual(1.5, CurGameState.Pot);
                        Assert.AreEqual(1, CurGameState.Bet);
                        Assert.AreEqual(1, CurGameState.BetCount);
                        Assert.AreEqual(Position, CurGameState.CurrentActor);
                        Assert.AreEqual(1, CurGameState.GetMinBet(GameDefinition));
                        Assert.AreEqual(1, CurGameState.GetMaxBet(GameDefinition));

                        Assert.AreEqual(true, CurGameState.Players[0].CanActInCurrentRound);
                        Assert.AreEqual(true, CurGameState.Players[0].CanActInGame);
                        Assert.AreEqual(false, CurGameState.Players[0].IsFolded);
                        Assert.AreEqual(false, CurGameState.Players[0].IsAllIn);
                        Assert.AreEqual(0.5, CurGameState.Players[0].InPot);
                        Assert.AreEqual(0.5, CurGameState.Players[0].Bet);
                        Assert.AreEqual(-.5, CurGameState.Players[0].Stack);

                        Assert.AreEqual(true, CurGameState.Players[1].CanActInCurrentRound);
                        Assert.AreEqual(true, CurGameState.Players[1].CanActInGame);
                        Assert.AreEqual(false, CurGameState.Players[1].IsFolded);
                        Assert.AreEqual(false, CurGameState.Players[1].IsAllIn);
                        Assert.AreEqual(1, CurGameState.Players[1].InPot);
                        Assert.AreEqual(1, CurGameState.Players[1].Bet);
                        Assert.AreEqual(-1, CurGameState.Players[1].Stack);

                        return(PokerAction.r(0, 1));

                    case 2:
                        VerifyActions(gameString, 4, null, "? ?");

                        Assert.AreEqual(0, CurGameState.Round);
                        Assert.AreEqual(5, CurGameState.Pot);
                        Assert.AreEqual(3, CurGameState.Bet);
                        Assert.AreEqual(3, CurGameState.BetCount);
                        Assert.AreEqual(Position, CurGameState.CurrentActor);
                        Assert.AreEqual(1, CurGameState.GetMinBet(GameDefinition));
                        Assert.AreEqual(1, CurGameState.GetMaxBet(GameDefinition));

                        Assert.AreEqual(true, CurGameState.Players[0].CanActInCurrentRound);
                        Assert.AreEqual(true, CurGameState.Players[0].CanActInGame);
                        Assert.AreEqual(false, CurGameState.Players[0].IsFolded);
                        Assert.AreEqual(false, CurGameState.Players[0].IsAllIn);
                        Assert.AreEqual(2, CurGameState.Players[0].InPot);
                        Assert.AreEqual(2, CurGameState.Players[0].Bet);
                        Assert.AreEqual(-2, CurGameState.Players[0].Stack);

                        Assert.AreEqual(false, CurGameState.Players[1].CanActInCurrentRound);
                        Assert.AreEqual(true, CurGameState.Players[1].CanActInGame);
                        Assert.AreEqual(false, CurGameState.Players[1].IsFolded);
                        Assert.AreEqual(false, CurGameState.Players[1].IsAllIn);
                        Assert.AreEqual(3, CurGameState.Players[1].InPot);
                        Assert.AreEqual(3, CurGameState.Players[1].Bet);
                        Assert.AreEqual(-3, CurGameState.Players[1].Stack);

                        return(PokerAction.c(0));

                    // Round 1
                    case 3:
                        VerifyActions(gameString, 7, null, "? ?");

                        Assert.AreEqual(1, CurGameState.Round);
                        Assert.AreEqual(8, CurGameState.Pot);
                        Assert.AreEqual(2, CurGameState.Bet);
                        Assert.AreEqual(1, CurGameState.BetCount);
                        Assert.AreEqual(Position, CurGameState.CurrentActor);
                        Assert.AreEqual(2, CurGameState.GetMinBet(GameDefinition));
                        Assert.AreEqual(2, CurGameState.GetMaxBet(GameDefinition));

                        Assert.AreEqual(true, CurGameState.Players[0].CanActInCurrentRound);
                        Assert.AreEqual(true, CurGameState.Players[0].CanActInGame);
                        Assert.AreEqual(false, CurGameState.Players[0].IsFolded);
                        Assert.AreEqual(false, CurGameState.Players[0].IsAllIn);
                        Assert.AreEqual(3, CurGameState.Players[0].InPot);
                        Assert.AreEqual(0, CurGameState.Players[0].Bet);
                        Assert.AreEqual(-3, CurGameState.Players[0].Stack);
                        Assert.AreEqual(14, CurGameState.Players[0].Hand.Length);

                        Assert.AreEqual(false, CurGameState.Players[1].CanActInCurrentRound);
                        Assert.AreEqual(true, CurGameState.Players[1].CanActInGame);
                        Assert.AreEqual(false, CurGameState.Players[1].IsFolded);
                        Assert.AreEqual(false, CurGameState.Players[1].IsAllIn);
                        Assert.AreEqual(5, CurGameState.Players[1].InPot);
                        Assert.AreEqual(2, CurGameState.Players[1].Bet);
                        Assert.AreEqual(-5, CurGameState.Players[1].Stack);
                        Assert.AreEqual(12, CurGameState.Players[1].Hand.Length);
                        Assert.IsTrue(CurGameState.Players[1].Hand.StartsWith("? ?"));

                        return(PokerAction.r(0, 1));
                    }
                }
                else
                {
                    // Player1 is BB
                    switch (OnActionRequiredCount)
                    {
                    // Round 0
                    case 1:
                        VerifyActions(gameString, 3, "? ?", null);

                        Assert.AreEqual(0, CurGameState.Round);
                        Assert.AreEqual(3, CurGameState.Pot);
                        Assert.AreEqual(2, CurGameState.Bet);
                        Assert.AreEqual(2, CurGameState.BetCount);
                        Assert.AreEqual(Position, CurGameState.CurrentActor);
                        Assert.AreEqual(1, CurGameState.GetMinBet(GameDefinition));
                        Assert.AreEqual(1, CurGameState.GetMaxBet(GameDefinition));

                        Assert.AreEqual(false, CurGameState.Players[0].CanActInCurrentRound);
                        Assert.AreEqual(true, CurGameState.Players[0].CanActInGame);
                        Assert.AreEqual(false, CurGameState.Players[0].IsFolded);
                        Assert.AreEqual(false, CurGameState.Players[0].IsAllIn);
                        Assert.AreEqual(2, CurGameState.Players[0].InPot);
                        Assert.AreEqual(2, CurGameState.Players[0].Bet);
                        Assert.AreEqual(-2, CurGameState.Players[0].Stack);
                        Assert.AreEqual("? ?", CurGameState.Players[0].Hand);

                        Assert.AreEqual(true, CurGameState.Players[1].CanActInCurrentRound);
                        Assert.AreEqual(true, CurGameState.Players[1].CanActInGame);
                        Assert.AreEqual(false, CurGameState.Players[1].IsFolded);
                        Assert.AreEqual(false, CurGameState.Players[1].IsAllIn);
                        Assert.AreEqual(1, CurGameState.Players[1].InPot);
                        Assert.AreEqual(1, CurGameState.Players[1].Bet);
                        Assert.AreEqual(-1, CurGameState.Players[1].Stack);
                        Assert.AreEqual(5, CurGameState.Players[1].Hand.Length);

                        return(PokerAction.r(0, 1));

                    // Round 1
                    case 2:
                        VerifyActions(gameString, 6, "? ?", null);

                        Assert.AreEqual(1, CurGameState.Round);
                        Assert.AreEqual(6, CurGameState.Pot);
                        Assert.AreEqual(0, CurGameState.Bet);
                        Assert.AreEqual(0, CurGameState.BetCount);
                        Assert.AreEqual(Position, CurGameState.CurrentActor);
                        Assert.AreEqual(2, CurGameState.GetMinBet(GameDefinition));
                        Assert.AreEqual(2, CurGameState.GetMaxBet(GameDefinition));

                        Assert.AreEqual(true, CurGameState.Players[0].CanActInCurrentRound);
                        Assert.AreEqual(true, CurGameState.Players[0].CanActInGame);
                        Assert.AreEqual(false, CurGameState.Players[0].IsFolded);
                        Assert.AreEqual(false, CurGameState.Players[0].IsAllIn);
                        Assert.AreEqual(3, CurGameState.Players[0].InPot);
                        Assert.AreEqual(0, CurGameState.Players[0].Bet);
                        Assert.AreEqual(-3, CurGameState.Players[0].Stack);
                        Assert.AreEqual(14, CurGameState.Players[1].Hand.Length);

                        Assert.AreEqual(true, CurGameState.Players[1].CanActInCurrentRound);
                        Assert.AreEqual(true, CurGameState.Players[1].CanActInGame);
                        Assert.AreEqual(false, CurGameState.Players[1].IsFolded);
                        Assert.AreEqual(false, CurGameState.Players[1].IsAllIn);
                        Assert.AreEqual(3, CurGameState.Players[1].InPot);
                        Assert.AreEqual(0, CurGameState.Players[1].Bet);
                        Assert.AreEqual(-3, CurGameState.Players[1].Stack);
                        Assert.AreEqual(14, CurGameState.Players[1].Hand.Length);

                        return(PokerAction.r(0, 1));

                    case 3:
                        VerifyActions(gameString, 8, "? ?", null);

                        Assert.AreEqual(1, CurGameState.Round);
                        Assert.AreEqual(12, CurGameState.Pot);
                        Assert.AreEqual(4, CurGameState.Bet);
                        Assert.AreEqual(2, CurGameState.BetCount);
                        Assert.AreEqual(Position, CurGameState.CurrentActor);
                        Assert.AreEqual(2, CurGameState.GetMinBet(GameDefinition));
                        Assert.AreEqual(2, CurGameState.GetMaxBet(GameDefinition));

                        Assert.AreEqual(false, CurGameState.Players[0].CanActInCurrentRound);
                        Assert.AreEqual(true, CurGameState.Players[0].CanActInGame);
                        Assert.AreEqual(false, CurGameState.Players[0].IsFolded);
                        Assert.AreEqual(false, CurGameState.Players[0].IsAllIn);
                        Assert.AreEqual(7, CurGameState.Players[0].InPot);
                        Assert.AreEqual(4, CurGameState.Players[0].Bet);
                        Assert.AreEqual(-7, CurGameState.Players[0].Stack);
                        Assert.AreEqual(12, CurGameState.Players[0].Hand.Length);
                        Assert.IsTrue(CurGameState.Players[0].Hand.StartsWith("? ?"));

                        Assert.AreEqual(true, CurGameState.Players[1].CanActInCurrentRound);
                        Assert.AreEqual(true, CurGameState.Players[1].CanActInGame);
                        Assert.AreEqual(false, CurGameState.Players[1].IsFolded);
                        Assert.AreEqual(false, CurGameState.Players[1].IsAllIn);
                        Assert.AreEqual(5, CurGameState.Players[1].InPot);
                        Assert.AreEqual(2, CurGameState.Players[1].Bet);
                        Assert.AreEqual(-5, CurGameState.Players[1].Stack);
                        Assert.AreEqual(14, CurGameState.Players[1].Hand.Length);

                        return(PokerAction.c(0));
                    }
                }
                Assert.Fail();
                return(null);
            }