コード例 #1
0
ファイル: Program.cs プロジェクト: DCHatten/Recursion-Example
        /// <summary>
        /// Method to print a menu for the user to choose 1 of the built in mazes to solve, showing the steps used.
        /// Is also called recursively to keep the program open until the user chooses to exit.
        /// </summary>
        /// <param name="maze1">The Default maze</param>
        /// <param name="maze2">The transposed maze</param>
        /// <param name="X_START">The hard coded initial x coordinate</param>
        /// <param name="Y_START">The hard coded initial y coordinate</param>
        /// <param name="mazeSolver">The instance of the MazeSolver method from the MazeSolver class</param>
        static void Menu(char[,] maze1, char[,] maze2, int X_START, int Y_START, MazeSolver mazeSolver)
        {
            Console.WriteLine("Choose which maze you would like to solve:");
            Console.WriteLine("1. Standard Maze");
            Console.WriteLine("2. Transposed Maze");
            Console.WriteLine("3. Exit");
            string userInput = Console.ReadLine();

            switch (userInput)
            {
            case "1":
                //Tell the instance to solve the first maze with the passed maze, and start coordinates.
                mazeSolver.SolveMaze(maze1, X_START, Y_START);
                break;

            case "2":
                //Solve the transposed maze.
                mazeSolver.SolveMaze(maze2, X_START, Y_START);
                break;

            case "3":
                //Call the Pause method to display an exit prompt
                Pause();
                break;

            default:
                Console.WriteLine("Error, you must select from the available options");
                Console.Clear();
                Menu(maze1, maze2, X_START, Y_START, mazeSolver);
                break;
            }
            Menu(maze1, maze2, X_START, Y_START, mazeSolver);
        }
