Exemple #1
0
 /// <summary>
 /// Prints the solution
 /// </summary>
 /// <param name="ASolution">The list that holds the solution</param>
 static public void PrintSolution(List <AStarNode2D> ASolution)
 {
     for (int j = 0; j < 10; j++)
     {
         for (int i = 0; i < 10; i++)
         {
             bool solution = false;
             foreach (AStarNode2D n in ASolution)
             {
                 AStarNode2D tmp = new AStarNode2D(null, null, 0, i, j);
                 solution = n.IsSameState(tmp);
                 if (solution)
                 {
                     break;
                 }
             }
             if (solution)
             {
                 Console.Write("o ");
             }
             else
             if (MainClass.GetMap(i, j) == -1)
             {
                 Console.Write("# ");
             }
             else
             {
                 Console.Write(". ");
             }
         }
         Console.WriteLine("");
     }
 }
Exemple #2
0
        static void Main1(string[] args)
        {
            Console.WriteLine("Starting...");

            var astar = new AStar <AStarNode2D>();

            AStarNode2D GoalNode  = new AStarNode2D(null, null, 0, 9, 9);
            AStarNode2D StartNode = new AStarNode2D(null, GoalNode, 0, 0, 0);

            StartNode.GoalNode = GoalNode;
            var sw = Stopwatch.StartNew();

            astar.FindPath(StartNode);
            sw.Stop();
            PrintSolution(astar.Solution);

            Console.WriteLine(sw.ElapsedMilliseconds);

            Console.ReadLine();
        }