コード例 #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>();
 }
コード例 #2
0
        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));
        }