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:
Unfortunately for us, 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-src.tar.gz (source code)
It’s a command line program. From the terminal, the usage is like this:
java -jar MazeGenerator.jar [width] [height] [formatting]
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’).