maze-nd


Namemaze-nd JSON
Version 0.1.1 PyPI version JSON
download
home_page
SummaryA python package for generating and visualizing n-dimensional mazes.
upload_time2023-11-21 03:56:18
maintainer
docs_urlNone
authorDaniel
requires_python>=3.10,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![A woodsy maze](https://github.com/dthuff/maze-nd/blob/master/examples/maze_kaboom_100_30.png)

# maze-nd

A python package for generating n-dimensional mazes via [randomized Prim's Algorithm](https://en.wikipedia.org/wiki/Maze_generation_algorithm)

Initial implementation in 2D from: https://github.com/ArneStenkrona/MazeFun

# Getting Started

## Prerequisites
Poetry: https://python-poetry.org/docs/#installation

## Installation

### Clone the repository: 

    git clone https://github.com/dthuff/maze-nd

### and install dependencies:

    cd maze-nd/
    poetry install

### Or, install via pip:

    pip install maze-nd

# Usage
## Generating maze structures
The MazeND class defines a maze data structure represented by a boolean array of arbitrary shape `maze.grid`.

A 2D maze of 40 rows and 40 columns can be generated with:

    from maze_nd.maze_nd import MazeND
    maze = MazeND([40, 40])

Note that maze dimensions must be odd to ensure a solid outer border. If even shape args are passed, they will be forced to be odd.

    maze = MazeND([40, 40])

    >>> maze.grid.shape
    (39, 39)

A 3D maze of 40 rows, 40 columns, and 20 slices can be generated with:

    maze = MazeND([40, 40, 20])

A 7D maze:

    maze = MazeND([20, 20, 20, 10, 10, 20, 5])

_**Caution**_: generation time is proportional to `np.prod(maze.grid.shape)`. This can quickly blow up for mazes with more than 4 dimensions.


## Visualizing maze structures

The maze generation process can be visualized using `examples/draw_maze.py`:

    poetry run python draw_maze.py 40 40

By default, this will save an image of the maze at `examples/maze_image.png`

Any number of shape dimensions can be passed. A 3D maze can be generated via:

    poetry run python draw_maze.py 20 20 20

For mazes with dimension N > 2, 2D planes of the maze will be drawn separated by a vertical border. For an N-D maze, N-1 planes are shown.


The animation can be turned off using `--skip-animation`:

    poetry run python draw_maze.py 40 40 --skip-animation

Fun color themes can be applied via `--theme`:

    poetry run python draw_maze.py --theme beachy 40 40

Available themes are: 
`default`
![A boring, default maze](https://github.com/dthuff/maze-nd/blob/master/examples/maze_default_90_40.png)

`beachy`, 
![A beachy maze](https://github.com/dthuff/maze-nd/blob/master/examples/maze_beachy_90_40.png)

`woodsy`, 
![A woodsy maze](https://github.com/dthuff/maze-nd/blob/master/examples/maze_woodsy_90_40.png)

`christmas`, 
![A festive, christmas maze](https://github.com/dthuff/maze-nd/blob/master/examples/maze_christmas_90_40.png)

and `kaboom`.
![An explosive, kaboom maze](https://github.com/dthuff/maze-nd/blob/master/examples/maze_kaboom_90_40.png)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "maze-nd",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Daniel",
    "author_email": "huffdanielt@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/25/c7/a35d02b06c76852551c875cb0b6fbdd5cef2faa0bc39b03e821f45c17d17/maze_nd-0.1.1.tar.gz",
    "platform": null,
    "description": "![A woodsy maze](https://github.com/dthuff/maze-nd/blob/master/examples/maze_kaboom_100_30.png)\n\n# maze-nd\n\nA python package for generating n-dimensional mazes via [randomized Prim's Algorithm](https://en.wikipedia.org/wiki/Maze_generation_algorithm)\n\nInitial implementation in 2D from: https://github.com/ArneStenkrona/MazeFun\n\n# Getting Started\n\n## Prerequisites\nPoetry: https://python-poetry.org/docs/#installation\n\n## Installation\n\n### Clone the repository: \n\n    git clone https://github.com/dthuff/maze-nd\n\n### and install dependencies:\n\n    cd maze-nd/\n    poetry install\n\n### Or, install via pip:\n\n    pip install maze-nd\n\n# Usage\n## Generating maze structures\nThe MazeND class defines a maze data structure represented by a boolean array of arbitrary shape `maze.grid`.\n\nA 2D maze of 40 rows and 40 columns can be generated with:\n\n    from maze_nd.maze_nd import MazeND\n    maze = MazeND([40, 40])\n\nNote that maze dimensions must be odd to ensure a solid outer border. If even shape args are passed, they will be forced to be odd.\n\n    maze = MazeND([40, 40])\n\n    >>> maze.grid.shape\n    (39, 39)\n\nA 3D maze of 40 rows, 40 columns, and 20 slices can be generated with:\n\n    maze = MazeND([40, 40, 20])\n\nA 7D maze:\n\n    maze = MazeND([20, 20, 20, 10, 10, 20, 5])\n\n_**Caution**_: generation time is proportional to `np.prod(maze.grid.shape)`. This can quickly blow up for mazes with more than 4 dimensions.\n\n\n## Visualizing maze structures\n\nThe maze generation process can be visualized using `examples/draw_maze.py`:\n\n    poetry run python draw_maze.py 40 40\n\nBy default, this will save an image of the maze at `examples/maze_image.png`\n\nAny number of shape dimensions can be passed. A 3D maze can be generated via:\n\n    poetry run python draw_maze.py 20 20 20\n\nFor mazes with dimension N > 2, 2D planes of the maze will be drawn separated by a vertical border. For an N-D maze, N-1 planes are shown.\n\n\nThe animation can be turned off using `--skip-animation`:\n\n    poetry run python draw_maze.py 40 40 --skip-animation\n\nFun color themes can be applied via `--theme`:\n\n    poetry run python draw_maze.py --theme beachy 40 40\n\nAvailable themes are: \n`default`\n![A boring, default maze](https://github.com/dthuff/maze-nd/blob/master/examples/maze_default_90_40.png)\n\n`beachy`, \n![A beachy maze](https://github.com/dthuff/maze-nd/blob/master/examples/maze_beachy_90_40.png)\n\n`woodsy`, \n![A woodsy maze](https://github.com/dthuff/maze-nd/blob/master/examples/maze_woodsy_90_40.png)\n\n`christmas`, \n![A festive, christmas maze](https://github.com/dthuff/maze-nd/blob/master/examples/maze_christmas_90_40.png)\n\nand `kaboom`.\n![An explosive, kaboom maze](https://github.com/dthuff/maze-nd/blob/master/examples/maze_kaboom_90_40.png)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A python package for generating and visualizing n-dimensional mazes.",
    "version": "0.1.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c6cc307bd05300dca6a90067cac3776a89f18d4406c1df4d226d26af97c84f27",
                "md5": "aace66c273e7697696450b20c1255df6",
                "sha256": "203ff13a693301639d99a10ef214476bdf2be5bc417de7475bbef83fda6283ab"
            },
            "downloads": -1,
            "filename": "maze_nd-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aace66c273e7697696450b20c1255df6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 6989,
            "upload_time": "2023-11-21T03:56:16",
            "upload_time_iso_8601": "2023-11-21T03:56:16.969876Z",
            "url": "https://files.pythonhosted.org/packages/c6/cc/307bd05300dca6a90067cac3776a89f18d4406c1df4d226d26af97c84f27/maze_nd-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "25c7a35d02b06c76852551c875cb0b6fbdd5cef2faa0bc39b03e821f45c17d17",
                "md5": "769584df767dafb38b41dce216987b85",
                "sha256": "286a8781c712a659e2c2000dd5ccabac973ae60580ecd72139f41dbcee4a0ddb"
            },
            "downloads": -1,
            "filename": "maze_nd-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "769584df767dafb38b41dce216987b85",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 5986,
            "upload_time": "2023-11-21T03:56:18",
            "upload_time_iso_8601": "2023-11-21T03:56:18.526843Z",
            "url": "https://files.pythonhosted.org/packages/25/c7/a35d02b06c76852551c875cb0b6fbdd5cef2faa0bc39b03e821f45c17d17/maze_nd-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-21 03:56:18",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "maze-nd"
}
        
Elapsed time: 1.10953s