Skip to main content

Crate amaze

Crate amaze 

Source
Expand description

A playground for maze and procedural dungeon generation in Rust.

amaze provides a collection of algorithms and utilities for creating, solving, rendering, and serializing mazes and procedural dungeons. It is the core library behind the amaze-cli and amaze-gui binaries, suitable for games, simulations, and procedural-content experiments.

§Features

  • Perfect-maze generators for 4-connected grids: recursive backtracker, growing tree, Kruskal, Eller, Wilson, hunt-and-kill, sidewinder, binary tree, and Prim.
  • Hexagonal (6-connected) generators: recursive backtracker, growing tree, and Aldous-Broder.
  • Procedural dungeons: caverns, rooms, and winding layouts.
  • Pathfinding solvers: BFS, DFS, A*, and dead-end filling, all implementing the shared preamble::MazeSolver trait.
  • Renderers: Unicode box-drawing characters and PGM images, plus statistics via preamble::MazeStats.
  • Graph representations: adjacency lists, edge lists, passability grids (with hex variants), and optional petgraph integration.
  • Serialization: binary format, JSON, and file I/O support.

§Quick Start

Generate a small rectangular maze and render it with Unicode box-drawing characters:

use amaze::generators::RecursiveBacktracker4;
use amaze::preamble::Wall4Grid;
use amaze::renderers::{UnicodeRenderStyle, UnicodeRenderer};

let generator = RecursiveBacktracker4::new_from_seed(0xdeadbeef);
let grid: Wall4Grid = generator.generate(6, 6);

let renderer = UnicodeRenderer::new(UnicodeRenderStyle::Heavy, true);
let output = renderer.render(&grid);
assert!(!output.is_empty());

§Feature Flags

The crate ships with a rich set of optional features. The defaults are renderers, generators, solvers, and representations.

FeatureDescription
generatorsAll 4-connected grid maze generation algorithms
generators-hexAll hexagonal (6-connected) maze generation algorithms
solversAll maze solving algorithms (BFS, DFS, A*, dead-end filling)
renderersAll rendering backends (Unicode + PGM)
representationsStandard 4-connected graph representations
hex-representationsHexagonal maze representations
dungeon-representationsDungeon/cave representations
binary-formatBinary serialization format
json-formatJSON serialization format
file-ioFile I/O combining binary and JSON formats
petgraphpetgraph integration for graph operations
serdeSerde serialization support

Fine-grained sub-flags (e.g. generator-kruskal, solver-bfs) are documented in Cargo.toml and on docs.rs.

§Crate Layout

The preamble module re-exports the most commonly used types. Key modules: generators, solvers, renderers, dungeon, representations, and storage (with file-io).

§Companion Crates

  • amaze-cli — command-line interface for generating and rendering mazes.
  • amaze-gui — graphical user interface with live preview.

§License

Licensed under EUPL-1.2 OR MIT OR Apache-2.0.

Modules§

direction4
direction6
dungeon
Procedural dungeon generation and representation.
generators
Maze generation algorithms for rectangular 4-connected grids.
path
preamble
renderers
representations
room4
room4_list
solvers
Maze solving algorithms for Wall4Grid.
stats