Skip to main content

A no-dependency library to generate mazes.

Project description

Labyrinthine

A no-dependency library to generate mazes.

maze

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 of int specifying width and height of the maze, or a single int for a square one.
  • start: a pair of int defining the starting point. Default value is (0, 0), the top-left corner of the maze.
  • seed: int, optional. Default value is None.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

labyrinthine-0.1.11.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

labyrinthine-0.1.11-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page