This project provides a simple ASCII Maze Generator implemented in Python.
It uses recursive backtracking to generate a random maze and displays it both in the terminal (ASCII format) and graphically using Matplotlib.
- Randomized maze generation using recursive backtracking
- Customizable width, height, and random seed
- ASCII-style visualization in the terminal
- Clean visualization using Matplotlib
- Deterministic output with seed input (or random as per user)
Install dependencies before running the script:
pip install matplotlibRun the script directly from the terminal:
python maze.pyYou will be prompted to enter:
- Width: number of maze cells horizontally
- Height: number of maze cells vertically
- Seed: integer seed for deterministic generation (
-1for random maze)
Example:
Enter width: 10
Enter height: 6
Enter seed or -1 if random: 42ASCII Maze:
#####################
S # # #
# ####### ### ##### #
# # # # #
####### # ####### # #
# # # # # #
# ##### ####### # # #
# # # # # #
# # # ### ######### #
# # # # # # #
# # # ####### # # # #
# # # E
#####################
A neatly formatted ASCII maze is displayed in a pop-up matplotlib window for easy visualization.
- The maze is represented as a 2D grid (
1for wall,0for passage). - Recursive carving starts from a random odd-indexed cell.
- Each recursive step randomly picks a direction and carves a passage.
- An entrance (
S) and exit (E) are added automatically.