コード例 #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 = 
            { { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
            { '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },
            { '#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },
            { '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '#' },
            { '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '.' },
            { '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' } };

            // >This maze has no exit. Used to test backtracking.
            //{ { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
            //{ '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },
            //{ '#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },
            //{ '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },
            //{ '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '#' },
            //{ '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            //{ '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            //{ '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            //{ '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },
            //{ '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },
            //{ '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },
            //{ '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' } };

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

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

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

            //Solve the transposed _maze.
            mazeSolver.SolveMaze(maze2, X_START, Y_START);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Audre/cis237assignment2
        /// <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);

        }
コード例 #4
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)
        {
            //***********************************
            //Instanciating class Used
            //***********************************
            UserInterface ui = new UserInterface();

            /// <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 =
            { { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
              { '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },
              { '#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },
              { '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },
              { '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '.' },
              { '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
              { '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
              { '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
              { '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },
              { '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },
              { '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },
              { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' } };

            /// <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);

            /// <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 for user to look over the maze
            ui.ExitFound();

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

            //Pause for the user to look over the maze
            ui.ExitFound();
        }
コード例 #5
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 =
            { { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
              { '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },
              { '#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },
              { '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },
              { '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '.' },
              { '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
              { '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
              { '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
              { '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },
              { '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },
              { '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },
              { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' } };

            /// <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);

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

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


            //Print the final results for both maze1 and maze2
            PrintMaze(maze1);
            Console.WriteLine("Results For Maze 1" + Environment.NewLine);
            PrintMaze(maze2);
            Console.WriteLine("Results For Maze 2" + Environment.NewLine);
            Console.ReadLine();
        }
コード例 #6
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 =
            { { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
              { '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },
              { '#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },
              { '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },
              { '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '.' },
              { '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
              { '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
              { '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
              { '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },
              { '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },
              { '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },
              { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' } };

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

            //Create the second maze by transposing the first maze
            char[,] maze2 = new char[maze1.GetLength(1), maze1.GetLength(0)];

            transposeMaze(maze1, maze2);

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

            Console.WriteLine("Hit enter to solve the second maze");
            Console.ReadLine();

            //Solve the transposed maze.
            mazeSolver.SolveMaze(maze2, X_START, Y_START);
        }
コード例 #7
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 =
            { { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
              { '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },
              { '#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },
              { '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },
              { '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '.' },
              { '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
              { '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
              { '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
              { '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },
              { '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },
              { '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },
              { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' } };

            MazeSolver mazeSolver = new MazeSolver();

            showMaze(maze1); //Show base maze
            char[,] maze2 = transposeMaze(maze1);

            char[,] maze1Solved = mazeSolver.SolveMaze(maze1, Y_START, X_START); //pass maze1 into the solver object, it returns the solved maze we save as maze1Solved
            showMaze(maze1Solved);                                               //Show the solved maze1Solved

            //Create the second maze by transposing the first maze, and show it

            showMaze(maze2); //Show the (should be) blank maze2

            //Solve the transposed maze.
            char[,] maze2Solved = (mazeSolver.SolveMaze(maze2, Y_START, X_START));
            showMaze(maze2Solved);
        }
コード例 #8
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 =
            { { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
              { '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },
              { '#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },
              { '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },
              { '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '.' },
              { '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
              { '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
              { '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
              { '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },
              { '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },
              { '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },
              { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' } };

            MazeSolver mazeSolver = new MazeSolver();

            showMaze(maze1); //Show base maze
            char[,] maze2 = transposeMaze(maze1);

            char[,] maze1Solved = mazeSolver.SolveMaze(maze1, Y_START, X_START); //pass maze1 into the solver object, it returns the solved maze we save as maze1Solved
            showMaze(maze1Solved); //Show the solved maze1Solved

            //Create the second maze by transposing the first maze, and show it

            showMaze(maze2); //Show the (should be) blank maze2

            //Solve the transposed maze.
            char[,] maze2Solved = (mazeSolver.SolveMaze(maze2, Y_START, X_START));
            showMaze(maze2Solved);
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: grantfar/cis237assignment2
        /// <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.
            /// </summary>
            char[,] maze1 =
            { { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
            { '#', '·', '·', '·', '#', '·', '·', '·', '·', '·', '·', '#' },
            { '#', '·', '#', '·', '#', '·', '#', '#', '#', '#', '·', '#' },
            { '#', '#', '#', '·', '#', '·', '·', '·', '·', '#', '·', '#' },
            { '#', '·', '·', '·', '·', '#', '#', '#', '·', '#', '·', '·' },
            { '#', '#', '#', '#', '·', '#', '·', '#', '·', '#', '·', '#' },
            { '#', '·', '·', '#', '·', '#', '·', '#', '·', '#', '·', '#' },
            { '#', '#', '·', '#', '·', '#', '·', '#', '·', '#', '·', '#' },
            { '#', '·', '·', '·', '·', '·', '·', '·', '·', '#', '·', '#' },
            { '#', '#', '#', '#', '#', '#', '·', '#', '#', '#', '·', '#' },
            { '#', '·', '·', '·', '·', '·', '·', '#', '·', '·', '·', '#' },
            { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' } };

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

            /// <summary>
            /// Tell the instance to solve the first maze with the passed maze, and start coordinates.
            /// Cloned to prevent maze 2 from being pre-solved
            /// </summary>
            mazeSolver.SolveMaze((char[,])maze1.Clone(), X_START, Y_START);

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

            //Solve the transposed maze.
            mazeSolver.SolveMaze((char[,])maze2.Clone(), X_START, Y_START);
        }
コード例 #10
0
        static void Main(string[] args)
        {
            Console.BufferHeight = 5000;

            /// <summary>
            /// Starting Coordinates.
            /// </summary>
            const int X_START = 1;
            const int Y_START = 1;

            char[,] maze1 = 
          { { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
            { '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },
            { '#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },
            { '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '#' },
            { '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '.' },
            { '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' } };

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

            MazeSolver mazeSolver = new MazeSolver();

            Console.WriteLine("First Maze");
            Console.WriteLine();
            // This calls the MazeSolver class to solve the first maze
            mazeSolver.SolveMaze(maze1, X_START, Y_START);

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Second Maze");
            Console.WriteLine();
            // This calls the MazeSolver class to solve the transposed maze
            mazeSolver.SolveMaze(maze2, X_START, Y_START);
        }
コード例 #11
0
        // This is the main entry point for the program.
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            /// Starting Coordinates.
            const int X_START = 1;
            const int Y_START = 1;

            /// The first maze that needs to be solved.
            char[,] maze1 =
            {
            { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
            { '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },
            { '#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },
            { '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '.' },
            { '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' }
            };

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

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

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

            /// Give the user a chance to see the first finished maze before continuing to the transposition
            Console.WriteLine("Press ENTER to transpose this maze.");
            Console.ReadLine();

            /// Solve the transposed maze.
            mazeSolver.SolveMaze(maze2, X_START, Y_START);
        }
コード例 #12
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 =
            { { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
            { '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },
            { '#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },
            { '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', 'F' },
            { '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' } };

            char[,] copyOfMaze1 = (char[,])maze1.Clone(); //A clone of maze1 so everything doesn't break when we try to transpose!

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

            /// <summary>
            /// Tell the instance to solve the first maze with the passed maze, and start coordinates.
            /// </summary>

            Console.WriteLine("Original Maze:");
            mazeSolver.SolveMaze(maze1, X_START, Y_START);

            Console.WriteLine("Transposed Maze:");
            //Create the second maze by transposing the first maze
            char[,] maze2 = transposeMaze(copyOfMaze1);

            //Solve the transposed maze.
            mazeSolver.SolveMaze(maze2, X_START, Y_START);
        }
コード例 #13
0
        static void Main(string[] args)
        {
            // Ask user if they want the drawn effect.
            MazeSolver.applyDrawnEffect = !printNormally();

            // Starting Coords
            const int X_START = 1;
            const int Y_START = 1;

            // Create new Maze Solver
            MazeSolver mazeSolver = new MazeSolver();

            // Assign new maze
            char[,] maze1 = getNewMaze();

            // Tell maze solver to solve the given maze, then print it.
            mazeSolver.SolveMaze(maze1, X_START, Y_START);
            mazeSolver.PrintMaze();
            Console.WriteLine("Maze solved! (\"O\" indicates the successful path.) Press any key to solve the transposed version.");
            Console.ReadKey(true);

            // Create new maze solver
            mazeSolver = new MazeSolver();

            // Reset the maze.
            maze1 = getNewMaze();

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

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

            // Print the maze
            mazeSolver.PrintMaze();

            Console.WriteLine("Maze solved! (\"O\" indicates the successful path.) Press any key to continue.");
            Console.ReadKey(true);
        }
コード例 #14
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_COORD = 1;
            const int Y_COORD = 1;

            //starting UI
            Console.WriteLine("Project #2 ");
            Console.WriteLine("Press Enter to begin");
            Console.WriteLine("________________________");
            Console.ReadLine();

            ///<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);


            //maze 1
            Console.WriteLine("===============================================");
            Console.WriteLine("Maze #1");
            Console.WriteLine("===============================================");

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

            //maze 2
            Console.WriteLine();
            Console.WriteLine("===============================================");
            Console.WriteLine("Maze #2");
            Console.WriteLine("===============================================");

            //Solve the transposed maze.
            mazeSolver.SolveMaze(maze2, X_COORD, Y_COORD);

            //to keep program from closing
            Console.ReadLine();
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: jsziede/cis237assignment2
        /// <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 = 
            { { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
            { '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },
            { '#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },
            { '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '#' },
            { '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '.' },
            { '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' } };

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

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

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

            int choice = ui.MazePrompt();
            while (choice != 5)
            {
                switch (choice.ToString())
                {
                    case "1":
                        ui.PrintMaze(maze1);
                        choice = ui.MazePrompt();
                        break;
                    case "2":
                        /// <summary>
                        /// Tell the instance to solve the first maze with the passed maze, and start coordinates.
                        /// </summary>
                        mazeSolver.SolveMaze(maze1, X_START, Y_START);
                        choice = 5;
                        break;
                    case "3":
                        maze2 = transposeMaze(maze1);
                        ui.PrintMaze(maze2);
                        choice = ui.MazePrompt();
                        break;
                    case "4":
                        //Solve the transposed maze.
                        mazeSolver.SolveMaze(maze2, X_START, Y_START);
                        choice = 5;
                        break;
                    case "5":
                        break;
                    default:
                        Console.WriteLine("Error. Please select a valid number.");
                        choice = ui.MazePrompt();
                        break;
                }
            }
        }
コード例 #16
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();
        }
コード例 #17
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();
        }
コード例 #18
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)
        {
            int windowheight = 60;
            int windowwidth = 160;
            Console.BufferHeight = 100;
            Console.BufferWidth = 100;
            Console.SetWindowSize(windowwidth, windowheight);

            /// <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 =
            {
            { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
            { '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },
            { '#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },
            { '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', 'E' },
            { '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' }
            };

            //made another maze to avoid transposed mazed already being solved
            char[,] maze1orig =
            {
            { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' },
            { '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#' },
            { '#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#' },
            { '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', 'E' },
            { '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#' },
            { '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#' },
            { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' }
            };

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

            mazeSolver.Print(maze1);
            Console.WriteLine("----------PRESS ANY KEY TO SOLVE MAZE----------");
            Console.ReadKey();

            /// <summary>
            /// Tell the instance to solve the first maze with the passed maze, and start coordinates.
            /// </summary>
            ///

            mazeSolver.SolveMaze(maze1, X_START, Y_START);
            Console.WriteLine("----------------- MAZE SOLVED------------------\n");
            Console.WriteLine("--------PRESS ANY KEY TO TRANSPOSE MAZE--------\n");
            Console.ReadKey();

            //Create the second maze by transposing the first maze
            char[,] maze2 = transposeMaze(maze1orig);
            mazeSolver.Print(maze2);

            Console.WriteLine("----PRESS ANY KEY TO SOLVE TRANSPOSED MAZE-----");

            Console.ReadKey();

            //Solve the transposed maze.
            mazeSolver.SolveMaze(maze2, X_START, Y_START);
            Console.WriteLine("-------------PRESS ANY KEY TO EXIT-------------");
            Console.ReadKey();
            Environment.Exit(0);
        }