Maze Generation: Recursive Backtracking(weblog.jamisbuck.org)
weblog.jamisbuck.org
Maze Generation: Recursive Backtracking
http://weblog.jamisbuck.org/2010/12/27/maze-generation-recursive-backtracking#content
http://weblog.jamisbuck.org/2010/12/27/maze-generation-recursive-backtracking#content
This is basically the algorithm I use however instead of using a recursive call I have a variable that keeps track of the current position. When I run in to a dead end and need to backtrack I mark the cell with a special backtrack flag and find the only neighboring cell that I can move back to that does not have the backtrack flag.