Generates mazes using Prim's Algorithm
This program generates n x m
mazes using a randomized Prim's Algorithm, which is based on this description.
Run
python3 MazeGenerator.py <height> <width> <seed>
to generate a 10 x 10
maze.
Optionally, input integer parameters
python3 MazeGenerator.py <height> <width>
for a <height> x <width>
maze.
Additionally, the program supports seeding for reproducable mazes:
python3 MazeGenerator.py <height> <width> <seed>
To export maze into file, use the terminal piping command:
python3 MazeGenerator.py > cool_maze.txt
All program prompts are printed to stderr
so only the maze will be piped.
Empty (round-edged) squares are denoted as paths. Walls are filled in rectangles. The borders are double lines. Starting point denoted S
and end point denoted E
.
Here is a 4 x 4
sample:
=========
‖S▢▢▢▢▢▢‖
‖▢▬▢▬▢▬▬‖
‖▢▮▢▮▢▢▢‖
‖▢▬▢▬▬▬▢‖
‖▢▮▢▮▢▢▢‖
‖▬▬▬▬▬▬▢‖
‖E▢▢▢▢▢▢‖
=========
Another 100 x 100
maze is stored in sample_maze.txt
Python3 is recommended. To use a lower version, uncomment the first line to import the print function from the __future__
.