Beispiel #1
0
 public AStarSearch(IInformedProblem <T> problem, IHeustisticFunction <T> heuristic)
 {
     Problem       = problem;
     Heuristic     = heuristic;
     PriorityQueue = new PriorityQueue <HeuristicNode <T> >();
     OpenList      = new HashSet <T>();
     ClosedList    = new HashSet <T>();
 }
        public HeuristicNode <T> ChildNode(IInformedProblem <T> problem, IAction <T> action, IHeustisticFunction <T> heurisctic)
        {
            T   state         = problem.Transition(this.State, action);
            int stepCost      = problem.StepCost(this.State, action);
            int totalCost     = this.PathCost + stepCost;
            int heuristicCost = totalCost + heurisctic.Calculate(problem, state);

            return(new HeuristicNode <T>(state, action, this, totalCost, heuristicCost));
        }
Beispiel #3
0
        public int Calculate(IInformedProblem <T> problem, T state)
        {
            T goalState = problem.GoalState;

            return(state.ManhattanDistance(goalState));
        }