Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is the first half of the maze project where you will create most of the required objects for the Maze project. To receive full
This is the first half of the maze project where you will create most of the required objects for the Maze project.
To receive full credit for this part, you must create a Square object that can show a square on a grid, a MazeSquare object that is derived from the Square object, and a Maze object that contains a dimensional array of MazeSquare object pointers. Each object has a set of requirements as described in the rubric below.
Note the MazeSquare object must inherit from the square object we developed during this weeks warmup, but with several additional methods listed in the criteria below, and must use polymorphism to extend the draw functionality. To demonstrate polymorphism, while drawing the initial grid of squares, the Maze object must use Square object pointers, not MazeSquare pointers to invoke the Square::Draw method, not the MazeSquare::Draw method.
To validate the code is working correctly, randomly queue a bunch of MazeSquare objects pointers from the maze grid using a STL object, and deque them. As each MazeSquare pointer is dequeued, randomly pick an unvisited neighbor and remove the wall between the dequeued square and it's chosen neighbor. Visibly mark the neighbor as visited as shown in the video below.
Here is some pseudo code you should follow for part I:
numofiterations numrows numcolumns
repeat numiterations:
randomly pick a square in the d maze array
add the pointer to the randomly chosen square to the queue
repeat until the queue is empty:
sqPtr dequeue remove the next square pointer from the queue.
look at all the neighboring squares to sqPtr neighbors squares must share a side, diagonal squares are not neighbors
neighborSqurePtr randomly choose a neighboring square that isn't marked visited.
Make sure you don't go beyond the maze boundaries.
If all the neighbors have been visited, continue to the next iteration
invoke neighborSqurePtrmarkVisited
remove the wall between the sqPtr and neighborSquarePointer
If this is implemented correctly, you should have a partial unsolvable maze without any paths that create a loop.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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