Beispiel #1
0
        Node AddMove(string move, int row, int col)
        {
            var node = current.ChildExists(move);

            if (node != null)
            {
                current = node;
            }
            else
            {
                node    = current.AddChild(move, row, col);
                current = node;
            }

            return(node);
        }
Beispiel #2
0
        //----------------------------------------------------------------
        //Expands the Node so it will have children
        private void Expand(Node parent)
        {
            simulationState.ImportState(parent.State);

            if (parent.Action.Move != null) //If it's not the root node
            {
                simulationState.Change(parent.Action);
            }
            if (simulationState.isOver)
            {
                return;
            }

            //Gets the possible Actions
            IAction[] possActions = simulationState.PossMoves(NextPlayer(parent.Action.player));
            foreach (var item in possActions)
            {
                State tempState = new State();
                tempState.ImportState(simulationState);
                Node Child = new Node(parent, item, tempState);
                parent.AddChild(Child);
            }
        }