Get the latest tech news
Generating Mazes with Inductive Graphs (2017)
A few years ago—back in high school—I spent a little while writing programs to automatically generate mazes. It was a fun exercise and helped me come to grips with recursion: the first time I implemented it (in Java), I couldn’t get the recursive version to work properly so ended up using a while loop with an explicit stack! Making random mazes is actually a really good programming exercise: it’s relatively simple, produces cool pictures and does a good job of covering graph algorithms.
The actual graph view in fgl is a bit different and supports node and edge labels, which I’ve left out for simplicity. The final pieces of the puzzle are labeling the edges in a way that’s convenient to draw and generating the graph for the initial grid. The edges are labeled with an (x, y) position and either Horizontal(—) or Vertical(|).Running edfsR over a starting maze will give us the list of walls that were knocked down —they’re the ones we don’t want to draw.
Or read this on Hacker News