Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            IGrid grid = new DistanceGrid(5, 5);
            new BinaryTree().Run(ref grid);

            var start = grid[0, 0];
            var distances = start.Distances;

            var distanceGrid = (DistanceGrid)grid; //casting to a distance grid to take advantage of the "distances" property
            distanceGrid.CellDistances = distances;
            Console.WriteLine(grid.ToString(false));

            Console.WriteLine("Path from NW corner to SW corner:");
            distanceGrid.CellDistances = distances.PathToGoal(grid[grid.Rows-1, 0]);
            Console.WriteLine(grid.ToString(false));

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            IGrid grid = new DistanceGrid(5, 5);

            new BinaryTree().Run(ref grid);

            var start     = grid[0, 0];
            var distances = start.Distances;

            var distanceGrid = (DistanceGrid)grid; //casting to a distance grid to take advantage of the "distances" property

            distanceGrid.CellDistances = distances;
            Console.WriteLine(grid.ToString(false));

            Console.WriteLine("Path from NW corner to SW corner:");
            distanceGrid.CellDistances = distances.PathToGoal(grid[grid.Rows - 1, 0]);
            Console.WriteLine(grid.ToString(false));

            Console.ReadKey();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            IGrid grid = new DistanceGrid(5, 5);

            new BinaryTree().Run(ref grid);

            var       start     = grid[0, 0];
            Distances distances = start.Distances;

            var newStart = distances.Max.Cell;
            var distance = distances.Max.Distance;

            var       newDistances = newStart.Distances;
            MaxResult result       = newDistances.Max;

            DistanceGrid distanceGrid = (DistanceGrid)grid;

            distanceGrid.CellDistances = newDistances.PathToGoal(result.Cell);

            Console.WriteLine(distanceGrid.ToString(false));

            Console.ReadKey();
        }