A pygame program that generates a maze and solves itself using a DFS algorithm
Maze Generator And Solver
Program Purpose: Generates a maze that then solves itself
Language: Python and Pygame
Algorithm: Randomized DFS / Floodfill / Recursive Backtracking
How the program works
Generation
- Maintain a matrix that keeps track of visited cells
- Maintain a stack that keeps track of cells on the current path
- Start at the top left cell
- Randomly choose one of the available neighbor cells
- If there are none, go to previous cell in the stack
- Color visited cells blue, current cell blue, and remove the white wall
- Will eventually return to the top left cell and guarantees a maze
Solving