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

  1. 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).
  2. Push the starting node into a stack of work to do (the starting node is the lower-left of the grid).
  3. While the stack of work is not empty:
    1. Pop the top of the stack as the current node.
    2. If the current node has been visited, ignore it and continue.
    3. Else load all of the current node’s unvisited neighbors into the stack of work to do.
    4. 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.
    5. Mark the current node visited.
    6. When the stack is empty, the algorithm is finished, and the maze should now appear.