// This constructor is never used but reserved for potential expansion. It copied the maze from another maze object. public Maze(Maze mazeToCopy) { _maze = new List<int[]>(); _mazeForDisplay = new List<int[]>(); _mouse = new Mouse(); _pathmemory = new List<Direction>(); for (int i = 0; i < mazeToCopy._maze.Count; i++) { int[] newRow = new int[mazeToCopy._maze[i].Length]; for (int j = 0; j < mazeToCopy._maze[i].Length; j++) { newRow[j] = mazeToCopy._maze[i][j]; } AddRow(newRow); } }
public void Execute() { Console.WriteLine("Maze Pathfinder."); Console.WriteLine("Please read ReadMe file of instruction."); string toRestart; do { Console.WriteLine("Enter the size of the maze:"); Console.WriteLine("Number of column is:"); int X = int.Parse(Console.ReadLine()); Console.WriteLine("Number of Row is:"); int Y = int.Parse(Console.ReadLine()); Maze maze = new Maze(); Console.WriteLine("Enter the maze row by row (in 1 or 0):"); for (int i = 0; i < Y; i++) { maze.AddRow(ConvertInputToRow(Console.ReadLine())); maze.DisplayMaze(); } Console.WriteLine("\nMouse starts finding the path."); foreach (var startPosition in _startPositions) { Console.WriteLine("\nStart at the {0}", startPosition); maze.BeginsFindPath(startPosition); } Console.ReadLine(); Console.WriteLine("Enter Y to retart, other keys to end."); toRestart = Console.ReadLine().ToUpper(); } while (toRestart == "Y"); }