Crate terrain_forge

Crate terrain_forge 

Source
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 rooms
  • cellular - Cellular automata for organic caves
  • drunkard - Random walk for 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 noise terrain
  • agent - Multi-agent carving
  • glass_seam - Region connector
  • room_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§

ConnectivityGraph
Region connectivity information
GenerationResult
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
SemanticLayers
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
SemanticGenerator
Trait for algorithms that can generate semantic information

Functions§

generate_with_semantic
Generate a map with semantic layers if the algorithm supports it