Beispiel #1
0
        /// <summary>
        /// This is the main entry point for the program.
        /// You are free to add anything else you would like to this program,
        /// however the maze solving part needs to occur in the MazeSolver class.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            /// <summary>
            /// Starting Coordinates.
            /// </summary>
            const int X_START = 1;
            const int Y_START = 1;
            const int ARRAY_SIZE = 12;

            /// <summary>
            /// Create a new instance of UserInterface.
            /// </summary>
            UserInterface ui = new UserInterface();

            ///<summary>
            /// The first maze that needs to be solved.
            /// Note: You may want to make a smaller version to test and debug with.
            /// You don't have to, but it might make your life easier.
            /// </summary>
            char[,] maze1 = 
            { { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
            { '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },
            { '#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },
            { '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '#' },
            { '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '.' },
            { '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' } };

            /// <summary>
            /// Create a new instance of a mazeSolver.
            /// </summary>
            MazeSolver mazeSolver = new MazeSolver();

            //Create the second maze by transposing the first maze
            char[,] maze2 = transposeMaze(maze1, ARRAY_SIZE);


            /// <summary>
            /// Tell the instance to solve the first maze with the passed maze, and start coordinates.
            /// </summary>
            mazeSolver.SolveMaze(maze1, X_START, Y_START);

            // Pause maze solving until user presses key.
            ui.StartNextMaze();

            //Solve the transposed maze.
            mazeSolver.SolveMaze(maze2, X_START, Y_START);

        }
Beispiel #2
0
        /// <summary>
        /// This is the main entry point for the program.
        /// You are free to add anything else you would like to this program,
        /// however the maze solving part needs to occur in the MazeSolver class.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            /// <summary>
            /// Starting Coordinates.
            /// </summary>
            const int X_START = 1;
            const int Y_START = 1;

            ///<summary>
            /// The first maze that needs to be solved.
            /// Note: You may want to make a smaller version to test and debug with.
            /// You don't have to, but it might make your life easier.
            /// </summary>
            char[,] maze1 = 
            { { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
            { '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },
            { '#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },
            { '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '#' },
            { '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '.' },
            { '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' } };

            
            //Create the second maze by transposing the first maze
            char[,] maze2 = transposeMaze(maze1);

            // Create a new instance of a mazeSolver.
            // Create a new instance of a ui.
            MazeSolver mazeSolver = new MazeSolver();
            UserInterface ui = new UserInterface();

            //Displays a message stating that this is the original unsolved maze.
            //Then displays the unsolved maze.
            UserInterface.OriginalMessage(maze1);
            
            
            // Tell the instance to solve the first maze with the passed maze, and start coordinates.
            //Starts the maze solving process by passing the original maze and the start coordinates
            //into the process.
            mazeSolver.SolveMaze(maze1, X_START, Y_START);

            //Displays a message stating that this is the solved original maze.
            //Then displays the solved maze.
            UserInterface.OriginalSolved(maze1);

            //Displays a message stating that this is the transposed unsolved maze.
            //Then displays the unsolved maze.
            UserInterface.TransposedMessage(maze2);

            //Solve the transposed maze.
            //Starts the maze solving process by passing the transposed maze and the start coordinates
            //into the process.
            mazeSolver.SolveMaze(maze2, X_START, Y_START);

            //Displays a message stating that this is the solved transposed maze.
            //Then displays the solved maze.
            UserInterface.TransposedSolved(maze2);

            //Pauses the program so the user can see the results.
            UserInterface.Pause();
        }
Beispiel #3
0
 /// <summary>
 /// Default Constuctor to setup a new maze solver.
 /// </summary>
 public MazeSolver()
 {
     ui = new UserInterface();
 }