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.art I Maze Rubric
Part I Maze Rubric
Criteria Ratings Pts
This criterion is linked to a Learning OutcomeCreate a Square Object that has a constructor that takes the X Y pixel coordinates of the upper left corner, and has a virtual draw method that will show the square.
pts
This criterion is linked to a Learning OutcomeCreate a MazeSquare object derives from the square object that implements the following methods:
pts
This criterion is linked to a Learning OutcomeremoveSide Side s causes the corresponding side in the square to disappear painted black
pts
This criterion is linked to a Learning Outcomedraw draws the square at the given coordinates showing the remaining sides and other visible markings to indicate if the square is the currently actively dequeued square or has been visited.
pts
This criterion is linked to a Learning OutcomehasTop hasBottom hasLeft hasRight each method returns bool indicating if square has corresponding side
pts
This criterion is linked to a Learning OutcomemarkVisited marks the square as being visited isVisited and causes the square to be redrawn showing that it has been visited.
pts
This criterion is linked to a Learning OutcomeCreate a Maze object which contains D array of MazeSquare pointers. The dimensions of the D arrays must be given as parameters to the Maze object constuctor.
pts
This criterion is linked to a Learning OutcomeWhen initially drawing the grid of squares, the Maze constructor must cast the MazeSquare pointer to a Square object pointer and invoke the Square::draw method, and not invoke the MazeSquare::draw method
pts
This criterion is linked to a Learning OutcomeUse a STL object that can store Square pointers and randomly insert Square from the maze object.
pts
This criterion is linked to a Learning OutcomeWrite a loop that removes all the Square in the For each square in the queue, randomly find an unvisited neighboring square, remove the wall between the dequeued square and the chosen neighbor square
pts
This criterion is linked to a Learning OutcomeGood code quality, submitted on time, and all the vcxproj CMakeList & cpp files to build the project.
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