↑ new maze ↓ maze solution using DFS |
The display above shows the result of these steps:
The maze generator starts with a maze with all walls "up" and follows the process: pick a wall at random; if the cells on either side are already connected, leave the wall standing, otherwise knock it down; stop the first time when start and goal are connected, and report the number of components; then continue until all cells are pairwise connected and verify that the maze has only one component. A Union-Find data structure is used to keep track of connectivity. The KISS pseudo-random number generator, invented by George Marsaglia, late Professor of Statistics at FSU, is used for random choices.
The maze solver operates by converting the maze to its dual graph (which is incidentally a subgraph of the square lattice) and applying depth-first search on that graph.
This demo is part of a project for my course COP4531 at FSU.
========= Diagnostic output from mazegen.sh =========Ranmaze: numrows = 60, numcols = 150, numcells = 9000, start = 4500, goal = 4649, trace = 0 components after 0 passes: 9000 components after 1 pass: 792 components after all passes: 1 Solution found has 426 cells Maze and solution written to file "./_TEMPMAZE.1.dfs" Printmaze: Writing encapsulated postscript ./mazegen.sh: line 28: pstopnm: command not found ./mazegen.sh: line 28: pnmtopng: command not found ./mazegen.sh: line 36: pstopnm: command not found ./mazegen.sh: line 36: pnmtopng: command not found maze graphic in maze.png solved maze graphic in maze.dfs.png