Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/morvanzhou/mmaze
A python maze generator and solver
https://github.com/morvanzhou/mmaze
maze maze-generator maze-solver python symmetric-maze
Last synced: 3 months ago
JSON representation
A python maze generator and solver
- Host: GitHub
- URL: https://github.com/morvanzhou/mmaze
- Owner: MorvanZhou
- License: mit
- Created: 2022-09-26T07:13:57.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-02T05:26:29.000Z (about 2 years ago)
- Last Synced: 2024-05-02T21:27:42.126Z (9 months ago)
- Topics: maze, maze-generator, maze-solver, python, symmetric-maze
- Language: Python
- Homepage:
- Size: 77.1 KB
- Stars: 17
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MMaze
A python maze generator and solver.
## Usage
Generating a maze with specific width and height. Print on screen directly.
```python
import mmazem = mmaze.generate(width=3, height=3)
print(m)"""
||||||||||||||
|| || ||
|||||| || ||
|| || ||
|| |||||| ||
|| ||
||||||||||||||
"""
```Plot the maze to image.
```python
import mmazem = mmaze.generate(width=3, height=3)
m.plot()
```
Get solution and plot on screen:
```python
import mmazem = mmaze.generate(width=3, height=3)
solutions = m.solve(start=(0, 0), end=(2, 2))
print(m.tostring(solution=solutions[0], start=(0, 0), end=(2, 2)))"""
||||||||||||||
||S ********||
|| ||||||**||
|| || **||
|| ||||||**||
|| || E ||
||||||||||||||
"""
```Generate a solution and plot to an image.
```python
import mmazem = mmaze.generate(width=10, height=10)
solutions = m.solve(start=(0, 0), end=(9, 9))
m.plot(solution=solutions[0], start=(0, 0), end=(9, 9))
```
To make a symmetric maze by passing a symmetry method. Note that width or height must be odd number when you want to
solve the generated maze.In this repo, only backtracking / growingtree / huntandkill / prims algorithms can generate symmetric maze.
```python
import mmazestart = (0, 0)
end = (10, 10)
m = mmaze.generate(width=11, height=11, symmetry="horizontal")
solutions = m.solve(start=start, end=end)
m.plot(solution=solutions[0], start=start, end=end)
```
## Install
```
pip install mmaze
```## More demo use cases
Demo can be found in test file: [tests](https://github.com/MorvanZhou/mmaze/blob/master/tests/mmaze_test.py)