feat(simulation): generation pipeline Rust types + SystemNameIndex (#900, #912-#926)

WorldTier enum fixed to Epicenter/Regional/Backwater/Passage/Waypoint
(D-218). Full enum implementations for ComplexityTier, SettingType,
SettlementClass, DistrictType, PoliticalArchetype, FoundingOrientation,
TerritorialStatus, GeographicAttractor, AttractorType, and
CompatibilityMatrix. SystemNameIndex with Aho-Corasick text scanning
for background pre-generation queue integration (D-206).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-02 18:40:44 +02:00
co-authored by Claude Opus 4.6
parent b6ca785f74
commit ca9ab189e0
5 changed files with 413 additions and 7 deletions
+152 -7
View File
@@ -100,15 +100,19 @@ pub type PlacedObject = String;
/// Network importance of a world in the galaxy.
/// Determines simulation fidelity budget and NPC complexity ceiling.
///
/// Source: tyre-round4.md §2.1, workshop-outcomes.md
/// Source: D-218, workshop-outcomes.md
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum WorldTier {
/// Background system — minimal simulation, sparse NPCs. Pure environmental.
Peripheral,
/// Standard Settled Reach system — full simulation, complex social sites.
Connected,
/// Major hub — maximum fidelity, multi-faction politics, all triangle types.
Core,
/// Hub system. Full simulation, high faction pressure.
Epicenter,
/// Regional system. 1–4 districts, partial full-budget simulation.
Regional,
/// Small community. 1 district. Network-insignificant, NOT budget-capped.
Backwater,
/// Transit stop. Pass-through node. Moderate complexity ceiling.
Passage,
/// Not simulated until player approaches. Minimal complexity ceiling.
Waypoint,
}
/// Generator content budget for a district.
@@ -288,6 +292,147 @@ pub enum EraCause {
CulturalShift,
}
// ---------------------------------------------------------------------------
// Settlement classification enums (D-196, D-212, D-213, D-214, D-215)
// ---------------------------------------------------------------------------
/// How a settlement enters and exits active simulation.
/// Controls whether generation runs, and at what complexity level.
/// Source: D-196
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub enum SettlementClass {
/// Named in wiki; always active regardless of population threshold.
NameLocked,
/// Active if pop ≥ 50_000; ghost stub if pop < 5_000.
PopulationBudget,
/// Active only while the triggering economic condition holds.
EconomicTriggered,
/// Emergent settlement not in atlas at generation time; written during simulation.
OrganicGrowth,
}
/// Dominant power structure of a settlement and its physical spatial expression.
/// Derived from TerritorialStatus + economic_role at generation time.
/// Source: D-214
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub enum PoliticalArchetype {
/// Top-down Commission planning; rectilinear, institutional core, radial-core arrangement.
Commission,
/// Corp-dominated; commercial density, restricted campus blocks, restricted-perimeter adjacent.
Corporate,
/// Self-organized; organic growth, mixed use, ribbon arrangement.
Pioneer,
/// Garrison or fortification origin; defensible geometry, fortified-perimeter arrangement.
Military,
/// University or research origin; campus-quad structure, green space, radial-core arrangement.
Academic,
/// Factory-first; large-footprint industrial blocks, worker residential rings, ribbon arrangement.
Industrial,
}
/// Primary spatial axis of a city's original street grid.
/// Derived from the matched attractor type (D-211). Controls district grid rotation.
/// Source: D-213
#[derive(Serialize, Deserialize, Clone, Debug)]
pub enum FoundingOrientation {
/// Street grid perpendicular to coastline. `facing_degrees`: compass bearing toward water (0–359).
Coastal { facing_degrees: u16 },
/// Street grid parallel to founding river. `bearing_degrees`: river flow direction (0–359).
RiverAligned { bearing_degrees: u16 },
/// Grid rotated to follow local contours (valley floor settlements).
TerrainFollowing,
/// Grid aligned to cardinal N/S/E/W (Commission-planned settlements on flat terrain).
Cardinal,
/// Arbitrary bearing (pioneer settlements on open terrain). `bearing_degrees`: 0–359.
Free { bearing_degrees: u16 },
}
/// Territory control status for a province (drainage basin). Priority-ordered derivation.
/// Source: D-212
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub enum TerritorialStatus {
/// Commission faction_influence ≥ 0.6 in this province.
CommissionControlled,
/// Single corporation faction_influence ≥ 0.5.
CorpTerritory,
/// Two or more factions each ≥ 0.3; no dominant faction.
ContestedZone,
/// No faction with influence ≥ 0.2.
FrontierUnclaimed,
/// Cultural corridor has indigenous autonomy flag.
IndigenousHeld,
/// Population density < 0.01 AND no faction ≥ 0.1.
Derelict,
}
// ---------------------------------------------------------------------------
// Attractor types for settlement placement (D-195, D-209, D-211)
// ---------------------------------------------------------------------------
/// The type of terrain feature that attracts settlement placement.
/// Source: D-195, D-209
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub enum AttractorType {
/// Where a river meets sea level or coastline. Historically high-value.
RiverMouth,
/// Proximity to coast without a river mouth. Port access.
CoastalAccess,
/// Where a river crosses a topographic saddle or confluence point.
RiverCrossing,
/// Local elevation minimum; flat, arable, sheltered.
ValleyFloor,
/// Saddle point between adjacent drainage basins; controls a mountain pass.
PassEntrance,
/// Adjacent to a lake polygon.
LakeShore,
/// Flat terrain away from all other attractors; fallback for plains settlements.
PlainCenter,
}
/// A terrain feature at a specific map position that influences city placement scoring.
/// Source: D-195, D-209
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct GeographicAttractor {
/// Pixel position in heightmap space [row, col].
pub position: (u16, u16),
pub attractor_type: AttractorType,
/// Normalized strength 0.0–1.0. Derived from flow accumulation or habitability score.
pub strength: f32,
}
/// Compatibility weights between economic roles and attractor types.
/// A 10×7 matrix (10 economic_role values × 7 AttractorType variants).
/// Each cell is a weight multiplier 0.0–3.0 applied during attractor-matching scoring.
/// Source: D-195
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct CompatibilityMatrix {
/// Row order: manufacturing, financial, agricultural, extraction, service_mixed,
/// institutional, transit_hub, research, military, residential.
/// Column order: RiverMouth, CoastalAccess, RiverCrossing, ValleyFloor,
/// PassEntrance, LakeShore, PlainCenter.
pub weights: [[f32; 7]; 10],
}
/// Data contract between build-time (systems.db) and the runtime-background
/// generation tier. Populated from atlas_city_names + bodies at generation
/// dispatch time. All 8 fields are required before a generation task may run.
/// Source: D-200, D-199
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct CityGenerationContext {
/// Foreign key into atlas_city_names.id
pub city_id: u64,
pub political_archetype: PoliticalArchetype,
/// Starting economic health seed (0.0–1.0). Derived per D-197.
pub prosperity_baseline: f32,
pub surrounding_biome: SettingType,
/// Compass octants (0=N, 1=NE … 7=NW) where roads enter the city footprint.
pub road_entry_directions: Vec<u8>,
/// City footprint radius in km. Derived from body_radius_km (D-204) + population.
pub footprint_radius_km: f32,
pub founding_orientation: FoundingOrientation,
pub world_tier: WorldTier,
}
// ---------------------------------------------------------------------------
// Supporting structs
// ---------------------------------------------------------------------------