Skip to content

Yet again, another CLI maze generator written in python, but with a cool visualisation to video!

License

Notifications You must be signed in to change notification settings

smallcluster/AnotherMazeGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AnotherMazeGenerator

Yet again, another CLI maze generator written in Python3, but with a cool visualization to video!

Help Mr.Squeaks 🐁 to get that 🧀! But beware of the sticky spider webs 🕷️🕸️, they will slow you down!

Why ?

Python being the FASTEST 🚀 language known to man, you can take the coffee break YOU 🫵 deserve and get your self a nice maze with its generation and solving steps in a video when you come back.


📦 Requirements

Install the required libraries:

pip install -r requirements.txt
  • numpy
  • pillow
  • opencv-python

> Basic usage

📖 Help

To show all CLI options use the -h option:

python maze.py -h

🖼️ Create a maze

Just specify image name (with its format) to the -o argument. Two images of a maze will be generated:

  • without a solution
  • with a solution (the shortest path)

Example:

python maze.py -o example.png


example.png (left), example.solution.png (right)

🏋️ Show weights

Maze solving uses the dijkstra algorithm to compute all cells weights (min path length from source).

The -g option, will draw those weights in the form of a heatmap.

Example:

python maze.py -o example.png -g


example.png (left), example.solution.png (right)

🕸️ Add webs and allow multiple possible solutions

One can add webs that slow down Mr.Squeaks by setting a penalty weight and a random spawn chance with the -w argument. -w waits for a string with a int and a float separated by a ; :

-w "penality(int);spawn_chance([0,1])"

But by default, the generated maze is a perfect maze, which means there is only one path covering the whole maze. This makes webs unavoidable !

To prevent this, one can randomly break some walls by supplying a probability (float between 0 and 1) to the -b option.

Example:

python maze.py -o example.png -w "4;0.1" -b 0.2


example.png (left), example.solution.png (right)
-
The solution purposely walks around the first spider web

🎬 Visualize the algorithms

If an image is specified, one can use the -v option to generate a mp4 video showing the maze generation and maze solving.

Example:

python maze.py -o example.png -v

⚠️ Compressing the generated video is highly recommended as the default compression isn't aggressive enough (video is mostly static)

Example with ffmpeg:

ffmpeg -i example.mp4 tmp.mp4 # up to 80% reduction with negligible quality loss
rm example.mp4
mv tmp.mp4 example.mp4

About

Yet again, another CLI maze generator written in python, but with a cool visualisation to video!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages