diff --git a/README.md b/README.md index 69b153a..f3e771d 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,17 @@ # 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.
`python -m pip install mazeforge`
+ MazeForge is supported on Python 3.7 and above. ## How to use + ```python >>> import mazeforge >>> mazeforge.generate(3, 3) @@ -21,5 +25,7 @@ array([[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. \ No newline at end of file + +`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. diff --git a/dist/mazeforge-0.1.0-py3-none-any.whl b/dist/mazeforge-0.1.0-py3-none-any.whl index 6e7a1bd..c21f35e 100644 Binary files a/dist/mazeforge-0.1.0-py3-none-any.whl and b/dist/mazeforge-0.1.0-py3-none-any.whl differ diff --git a/dist/mazeforge-0.1.0.tar.gz b/dist/mazeforge-0.1.0.tar.gz index 3ca8cb7..c834168 100644 Binary files a/dist/mazeforge-0.1.0.tar.gz and b/dist/mazeforge-0.1.0.tar.gz differ diff --git a/pyproject.toml b/pyproject.toml index 5df6a05..2105f80 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,15 +1,16 @@ [build-system] -requires = ["setuptools>=61.0.0", "wheel"] +requires = ["setuptools >= 61.0.0", "wheel"] build-backend = "setuptools.build_meta" [project] name = "mazeforge" version = "0.1.0" -description = "Simple and fast generation of mazes in Python" +description = "Simple and fast generation of mazes" readme = "README.md" authors = [{ name = "Oskar Meyenburg", email = "oskar.meyenburg@gmail.com" }] license = { file = "LICENSE" } classifiers = [ + "Intended Audience :: Developers", "Operating System :: OS Independent", "License :: OSI Approved :: MIT License", "Programming Language :: Python", @@ -19,38 +20,36 @@ keywords = ["labyrinth", "maze", "pymaze", "generation", "generate", "solve"] dependencies = ["numpy"] requires-python = ">=3.7" - [project.optional-dependencies] - build = ["build", "twine"] - dev = ["black", "bumpver", "isort", "mypy", "pytest"] +[project.optional-dependencies] +build = ["build", "twine"] +dev = ["black", "bumpver", "isort", "mypy", "pytest"] - # This would create the terminal command "mazeforge" - #[project.scripts] - #mazeforge = "mazeforge.__main__:main" +# This would create the terminal command "mazeforge" +#[project.scripts] +#mazeforge = "mazeforge.__main__:main" - [project.urls] - Homepage = "https://github.com/oskarmeyenburg/mazeforge" - repository = "https://github.com/oskarmeyenburg/mazeforge" - documentation = "https://github.com/oskarmeyenburg/mazeforge/blob/main/README.md" +[project.urls] +repository = "https://github.com/oskarmeyenburg/mazeforge" +documentation = "https://github.com/oskarmeyenburg/mazeforge/blob/main/README.md" [tool.bumpver] current_version = "0.1.0" version_pattern = "MAJOR.MINOR.PATCH" commit_message = "bump version {old_version} -> {new_version}" -commit = true -tag = true -push = false - - [tool.bumpver.file_patterns] - "pyproject.toml" = [ - 'current_version = "{version}"', - 'version = "{version}"', - ] - "src/mazeforge/__init__.py" = ["{version}"] - "src/mazeforge/__main__.py" = ["- mazeforge v{version}"] +commit = true +tag = true +push = false + +[tool.bumpver.file_patterns] +"pyproject.toml" = [ + 'current_version = "{version}"', + 'version = "{version}"', +] +"src/mazeforge/__init__.py" = ["{version}"] [tool.isort] -profile = "black" -import_heading_stdlib = "Standard library imports" +profile = "black" +import_heading_stdlib = "Standard library imports" import_heading_thirdparty = "Third party imports" import_heading_firstparty = "Reader imports" diff --git a/src/mazeforge.egg-info/PKG-INFO b/src/mazeforge.egg-info/PKG-INFO index d0bfbe0..683b322 100644 --- a/src/mazeforge.egg-info/PKG-INFO +++ b/src/mazeforge.egg-info/PKG-INFO @@ -1,7 +1,7 @@ Metadata-Version: 2.1 Name: mazeforge Version: 0.1.0 -Summary: Simple and fast generation of mazes in Python +Summary: Simple and fast generation of mazes Author-email: Oskar Meyenburg License: MIT License @@ -25,10 +25,10 @@ License: MIT License OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Project-URL: Homepage, https://github.com/oskarmeyenburg/mazeforge 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,generate,solve +Classifier: Intended Audience :: Developers Classifier: Operating System :: OS Independent Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python @@ -48,15 +48,19 @@ 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.
`python -m pip install mazeforge`
+ MazeForge is supported on Python 3.7 and above. ## How to use + ```python >>> import mazeforge >>> mazeforge.generate(3, 3) @@ -70,5 +74,7 @@ array([[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. diff --git a/src/mazeforge/generator.py b/src/mazeforge/generator.py index 5889b5d..524e2da 100644 --- a/src/mazeforge/generator.py +++ b/src/mazeforge/generator.py @@ -1,7 +1,7 @@ import random import numpy -def generate(width: int, height: int) -> numpy.ndarray: +def generate(width, height): """ Generate a 2d maze on a grid. @@ -17,27 +17,23 @@ def generate(width: int, height: int) -> numpy.ndarray: numpy.ndarray Maze as a numpy.ndarray with the shape (2 * width + 1, 2 * height + 1) """ - width = width * 2 + 1 - height = height * 2 + 1 - maze = numpy.ones((width, height), dtype=numpy.int_) + # Prim's algorithm + array_width = width * 2 + 1 + array_height = height * 2 + 1 + maze = numpy.ones((array_width, array_height), dtype=numpy.int_) - for x, y in numpy.ndindex((width, height)): + for x, y in numpy.ndindex((array_width, array_height)): if 1 == x % 2 == y % 2: maze[x, y] = 0 - # Prim's algorithm - maze_width = (width - 1) // 2 - maze_height = (height - 1) // 2 - def get_neighbours(x, y): neighbours = {(x - 1, y), (x + 1, y), (x, y - 1), (x, y + 1)} for neighbour in tuple(neighbours): - if not (0 <= neighbour[0] < maze_width and 0 <= neighbour[1] < maze_height): + if not (0 <= neighbour[0] < width and 0 <= neighbour[1] < height): neighbours.discard(neighbour) return neighbours - - existing_cells = {(maze_width // 2, maze_height // 2)} + existing_cells = {(width // 2, height // 2)} adjacent_cells = get_neighbours(*list(existing_cells)[0]) while len(adjacent_cells):