Adrian Herbez Rotating Header Image

PLARL: maze generation


I’ve been continuing to work on my 3d-printable roguelike, and in order to do that, I needed a way to generate mazes. OpenSCAD is a bit annoying to work with for general programming, so I instead opted to write the maze generation in javascript and export data into the OpenSCAD file.

The maze generation is based on Jamis Buck’s excellent book, “Mazes for Programmers”. The numbers in the cells are there to indicate the contents of the rooms, which can either be monsters (which deal 1-6 points of damage) or food/potions (which heal 1-6 points of health). I kept it really simple on that front- just using numbers between 11-16 for damage and 21-26 for health regen, since all I needed was an easy way to pass the number and type into the OpenSCAD code.

The end result of the mazegen is a set of integer values representing the exists for each cell (each of the cardinal directions being represented by a unique power of 2 and added together), as well as for the contents. Those arrays are pasted into the OpenSCAD source to actually generate the level

To see the generation for yourself, head here: http://www.adrianherbez.net/plarl/mazegen/

Leave a Reply