Generating Mazes with Inductive Graphs (2017)
Published on: 2025-08-06 08:01:59
Generating Mazes with Inductive Graphs 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. It’s especially interesting for functional programming because it relies on graphs and randomness, two things generally viewed as tricky in a functional style. So lets look at how to implement a maze generator in Haskell using inductive graphs for our graph traversal. Here’s what we’re aiming for: A simple maze built from a grid. Inductive graphs are provided by Haskell’s “Functional Graph Library” fgl . All of the code associated with this post is up on GitHub so
... Read full article.