A no-dependency library to generate mazes.
Project description
Labyrinthine
A no-dependency library to generate mazes.
Installation
pip install labyrinthine
Usage
import matplotlib.pyplot as plt
import numpy as np
from labyrinthine import depth_first
maze = depth_first(size=(31, 21))
plt.imshow(np.pad(maze, 1, constant_values=1), cmap="binary")
plt.axis("off")
plt.savefig("maze.png", bbox_inches="tight", pad_inches=0)
Parameters
depth_first
accepts the following parameters:
size
: either a pair ofint
specifying width and height of the maze, or a singleint
for a square one.start
: a pair ofint
defining the starting point. Default value is(0, 0)
, the top-left corner of the maze.seed
:int
, optional. Default value isNone
.
The output is an integer matrix of the requested size, where 1 represents a filled cell, thus a wall, and 0 represents an empty cell, thus a passage.
:warning: HEADS UP!
Due to the nature of the algorithm, it is warmly recommended to use odd width and height values, so that the resulting matrix doesn't have a vertical and horizontal border entirely filled with walls.
Development
Makefile
is self-explanatory.
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
File details
Details for the file labyrinthine-0.1.11.tar.gz
.
File metadata
- Download URL: labyrinthine-0.1.11.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f9278e07c3c04c6616fceb6fdaedcb000dada96ca9facbacdacdab0fa57155c |
|
MD5 | 4158dc3676d346aa05c5306ccc32dc63 |
|
BLAKE2b-256 | d09ba00ce4cbc503d6d904951f20ded58a219dada1c0d243cde98eef379387ea |
File details
Details for the file labyrinthine-0.1.11-py3-none-any.whl
.
File metadata
- Download URL: labyrinthine-0.1.11-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47683c5349fa78776f73218319eceacb6dcd40b4acbddfd6217e808fce763e53 |
|
MD5 | 3398e6161abaa7c0bd3c57ccae6b29a7 |
|
BLAKE2b-256 | 1b5aa54c9c1895508f493b2e1c22ab0febc2eaa226c979d6a636641ed6ccdfff |