Expand description
§TerrainForge
A modular procedural generation engine for terrain, dungeons, and maps.
§Quick Start
use terrain_forge::{Grid, Tile, algorithms};
let mut grid = Grid::new(80, 60);
let algo = algorithms::get("bsp").unwrap();
algo.generate(&mut grid, 12345);
println!("Generated {} floor tiles", grid.count(|t| t.is_floor()));§Semantic Generation
Generate maps with entity spawn markers and region metadata:
use terrain_forge::{algorithms, generate_with_semantic};
let result = generate_with_semantic("room_accretion", 80, 60, 12345);
if let Some(semantic) = result.semantic {
println!("Generated {} regions with {} markers",
semantic.regions.len(), semantic.markers.len());
}§Algorithms
14 generation algorithms available via algorithms::get:
bsp- Binary Space Partitioning for structured roomscellular- Cellular automata for organic cavesdrunkard- Random walk for winding corridorsmaze- Perfect maze generationrooms- Simple rectangular roomsvoronoi- Voronoi-based regionsdla- Diffusion-limited aggregationwfc- Wave Function Collapsepercolation- Connected cluster generationdiamond_square- Heightmap terrainfractal- Fractal noise terrainagent- Multi-agent carvingglass_seam- Region connectorroom_accretion- Brogue-style organic dungeons
§Composition
Chain algorithms with compose::Pipeline or layer with compose::LayeredGenerator:
use terrain_forge::{Grid, Tile, Algorithm, algorithms};
use terrain_forge::compose::Pipeline;
let mut grid = Grid::new(80, 60);
let pipeline = Pipeline::new()
.add(algorithms::get("rooms").unwrap())
.add(algorithms::get("cellular").unwrap());
pipeline.generate(&mut grid, 12345);§Effects
Post-process with effects: morphology, connectivity, filters, transforms.
§Noise
noise module provides Perlin, Simplex, Value, Worley with FBM and modifiers.
Modules§
- algorithms
- Procedural generation algorithms
- compose
- Composition system for chaining and layering algorithms
- constraints
- Constraint validation
- effects
- Effects and transforms for post-processing generated maps
- noise
- Noise generation module with composable generators and modifiers
Structs§
- Connectivity
Graph - Region connectivity information
- Generation
Result - Extended generation result with semantic information
- Grid
- 2D grid of cells
- Marker
- A spawn marker for entity placement
- Masks
- Spatial masks for gameplay logic
- Region
- A distinct region within the generated map
- Rng
- Seeded RNG wrapper for deterministic generation
- Semantic
Layers - Complete semantic information for a generated map
Enums§
- Tile
- Basic tile type for dungeon/terrain generation
Traits§
- Algorithm
- Trait for procedural generation algorithms
- Cell
- Trait for grid cells
- Semantic
Generator - Trait for algorithms that can generate semantic information
Functions§
- generate_
with_ semantic - Generate a map with semantic layers if the algorithm supports it