Ejemplo n.º 1
0
        private static void SimpleExample()
        {
            Console.Clear();
              Console.Out.WriteLine("Simple example - empty map.");
              WriteLegend();

              var map = new MapSample();
              Console.Out.Write(map.ToString());
              var pathFinder = new AStarPathfinder(map, 1000, false, new ManhattanDistance());
              var from = new PointInt32(0, 0);
              var to = new PointInt32(map.Width - 1, map.Height - 1);
              Console.Out.WriteLine("Path from {0} to {1}.", from, to);
              var path = pathFinder.FindPath(null, from, to);
              Console.Out.Write(map.ToString(path, true));
              Console.Out.WriteLine("Press any key to continue ...");
              Console.In.ReadLine();
        }
Ejemplo n.º 2
0
        private static void BlocksExample()
        {
            Console.Clear();
              Console.Out.WriteLine("Example with blocks in map.");
              WriteLegend();

              var map = new MapSample();
              for (var y = map.Height / 2; y < map.Height; y++) {
            map[map.Width / 3, y].IsBlocker = true;
            map[2 * map.Width / 3, y].IsBlocker = true;
              }
              Console.Out.Write(map.ToString());
              var pathFinder = new AStarPathfinder(map, 1000, false, new ManhattanDistance());
              var from = new PointInt32(0, 0);
              var to = new PointInt32(map.Width - 1, map.Height - 1);
              Console.Out.WriteLine("Path from {0} to {1}.", from, to);
              var path = pathFinder.FindPath(null, from, to);
              Console.Out.Write(map.ToString(path, true));
              Console.Out.WriteLine("Press any key to continue ...");
              Console.In.ReadLine();
        }