TerrainForge
A modular procedural generation engine for terrain, dungeons, and maps in Rust.
Features
- 13 Generation Algorithms: BSP, Cellular Automata, DLA, Drunkard Walk, Maze, Rooms, Voronoi, WFC, Percolation, Diamond Square, Fractal, Agent-based, Glass Seam
- Noise Generation: Perlin, Simplex, Value, Worley with FBM, Ridged, and modifiers
- Effects: Morphology, spatial analysis, filters, connectivity
- Composition: Pipeline chaining and layered generation
- 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 |
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
# Pipeline composition
# Layer composition
# Run config file
# Compare algorithms
# List available algorithms
Documentation
See docs/API.md for full API reference.
License
MIT