In 1991, on a DOS machine with a BGI graphics driver, I wrote a small program that draw colored trees on screen. It wasn't meant to generate mazes. It became one by accident. Last weekend, 35 years and two rewrites later, I finally gave it a home in the browser.
How it started: trees, not mazes
The idea didn't begin as "let me build a maze generator." It began with drawing trees.
First came binary trees — each branch splitting into two. Then I moved to trees with three branches instead of two. At some point those three branches were arranged so they met at 45-degree angles from one another, and that's when it clicked: a tree that never crosses itself, that always has exactly one path from the root to any point on it, is a maze. A "perfect maze" is nothing more than a spanning tree with no cycles. I arrived at that property by drawing branches, not by studying graph theory.
What came out of that was a recursive backtracking routine: pick a point, grow a branch in one of
Discussion
Start the conversation
Your voice can be the first to spark an engaging conversation.