terrain_forge/algorithms/
mod.rs

1//! Procedural generation algorithms
2
3mod bsp;
4mod cellular;
5mod drunkard;
6mod maze;
7mod rooms;
8mod voronoi;
9mod dla;
10mod wfc;
11mod percolation;
12mod diamond_square;
13mod prefab;
14mod agent;
15mod fractal;
16mod glass_seam;
17mod room_accretion;
18
19pub use bsp::{Bsp, BspConfig};
20pub use cellular::{CellularAutomata, CellularConfig};
21pub use drunkard::{DrunkardWalk, DrunkardConfig};
22pub use maze::{Maze, MazeConfig};
23pub use rooms::{SimpleRooms, SimpleRoomsConfig};
24pub use voronoi::{Voronoi, VoronoiConfig};
25pub use dla::{Dla, DlaConfig};
26pub use wfc::{Wfc, WfcConfig};
27pub use percolation::{Percolation, PercolationConfig};
28pub use diamond_square::{DiamondSquare, DiamondSquareConfig};
29pub use prefab::{PrefabPlacer, PrefabConfig, Prefab};
30pub use agent::{AgentBased, AgentConfig};
31pub use fractal::Fractal;
32pub use glass_seam::GlassSeam;
33pub use room_accretion::{RoomAccretion, RoomAccretionConfig, RoomTemplate};
34
35use crate::{Algorithm, Tile};
36
37/// Get algorithm by name
38pub fn get(name: &str) -> Option<Box<dyn Algorithm<Tile>>> {
39    match name {
40        "bsp" => Some(Box::new(Bsp::default())),
41        "cellular" | "cellular_automata" => Some(Box::new(CellularAutomata::default())),
42        "drunkard" => Some(Box::new(DrunkardWalk::default())),
43        "maze" => Some(Box::new(Maze::default())),
44        "simple_rooms" | "rooms" => Some(Box::new(SimpleRooms::default())),
45        "voronoi" => Some(Box::new(Voronoi::default())),
46        "dla" => Some(Box::new(Dla::default())),
47        "wfc" | "wave_function_collapse" => Some(Box::new(Wfc::default())),
48        "percolation" => Some(Box::new(Percolation::default())),
49        "diamond_square" => Some(Box::new(DiamondSquare::default())),
50        "agent" => Some(Box::new(AgentBased::default())),
51        "fractal" => Some(Box::new(Fractal)),
52        "glass_seam" | "gsb" => Some(Box::new(GlassSeam::default())),
53        "room_accretion" | "accretion" => Some(Box::new(RoomAccretion::default())),
54        _ => None,
55    }
56}
57
58/// List all available algorithm names
59pub fn list() -> &'static [&'static str] {
60    &[
61        "bsp", "cellular", "drunkard", "maze", "rooms", "voronoi",
62        "dla", "wfc", "percolation", "diamond_square", "agent", 
63        "fractal", "glass_seam", "room_accretion",
64    ]
65}