December 2020
Watching the maze carve itself was the coolest thing I'd made yet.
An animated maze generator built with p5.js. It carves a random maze out of a 15×15 grid using the recursive backtracking algorithm, drawing each step live — the red square is the current head of the walk, shaded cells are already visited, and walls fall as it goes.
Every cell starts with four walls. From the top-left corner the algorithm walks to a random unvisited neighbour, knocking down the wall between them, and when it hits a dead end it backtracks along a stack until it finds a cell with somewhere left to go.
Watching it run is the whole point: the red head wanders, gets stuck, retreats, and by the time it's done a perfect maze has been carved out of nothing.