home *** CD-ROM | disk | FTP | other *** search
- This may aid your understanding of PMMAZE. Unfortunately, use
- of an explicit stack instead of recursion results in somewhat obscure
- code. Good luck!
-
- To create a maze, use walls to divide a pile of
- clay into rectangular rooms of equal size. Enter
- the some room and remove the clay from it. Randomly
- pick an adjacent room that still has clay in it. If
- no such room exists, return to the room emptied just
- before the current room was emptied and try again.
- If you find an adjacent room containing clay, knock
- down the wall separating you from it, enter it, and
- remove the clay from it. Keep doing this until you
- have returned to the first room to have been emptied
- and can find no adjacent room containing clay.
- Knock down the walls blocking the entrance and exit
- to the maze; the maze is complete!
-
- To solve a maze, start at the entrance (lower
- left-hand room). Use chalk to draw a line on the
- floor from the middle of the room to the outside of
- the maze. In a given room, find a direction out of
- the room that you have not yet taken and that does
- not follow your chalk line. If such a direction
- exists, extend the chalk line in that direction
- until you reach the middle of an adjacent room. If
- no such direction exists, follow the chalk line out
- of the room, erasing it until you reach the middle
- of an adjacent room. Since the maze generated by
- this program has exactly one solution that does not
- involve backtracking, you will eventually reach the
- exit (upper right-hand room).