TerrainForge
A modular procedural generation engine for terrain, dungeons, and maps in Rust.
Features
- 14 Generation Algorithms: BSP, Cellular Automata, DLA, Drunkard Walk, Maze, Rooms, Voronoi, WFC, Percolation, Diamond Square, Fractal, Agent-based, Glass Seam, Room Accretion
- Advanced Connectivity: Region-aware connectors with loop control
- Noise Generation: Perlin, Simplex, Value, Worley with FBM, Ridged, and modifiers
- Effects: Morphology, spatial analysis, filters, connectivity
- Composition: Pipeline chaining and layered generation
- Prefab System: Rotatable prefabs with 90°/180°/270° variants
- Deterministic: Seeded RNG for reproducible results
- Generic: Works with custom cell types via traits
Quick Start
use ;
Installation
[]
= "0.1"
Algorithms
| Algorithm | Description |
|---|---|
bsp |
Binary Space Partitioning - structured rooms |
cellular |
Cellular Automata - organic caves |
drunkard |
Drunkard's Walk - winding corridors |
maze |
Perfect maze generation |
rooms |
Simple rectangular rooms |
voronoi |
Voronoi-based regions |
dla |
Diffusion-Limited Aggregation |
wfc |
Wave Function Collapse |
percolation |
Connected cluster generation |
diamond_square |
Heightmap terrain |
fractal |
Fractal terrain |
agent |
Multi-agent carving |
glass_seam |
Region connector |
room_accretion |
Brogue-style organic dungeons |
agent |
Agent-based carving |
glass_seam |
Connects disconnected regions |
Usage
Registry API
use ;
let mut grid = new;
// Get by name
let algo = get.unwrap;
algo.generate;
// List all
for name in list
Direct Instantiation
use ;
use ;
let config = BspConfig ;
let mut grid = new;
new.generate;
Noise
use ;
let noise = new;
let value = noise.get; // -1.0 to 1.0
let fbm = new;
let layered = fbm.get;
Constraints
use constraints;
let connectivity = validate_connectivity;
let density = validate_density;
let border_ok = validate_border;
Custom Cell Types
use ;
let grid = new;
CLI Tool
The demo framework provides visualization and testing:
# Generate single algorithm
# New: Room accretion (Brogue-style)
# Pipeline composition
# Layer composition
# Run config file
# New: Advanced features
# Compare algorithms
# List available algorithms
New in v0.2.0
- Room Accretion Algorithm: Brogue-style organic dungeon generation with sliding room placement
- Advanced Connectivity:
connect_regions_spanning()with loop control for better dungeon flow - Prefab Rotation: 90°/180°/270° rotation support for prefabs
- Public Region Analysis:
label_regions()for custom connectivity logic
Documentation
See docs/API.md for full API reference. See docs/ROGUELIKE_GENERATION_ANALYSIS.md for advanced techniques.
License
MIT