Ejemplo n.º 1
0
 private static void Redraw(
     Coordinate coord,
     Maze mazeObject,
     ConsoleMazeDrawer mazeDrawer,
     int newValue)
 {
     mazeObject.SetValueAt(coord, newValue);
     mazeDrawer.RedrawMaze(mazeObject);
 }
Ejemplo n.º 2
0
        static void Main()
        {
            var maze = new int[, ] {
                { 0, 0, 0, 0, 0, 0, 0 },
                { 1, 1, 0, 1, 0, 1, 1 },
                { 0, 1, 0, 1, 0, 0, 0 },
                { 1, 1, 1, 1, 1, 1, 0 },
                { 0, 1, 0, 0, 0, 0, 0 },
                { 1, 1, 0, 0, 1, 1, 0 },
                { 0, 2, 0, 0, 0, 1, 0 },
            };

            var mazeObject = new Maze(maze);
            var mazeDrawer = new ConsoleMazeDrawer();
            var algo       = new SearchThroughMaze(
                mazeObject,
                coord => Redraw(coord, mazeObject, mazeDrawer, 8),
                deadCord => Redraw(deadCord, mazeObject, mazeDrawer, 0)
                );
            var result = algo.Search();

            PrintResult(result);
        }