Depth-First Search Maze Generation Algorithm

preview_player
Показать описание
This is an animation of a maze being generated using a depth-first search algorithm. The maze was generated using my maze generator, Labyrinth, and the animation was generated using Manim, an animation library geared toward mathematics.

The depth-first search algorithm works by starting at a predetermined cell (in this case, the cell in the upper left) and marking that cell as visited. We then move to a random unvisited neighboring cell, mark that cell as visited, and repeat, building a long path through the maze. When we end up in a situation where all of the current cell's neighbors have been visited, we backtrack to the most recent junction we came to and start building a new path from there. This process is repeated until all cells in the maze have been visited, at which point the maze is ready to be solved.

The colors used in the animation are as follows:
- Gray cells have not yet been visited.
- Blue cells have been visited and are part of the completed maze.
- Orange cells represent the current path being added to the maze.

Many thanks to Grant Sanderson, the original creator of Manim, for making his excellent animation framework freely available for people like me to use. Grant's outstanding YouTube channel, 3Blue1Brown, has also helped inspire me to create a maze generator and specifically to focus on the visualization of various maze generation algorithms. Thanks also to the Manim community for their excellent documentation and work on the community edition of Manim, which is what I used for this animation.
Рекомендации по теме
join shbcf.ru