Implementation and visualization of recursive backtracker algorithm for maze creation in javaScript.
The depth-first search algorithm of maze generation can be described with a following recursive routine:
- Given a current cell as a parameter
- Mark the current cell as visited
- While the current cell has any unvisited neighbour cells
- Choose one of the unvisited neighbours
- Remove the wall between the current cell and the chosen cell
- Invoke the routine recursively for a chosen cell which is invoked once for any initial cell in the area.
source: Wikipedia Maze_generation_algorithm