August 2022
Intermediate to advanced
328 pages
8h 9m
English
Chapter 4 described a recursive algorithm that solves mazes, but another recursive algorithm generates mazes. In this chapter, we’ll generate mazes in the same format as the maze-solver program in Chapter 4. So, whether you’re a fan of solving mazes or creating them, you’ll now have the power to apply programming to the task.
The algorithm works by visiting a starting space in the maze and then recursively visiting a neighboring space. The maze’s hallways are “carved out” of the maze as the algorithm continues to visit neighbors. If the algorithm reaches a dead end that has no neighboring spaces, it backtracks to earlier ...
Read now
Unlock full access