The generated maze will be 'perfect', as in every point can be reached from every point.
- Pick a random cell (center), set cell as taken and put on the stack.
- Look at the last item in the stack. (blue, number is length on stack)
- Pick a neighbour empty(dark) cell, at random. (green)
- Is one available?
- Yes: Add neighbour cell to the stack. - Set cell as taken. - Basically we "dig" through the walls into this cell.
- No: Remove the last item from the stack. - We never "dig" into a previously made tunnel, only out of.
- If there are items in the stack, go to 2
Walkers use the "left-hand-rule". Touch the wall with your left hand and keep following it.