Programming Homework Help
Square Mazes of Arbitrary Size C++ Program
Requirements for practice are attached.
Algorithm: Basically the strategy for generating a maze in this assignment requires depth-first-search. Using a stack and a way to keep track of where it visited in the past, the algorithm will produce dynamic mazes
- Begin by marking all rooms in the graph as ‘unvisited’ (this may be placing them in a set or by not having them in a set based on how your mind works).
- Push the starting node into a stack of work to do (the starting node is the lower-left of the grid).
- While the stack of work is not empty:
-
- Pop the top of the stack as the current node.
- If the current node has been visited, ignore it and continue.
- Else load all of the current node’s unvisited neighbors into the stack of work to do.
- Pick a random currently-unvisited neighbor and break down the wall, or build a door, between the two rooms. This will vary based on how you choose to represent your maze, so know how you are doing it before you proceed.
- Mark the current node visited.
- When the stack is empty, the algorithm is finished, and the maze should now appear.