Sidewinder maze algorithm
Sidewinder builds a maze one row at a time: each row is cut into random runs, and every run opens one passage to the row above.
How it works
Work along each row from left to right. At every cell, flip a coin: either carve east and keep the run going, or close the run. When a run closes, pick one random cell in it and carve north from there. The top row can't carve north, so it is one long corridor.
Because every run has exactly one way up, every cell can reach the top row, and the whole maze is connected with no loops. It needs only the current run in memory, so it is very fast.
What to watch for
Watch the rows appear top to bottom, each one breaking into short horizontal runs that each poke one hole upwards.
Properties
- Texture
- Horizontal runs, one straight top corridor
- Dead ends
- Many
- Uniform
- No
- Speed
- Very fast
- Memory
- One row
Try it
Open the studio to carve your own Sidewinder maze at any size, solve it with up to four algorithms, and save the video.
FAQ
Why is the top row always open?
Cells in the top row have nowhere north to carve, so every run there keeps going east to the edge.
How is it different from Binary Tree?
Binary Tree lets each cell choose north or west independently. Sidewinder groups cells into runs, which removes Binary Tree's strong diagonal bias.