Skip to content

Commit

Permalink
Added class and improved docs
Browse files Browse the repository at this point in the history
  • Loading branch information
omeyenburg committed Jan 15, 2024
1 parent a8174ff commit 8ba3622
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/mazeforge.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ 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
Keywords: labyrinth,maze,pymaze,generation,generate,solve
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Expand Down
2 changes: 1 addition & 1 deletion src/mazeforge.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ MANIFEST.in
README.md
pyproject.toml
src/mazeforge/__init__.py
src/mazeforge/base.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
2 changes: 0 additions & 2 deletions src/mazeforge.egg-info/entry_points.txt

This file was deleted.

24 changes: 15 additions & 9 deletions src/mazeforge/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
"""MazeForge
Contact:
--------
"""
MazeForge
=========
- [email protected]
Provides
1. Generation of mazes
2. Solving of mazes
3. Visualisation of mazes
More information is available at:
Contact
- [email protected]
- https://pypi.org/project/mazeforge/
- https://github.com/oskarmeyenburg/mazeforge
More information
- https://pypi.org/project/mazeforge/
- https://github.com/oskarmeyenburg/mazeforge
"""
from .generator import generate
from .base import Maze


__version__ = "0.1.0"
__version__ = "0.1.0"
__all__ = ['Maze', 'generate']
16 changes: 16 additions & 0 deletions src/mazeforge/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import numpy


class Maze(numpy.ndarray):
def __new__(cls, width, height):
# Create a new array with the specified dimensions and fill value
maze_array = numpy.full((height, width), 0, dtype=numpy.int_)
obj = maze_array.view(cls)
return obj

@classmethod
def from_array(cls, array):
"""
Create a new Maze instance from an existing NumPy array
"""
return array.view(cls)
17 changes: 16 additions & 1 deletion src/mazeforge/generator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import random
import numpy

def generate(width: int, height: int) -> numpy.array:
def generate(width: int, height: int) -> numpy.ndarray:
"""
Generate a 2d maze on a grid.
Parameters
----------
width : int
Number of columns in the maze.
height : int
Number of rows in the maze.
Returns
-------
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_)
Expand Down

0 comments on commit 8ba3622

Please sign in to comment.