Answered step by step
Verified Expert Solution
Link Copied!

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 2 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:
num_of_iterations = num_rows * num_columns *2
repeat (num_iterations):
randomly pick a square in the 2d 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 neighborSqurePtr->markVisited()
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions

Question

What is American Polity and Governance ?

Answered: 1 week ago

Question

What is Constitution, Political System and Public Policy? In India

Answered: 1 week ago

Question

What is Environment and Ecology? Explain with examples

Answered: 1 week ago