Generating and solving maze
Project description
MMaze
A python maze generator and solver.
Usage
Generating a maze with specific width and height. Print on screen directly.
import mmaze
m = mmaze.generate(width=3, height=3)
print(m)
"""
||||||||||||||
|| || ||
|||||| || ||
|| || ||
|| |||||| ||
|| ||
||||||||||||||
"""
Plot the maze to image.
import mmaze
m = mmaze.generate(width=3, height=3)
m.plot()
Get solution and plot on screen:
import mmaze
m = 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.
import mmaze
m = 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.
import mmaze
start = (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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mmaze-0.1.4.tar.gz.
File metadata
- Download URL: mmaze-0.1.4.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bb5e355509d1e1dcf1cba21f0f1e1cb4533d509e578e93e4746c5a5e9c8aeec
|
|
| MD5 |
09cbbb212cb5ac90201598ff256193db
|
|
| BLAKE2b-256 |
aac307e497dd6ca74985a82252e5a56b58ae0bcd7b42fc4a3ad7630efa6e41d1
|
File details
Details for the file mmaze-0.1.4-py3-none-any.whl.
File metadata
- Download URL: mmaze-0.1.4-py3-none-any.whl
- Upload date:
- Size: 23.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b93d3be9b56a877c5b3baf4fadd2f3dba0baf7b65293c5ce09adb4abcc3c8b5b
|
|
| MD5 |
65222ff9fc71216e96e5343da0a5304f
|
|
| BLAKE2b-256 |
a8234886fd7a91ab8b83774ff99d4ca009d0c7e5d0f217eb26486ec63dcd06e1
|