Member-only story
I believe everyone has played the maze game. This is a classic mini-game. Players need to start from the starting point, go through the maze, and then reach the end. But have you ever wondered how such a maze is generated? If you are given a complex maze, can you solve it by programing?
In this series, we will learn the solution and generation of a maze, and visualize the related process.
Project Preview
In this tutorial, we will use related algorithms to make the following effect.
- Use a recursive implementation of the depth-first search algorithm to solve the maze
Online Demo:
In the gif above, the blue squares represent the walls of the maze, and the white squares represent the roads of the maze. The yellow path represents a solution of the maze, and the red path represents the solution process of the algorithm.
2. Use an iterative implementation of the depth-first search algorithm to solve the maze