Example #1
0
        /// <summary>
        /// Finds a node by an action path. Action path must not contain the root node and the blinds.
        /// This function is not speed-optimized.
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public Int64 FindNode(IStrategicAction[] path)
        {
            UFTreeChildrenIndex actionTreeIndex = new UFTreeChildrenIndex(this);
            Int64 curNode = PlayersCount;

            for (int a = 0; a < path.Length; ++a)
            {
                int childCount, chBegin;
                actionTreeIndex.GetChildrenBeginIdxAndCount(curNode, out chBegin, out childCount);
                for (int ch = 0; ch < childCount; ++ch)
                {
                    int chIdx = actionTreeIndex.GetChildIdx(chBegin + ch);
                    if (path[a].Position == Nodes[chIdx].Position)
                    {
                        if (Nodes[chIdx].IsDealerAction)
                        {
                            IDealerAction da = (IDealerAction)path[a];
                            if (da.Card == Nodes[chIdx].Card)
                            {
                                curNode = chIdx;
                                goto found;
                            }
                        }
                        else
                        {
                            IPlayerAction pa = (IPlayerAction)path[a];
                            if (pa.Amount == Nodes[chIdx].Amount)
                            {
                                curNode = chIdx;
                                goto found;
                            }
                        }
                    }
                }
                throw new ApplicationException(String.Format("Cannot find child at node {0} for action {1}",
                                                             curNode, path[a]));
found:
                ;
            }
            return(curNode);
        }
Example #2
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);
        }
Example #3
0
 public void perform_action_with(IDealerAction dealer_action)
 {
     dealer_action.perform_on(_playing_positions, _card_shoe, player);
     determine_table_status();
 }