Question
The perfect maze is represented as a two-dimensional matrix as defined below. public class Maze { private char[,] M; private int size; public Maze(int n)
The perfect maze is represented as a two-dimensional matrix as defined below.
public class Maze { private char[,] M; private int size; public Maze(int n) { ... } (2) private void Initialize( ) { ... } // Called by the constructor (6) private void Create( ) { ... } // Called by the constructor (2) private void DepthFirstSearch(int i, int j, bool[,] visited) { ... } // Called by Create (12) public void Print( ) { ... } }
1) Implement each of the above methods, keeping in mind the following requirements. a. The method Initialize populates matrix M with blank characters and walls (e.g. '-' and '|'). The size of the matrix may be greater than n to accommodate the "walls" and any other boundaries. (show screenshot)
b. The method Create invokes DepthFirstSearch to build the perfect maze. As the depth-first search is performed, if two or more adjacent positions are unvisited, then one direction is randomly chosen. (show screenshot)
2) Implement a main program to test the methods of Maze for n=0, 1, 2, 5, 10, 20. (show screenshot)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started