예제 #1
0
        private void UpdateHand(StrategicState next, int position, int card)
        {
            int handSize = next.Hands[position].Length;

            Array.Resize(ref next.Hands[position], handSize + 1);
            next.Hands[position][handSize] = card;
        }
예제 #2
0
        private StrategicState CreateNextState()
        {
            StrategicState next = new StrategicState(InPot.Length);

            for (int p = 0; p < InPot.Length; ++p)
            {
                next.InPot[p] = InPot[p];
                next.Hands[p] = Hands[p].ShallowCopy();
            }
            next.Pot           = Pot;
            next.ActivePlayers = ActivePlayers;
            return(next);
        }
예제 #3
0
        /// <summary>
        /// Update by a strategy tree node. Cannot update active players.
        /// </summary>
        public StrategicState GetNextState(IStrategyTreeNode n)
        {
            StrategicState next = CreateNextState();

            if (!n.IsDealerAction)
            {
                UpdateAmount(next, n.Position, n.Amount);
            }
            else
            {
                UpdateHand(next, n.Position, n.Card);
            }
            return(next);
        }
예제 #4
0
        /// <summary>
        /// Update by a strategic action.
        /// </summary>
        public StrategicState GetNextState(IStrategicAction action)
        {
            StrategicState next = CreateNextState();
            IPlayerAction  pa   = action as IPlayerAction;

            if (pa != null)
            {
                UpdateAmount(next, pa.Position, pa.Amount);
                IActionTreeNode an = pa as IActionTreeNode;
                if (an != null)
                {
                    next.ActivePlayers = an.ActivePlayers;
                }
            }
            else
            {
                IDealerAction da = action as IDealerAction;
                UpdateHand(next, da.Position, da.Card);
            }

            return(next);
        }
예제 #5
0
 private void UpdateAmount(StrategicState next, int position, double amount)
 {
     next.Pot             += amount;
     next.InPot[position] += amount;
 }