Exemplo n.º 1
0
        /*!
         * Return the node containing the new state obtained
         * by applying the given action to this node's
         * current state, with this node as the parent
         *
         * @method ChildNode
         * @param {Problem.AbstractProblem<State, Action, Cost>} - problem. A standard problem
         * @param {Action} action initiating a transition fro one state to the next
         * @return {SearchTreeNode.Node<State, Action, Cost>} node - node produced from the current node by Action action
         */
        public Node <State, Action, Cost> ChildNode(Problem.AbstractProblem <State, Action, Cost> problem, Action action)
        {
            State nextState = problem.Result(this.state, action);
            Node <State, Action, Cost> cnode = new Node <State, Action, Cost>(nextState, this, action, problem.PathCost(this.pathCost, this.state, action, nextState));

            return(cnode);
        }
Exemplo n.º 2
0
        /*! nodes reachable from this node */
        public List <Node <State, Action, Cost> > Expand(Problem.AbstractProblem <State, Action, Cost> problem)
        {
            List <Node <State, Action, Cost> > nodes = new List <Node <State, Action, Cost> >();

            problem.Actions(this.state).ForEach(
                delegate(Action action)
            {
                nodes.Add(this.ChildNode(problem, action));
            }
                );
            return(nodes);
        }