-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2318a4
commit a657ec6
Showing
13 changed files
with
158 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Build and Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install numpy | ||
- name: Run tests | ||
run: pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
mazeforge.egg-info | ||
**/__pycache__ | ||
**/.DS_Store | ||
**/.vscode | ||
tutorial.md | ||
venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
Metadata-Version: 2.1 | ||
Name: mazeforge | ||
Version: 0.1.0 | ||
Summary: Simple and fast generation of mazes in Python | ||
Author-email: Oskar Meyenburg <[email protected]> | ||
License: MIT License | ||
|
||
Copyright (c) 2024 Oskar Meyenburg | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
Project-URL: repository, https://github.com/oskarmeyenburg/mazeforge | ||
Project-URL: documentation, https://github.com/oskarmeyenburg/mazeforge/blob/main/README.md | ||
Keywords: labyrinth,maze,pymaze,generation | ||
Classifier: License :: OSI Approved :: MIT License | ||
Classifier: Programming Language :: Python | ||
Classifier: Programming Language :: Python :: 3 | ||
Requires-Python: >=3.7 | ||
Description-Content-Type: text/markdown | ||
License-File: LICENSE | ||
Requires-Dist: numpy | ||
Provides-Extra: build | ||
Requires-Dist: build; extra == "build" | ||
Requires-Dist: twine; extra == "build" | ||
Provides-Extra: dev | ||
Requires-Dist: black; extra == "dev" | ||
Requires-Dist: bumpver; extra == "dev" | ||
Requires-Dist: isort; extra == "dev" | ||
Requires-Dist: mypy; extra == "dev" | ||
Requires-Dist: pytest; extra == "dev" | ||
|
||
# MazeForge | ||
Generation of mazes in Python | ||
|
||
## Installation | ||
You can install **MazeForge** from [PyPI](https://pypi.org/project/mazeforge/) by running the following in your terminal.<br> | ||
`python -m pip install mazeforge` | ||
<br> | ||
MazeForge is supported on Python 3.7 and above. | ||
|
||
## How to use | ||
```python | ||
>>> import mazeforge | ||
>>> mazeforge.generate(3, 3) | ||
array([[1., 1., 1., 1., 1., 1., 1.], | ||
[1., 0., 1., 0., 0., 0., 1.], | ||
[1., 0., 1., 0., 1., 1., 1.], | ||
[1., 0., 0., 0., 1., 0., 1.], | ||
[1., 1., 1., 0., 1., 0., 1.], | ||
[1., 0., 0., 0., 0., 0., 1.], | ||
[1., 1., 1., 1., 1., 1., 1.]]) | ||
``` | ||
|
||
## Documentation | ||
### mazeforge.generate | ||
`mazeforge.generate` generates a perfect maze. This means that any two cells are connected by one single unique path. The function returns 2d numpy array. Walls are represented as a `1` and corridor as a `0`. The maze is generated using the prim's algorithm. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
LICENSE | ||
MANIFEST.in | ||
README.md | ||
pyproject.toml | ||
src/mazeforge/__init__.py | ||
src/mazeforge/generator.py | ||
src/mazeforge.egg-info/PKG-INFO | ||
src/mazeforge.egg-info/SOURCES.txt | ||
src/mazeforge.egg-info/dependency_links.txt | ||
src/mazeforge.egg-info/entry_points.txt | ||
src/mazeforge.egg-info/requires.txt | ||
src/mazeforge.egg-info/top_level.txt | ||
tests/test_generator.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[console_scripts] | ||
mazeforge = mazeforge.__main__:main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
numpy | ||
|
||
[build] | ||
build | ||
twine | ||
|
||
[dev] | ||
black | ||
bumpver | ||
isort | ||
mypy | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mazeforge |
Binary file not shown.
Binary file not shown.
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import src.mazeforge as mazeforge | ||
# import pygame | ||
import numpy | ||
import time | ||
|
||
width = height = 4 | ||
maze = mazeforge.generate(width, height) | ||
print(maze) | ||
time.sleep(1) | ||
# width = width * 2 + 1 | ||
# height = height * 2 + 1 | ||
# pygame.init() | ||
# window = pygame.display.set_mode((width * 10, height * 10)) | ||
|
||
|
||
# for x, y in numpy.ndindex((width, height)): | ||
# if not maze[x, y]: | ||
# pygame.draw.rect(window, (255, 255, 255), (x * 10, y * 10, 10, 10)) | ||
|
||
|
||
# while True: | ||
# for event in pygame.event.get(): | ||
# if event.type == pygame.QUIT: | ||
# pygame.quit() | ||
# raise SystemExit() | ||
|
||
# pygame.display.flip() |