Пример #1
0
        public void AStarWithDiagonalDistance()
        {
            DiagonalDistanceHeuristic <Vector> heuristic = new DiagonalDistanceHeuristic <Vector>();
            AStarSearch <Vector>  aStarSearch            = new AStarSearch <Vector>(_problem, heuristic);
            SearchResult <Vector> searchResult           = aStarSearch.Search();
            List <Vector>         states = searchResult.States.ToList();

            Console.WriteLine("AStar with diagonal");
            Console.WriteLine($"OpenList:{aStarSearch.OpenList.Count}");
            Console.WriteLine($"ClosedList:{aStarSearch.ClosedList.Count}");
            foreach (var state in states)
            {
                Console.WriteLine(state);
            }
        }
Пример #2
0
 private Heuristic SelectProperHeuristic()
 {
     if (MustUseHeuristic())
     {
         if (checkBoxDiagonalMove.Checked)
         {
             return(DiagonalDistanceHeuristic.GetDiagonalDistanceHeuristic());
         }
         else
         {
             return(ManhattanDistanceHeuristic.GetManhattanDistanceHeuristic());
         }
     }
     else
     {
         return(NullHeuristic.GetNullHeuristic());
     }
 }