Ejemplo n.º 1
0
 private static void CorrectStartingPosition(MazeController mazeController,
                                             Tuple <bool, int, int> userSelectedStartingPoint)
 {
     if (userSelectedStartingPoint.Item1)
     {
         if (!mazeController.IsWall(userSelectedStartingPoint.Item2, userSelectedStartingPoint.Item3))
         {
             mazeController.ChangeMazeStartingPoint(userSelectedStartingPoint.Item2,
                                                    userSelectedStartingPoint.Item3);
         }
         else
         {
             Console.WriteLine("Selected starting position is WALL");
             Console.WriteLine("Continuing with text file maze\n");
         }
     }
 }
Ejemplo n.º 2
0
        private static void Main(string[] args)
        {
            var fileReader = new FileReader();

            if (fileReader.DataInitialized)
            {
                var userSelectedStartingPoint = AskForStartingPosition(fileReader.MazeHeight, fileReader.MazeWidth);

                var mazeController = new MazeController(fileReader.MazeHeight, fileReader.MazeWidth, fileReader.Maze);

                if (mazeController.MazeInitialized)
                {
                    CorrectStartingPosition(mazeController, userSelectedStartingPoint);

                    PrintMaze(mazeController.MazeHeight, mazeController.MazeWidth, mazeController.MazeLayout);

                    mazeController.SolveMaze();

                    if (mazeController.NoExit)
                    {
                        Console.WriteLine("Maze has no exit.");
                    }
                    else
                    {
                        PrintMoves(mazeController.SolvedMazeHistory);

                        PrintMaze(mazeController.MazeHeight, mazeController.MazeWidth, mazeController.MazeLayout,
                                  mazeController.SolvedMazeHistory);
                    }
                }
                else
                {
                    Console.WriteLine("Error creating maze");
                }
            }
            else
            {
                Console.WriteLine("Error reading \"RPAMaze.txt\" file from Desktop");
            }

            Console.ReadLine();
        }