public static Node <TState, TAction> ChildNode <TState, TAction>( ISearchProblem <TState, TAction> problem, Node <TState, TAction> parent, TAction action) { return(new Node <TState, TAction>( problem.Result(parent.State, action), parent, action, parent.PathCost + problem.StepCost(parent.State, action))); }
private Node <TState, TAction> ChildNode(ISearchProblem <TState, TAction> problem, TAction action) { var nextState = problem.Result(State, action); return(new Node <TState, TAction>( nextState, action, this, problem.PathCost( PathCost, State, action, nextState ) )); }
public static IEnumerable <Node <S, A> > GetSuccessors <S, A>(Node <S, A> node, ISearchProblem <S, A> problem) where A : class { var successors = new List <Node <S, A> >(); foreach (var action in problem.Actions(node.State)) { S successorState = problem.Result(node.State, action); double stepCost = problem.StepCost(node.State, action, successorState); successors.Add(CreateNode(successorState, node, action, stepCost)); } return(successors); }