Skip to content

omeyenburg/MazeForge

Repository files navigation

MazeForge

Generation of mazes in Python

Installation

You can install MazeForge from PyPI by running the following in your terminal.
python -m pip install mazeforge

MazeForge is supported on Python 3.7 and above.

Documentation

class mazeforge.Maze(width, height)

This generates a perfect maze, which means that any two cells are connected by one single unique path. The maze is generated using the prim's algorithm.

>>> import mazeforge
>>> mazeforge.Maze(width=5, height=5)
Maze(width=5, height=5)

print()

You can print the Maze using the print method.

>>> import mazeforge
>>> mazeforge.Maze(5, 5).print()
┌───────┬───────────┐   
│       │           │   
├───╴   └───╴   ╷   │   
│               │   │   
│   ┌───────╴   ├───┤   
│   │           │   │   
├───┘   ╷   ╷   ╵   │   
│       │   │       │   
├───────┘   │   ╷   │   
│           │   │   │   
└───────────┴───┴───┘

For further use, you may also convert the maze into a string.

>>> import mazeforge
>>> maze = mazeforge.Maze(5, 5)
>>> str(maze)
'┌───────┬───────────┐   \n│       │           │   \n├───╴   └───╴   ╷   │   \n│               │   │   \n│   ┌───────╴   ├───┤   \n│   │           │   │   \n├───┘   ╷   ╷   ╵   │   \n│       │   │       │   \n├───────┘   │   ╷   │   \n│           │   │   │   \n└───────────┴───┴───┘'

About

Generation of mazes in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published