A fun little toy/demo displaying some maze algorithms.
Note the mazes generated are perfect mazes, meaning they have exactly one path from any point to any other point inside the maze. They're not so useful for making games without some adaptation.
Algorithms:
Binary tree: at each cell, decides to go either down or right. Produces a bias towards diagonal movement and obvious lines at the bottom/right.
Sidewinder: goes along a run of cells horizontally, then adds one passage downwards. Tends towards vertical movement and obvious line at the bottom.
Aldous-Broder: random walk filling in cells as they're visited. Produces a totally unbiased maze (assuming rnd() is unbiased) but can be slow at the end.
If you're interested in the topic I recommend this book (that I got the idea/algorithms from): Mazes for Programmers.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/bimg/pi/pi16.png)
Does the Aldous-Broder guarantee that all edges are connected to a single tree of nodes?
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/11129/mechtoast.png)
@Danjen: yes (unless I've made a mistake in the implementation) all nodes should be reachable from all others via a single unique path.
[Please log in to post a comment]