1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
//! # TerrainForge
//!
//! A modular procedural generation engine for terrain, dungeons, and maps.
//!
//! ## Quick Start
//!
//! ```rust
//! use terrain_forge::{Grid, ops};
//!
//! let mut grid = Grid::new(80, 60);
//! ops::generate("bsp", &mut grid, Some(12345), None).unwrap();
//!
//! println!("Generated {} floor tiles", grid.count(|t| t.is_floor()));
//! ```
//!
//! ## Quick Start (Direct Instantiation)
//!
//! ```rust
//! use terrain_forge::{Algorithm, Grid};
//! use terrain_forge::algorithms::{Bsp, BspConfig};
//!
//! let mut grid = Grid::new(80, 60);
//! let bsp = Bsp::new(BspConfig {
//! min_room_size: 6,
//! max_depth: 5,
//! room_padding: 1,
//! });
//! bsp.generate(&mut grid, 12345);
//! ```
//!
//! ## Semantic Extraction
//!
//! Extract semantic information from any generated map:
//!
//! ```rust
//! use terrain_forge::{algorithms, SemanticExtractor, Grid, Rng};
//!
//! // 1. Generate map using any method
//! let mut grid = Grid::new(80, 60);
//! algorithms::get("cellular").unwrap().generate(&mut grid, 12345);
//!
//! // 2. Extract semantic information
//! let extractor = SemanticExtractor::for_caves();
//! let mut rng = Rng::new(12345);
//! let semantic = extractor.extract(&grid, &mut rng);
//!
//! // Works with any grid source - pipelines, external tools, etc.
//! ```
//!
//! ## Algorithms
//!
//! 15 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
//! - `noise_fill` - Noise-driven threshold fill
//! - `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`]:
//!
//! ```rust
//! use terrain_forge::{Grid, Tile};
//! use terrain_forge::pipeline::Pipeline;
//!
//! let mut grid = Grid::new(80, 60);
//! let mut pipeline = Pipeline::new();
//! pipeline.add_algorithm("rooms", None, None);
//! pipeline.add_algorithm("cellular", None, None);
//! pipeline.execute_seed(&mut grid, 12345).unwrap();
//! ```
//!
//! ## Effects
//!
//! Post-process with [`effects`]: morphology, connectivity, filters, transforms.
//!
//! ## Noise
//!
//! [`noise`] module provides Perlin, Simplex, Value, Worley with FBM and modifiers.
pub use Algorithm;
pub use ;
pub use ;
pub use Rng;
pub use ;
pub use ;
pub use ;
/// Generate a map that meets specific semantic requirements
///
/// This function attempts to generate a map that satisfies the given semantic requirements
/// by trying different seeds and validating the results. It provides a simple wrapper
/// around the existing generation system with requirement validation.
///
/// # Arguments
/// * `algorithm_name` - Name of the generation algorithm to use
/// * `width` - Grid width
/// * `height` - Grid height
/// * `requirements` - Semantic requirements that must be met
/// * `max_attempts` - Maximum number of generation attempts (default: 10)
/// * `base_seed` - Base seed for generation attempts
///
/// # Returns
/// * `Ok((grid, semantic))` - Successfully generated map meeting requirements
/// * `Err(String)` - Failed to meet requirements after max attempts
///
/// # Example
/// ```rust
/// use terrain_forge::{generate_with_requirements, semantic::SemanticRequirements};
///
/// let requirements = SemanticRequirements::basic_dungeon();
/// match generate_with_requirements("bsp", 80, 60, requirements, Some(5), 12345) {
/// Ok((grid, semantic)) => println!("Generated valid dungeon!"),
/// Err(msg) => println!("Failed: {}", msg),
/// }
/// ```