terrain_forge/algorithms/
mod.rs

1//! Procedural generation algorithms
2
3mod agent;
4mod bsp;
5mod cellular;
6mod diamond_square;
7mod dla;
8mod drunkard;
9mod fractal;
10mod glass_seam;
11mod maze;
12mod percolation;
13mod prefab;
14mod room_accretion;
15mod rooms;
16mod voronoi;
17mod wfc;
18
19pub use agent::{AgentBased, AgentConfig};
20pub use bsp::{Bsp, BspConfig};
21pub use cellular::{CellularAutomata, CellularConfig};
22pub use diamond_square::{DiamondSquare, DiamondSquareConfig};
23pub use dla::{Dla, DlaConfig};
24pub use drunkard::{DrunkardConfig, DrunkardWalk};
25pub use fractal::Fractal;
26pub use glass_seam::GlassSeam;
27pub use maze::{Maze, MazeConfig};
28pub use percolation::{Percolation, PercolationConfig};
29pub use prefab::{Prefab, PrefabConfig, PrefabPlacer};
30pub use room_accretion::{RoomAccretion, RoomAccretionConfig, RoomTemplate};
31pub use rooms::{SimpleRooms, SimpleRoomsConfig};
32pub use voronoi::{Voronoi, VoronoiConfig};
33pub use wfc::{Wfc, WfcConfig};
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",
62        "cellular",
63        "drunkard",
64        "maze",
65        "rooms",
66        "voronoi",
67        "dla",
68        "wfc",
69        "percolation",
70        "diamond_square",
71        "agent",
72        "fractal",
73        "glass_seam",
74        "room_accretion",
75    ]
76}