public Node AddChild(Action action, StateList goal) { // The state is our nodes current state with the action applied // Cost goes up by one Node child = new Node(action, action.Simulate(state, goal), this, cost + 1.0f); children.Add(this); return(child); }
public void AddAction(Node previous, Action a) { // Calculate the world state after this action StateList nextState = a.Simulate(previous.state); // Calculate the total cost of the plan including this action float totalCost = previous.cost + a.cost; // Create the leaf node (which hooks up parent/child ref Node leaf = new Node(previous, a, nextState, totalCost); openLeaves.Add(leaf); }