I was thinking about how to make mazes, and ended up making a maze generator.
It’s based on ‘depth-first search’, a recursive algorithm to make a spanning tree. Example output below:
Java doesn’t particularly like deep recursion, so this generator will fizzle out with an error on really big mazes.
On the other hand, it can produce output as HTML:
You can download the maze generator here:
- MazeGenerator.jar
- MazeGenerator-src.tar.gz (source code)
It’s a command line program. From the terminal, the usage is:
|
|
Width/height will change the size of your maze. You can set the format to ‘html’, or type in a character for the filled-in blocks to be. (The default is u2588 ‘Solid block’).
Update August 2025: I’ve manually adjusted the HTML markup of the maze to appear correctly on this blog, and it no longer exactly matches the output of this program.