Skip to main content

Stara Maze Generator

A Python package for generating, solving, and visualizing mazes using a modified version of Prim's algorithm. The mazes are represented as NumPy arrays and can be exported as HTML visualizations.

Features

  • Generate random mazes using a modified Prim's algorithm
  • Configurable maze size and minimum number of valid paths
  • Reproducible maze generation using seeds
  • Pathfinding using Breadth-First Search (BFS)
  • Export mazes as HTML visualizations with optional solution paths
  • Efficient maze representation using NumPy arrays

Installation

The package can be installed using pip:

pip install stara-maze-generator

Or using Poetry:

poetry add stara-maze-generator

Usage

Command Line Interface

The package provides a command-line interface for quick maze generation:

# Generate a default 40x40 maze
generate-maze

# Generate a 20x20 maze with custom start/goal positions
generate-maze --size 20 --start 0 0 --goal 19 19

# Generate a maze with a specific seed and show solution
generate-maze --seed 123 --draw-solution

# Generate a maze with more paths
generate-maze --min-valid-paths 5

Python API

from pathlib import Path
import numpy as np
from stara_maze_generator.vmaze import VMaze
from stara_maze_generator.pathfinder import Pathfinder

# Create a 20x20 maze
maze = VMaze(
    seed=42,              # Random seed for reproducibility
    size=20,              # Creates a 20x20 grid
    start=(1, 1),         # Starting position
    goal=(18, 18),        # Goal position
    min_valid_paths=3     # Minimum number of valid paths
)

# Generate the maze structure
maze.generate_maze(pathfinding_algorithm=Pathfinder.BFS)

# Find a path from start to goal
path = maze.find_path()

# Export as HTML visualization
maze.export_html(Path("maze.html"), draw_solution=True)

Maze Representation

The maze is represented as a 2D NumPy array where:

  • 0 represents walls
  • 1 represents passages
  • The maze is guaranteed to have at least min_valid_paths different paths from start to goal

HTML Visualization

The exported HTML visualization includes:

  • Color-coded cells (walls, passages, start, goal)
  • Optional solution path highlighting
  • Responsive grid layout
  • Maze information (size, seed, algorithm used)

Development

To set up the development environment:

# Clone the repository
git clone https://github.com/yourusername/stara-maze-generator.git
cd stara-maze-generator

# Install dependencies with Poetry
poetry install

# Run tests
poetry run pytest

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for stara-maze-generator 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stara-maze-generator 0.2.2
File Size Uploaded
stara_maze_generator-0.2.2.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stara-maze-generator 0.2.2
File Interpreter ABI Platform
stara_maze_generator-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 21.1 kB

Release files / stara_maze_generator-0.2.2.tar.gz

Download URL stara_maze_generator-0.2.2.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5f66d786833bbed6cf63e56e984465abece3c7bbd678160434648d3737d93934
BLAKE2b-256 checksum
How to use checksums
a50ed15a823f3b1e7865cacd2c9c6ef7e467af814096082ad2c0aa2e75bcdc18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.0 CPython/3.12.1 Linux/6.5.0-1025-azure

Release files / stara_maze_generator-0.2.2-py3-none-any.whl

Download URL stara_maze_generator-0.2.2-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca574bd41d44cead066e523ab673b88d55a60f47bad951d031a777c5c407d4f0
BLAKE2b-256 checksum
How to use checksums
5696a59d317824aa3764cf1a955f4dd255aed57d0c3a66516c546efe1efef4a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.0 CPython/3.12.1 Linux/6.5.0-1025-azure

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page