Generational Loop & Biophysical Mechanics
At the heart of Evolution is EvoTurnEngine.advance_generation(state, lang), which advances the simulation by one discrete generation (half-year seasonal step: year = generation / 2 + 1). Every generation executes a strictly ordered 5-stage pipeline under the 1-Deme-Per-Hex Exclusivity invariant (cell.deme_ids.size() <= 1), resolving each settlement's concrete chosen action (deme.chosen_action) through deterministic ecological, diplomatic, military, and demographic laws (EvoPayoffs).
High-Level Execution Pipeline
sequenceDiagram
participant Main as EvoMainController
participant Turn as EvoTurnEngine
participant Env as 1. EvoEnvPhase
participant Bio as 2. EvoBiophysPhase
participant Mile as 3. EvoMilestonePhase
participant Cog as 4. EvoDecisionModel
Main->>Turn: advance_generation(world_state, lang)
Turn->>Env: run_environmental_phase(state, lang)
Note over Env: Increment gen, flip season,<br/>glacial sea cycle, flood/emerge,<br/>regenerate K & R, +15 mana
Turn->>Bio: run_biophysical_phase(state, lang)
Note over Bio: 2A. EvoRuralHinterland.sync_claims + EvoRelations.tick<br/>2B. EvoEconomyPhase: Harvest, Hinterlands, Fortify, Innovate, K Degrade<br/>2C. EvoDiplomacyPhase: Trade, Aid, Pacts, Tribute & Ultimatums<br/>2D. EvoConflictPhase: Betrayals, Plunder Raids & Wars of Conquest<br/>2E. EvoSettlementPhase: Unification, Settling, Salubrity, Growth & Extinction
Turn->>Mile: run_milestone_phase(state, lang)
Note over Mile: Synthesize top milestone trait<br/>(Speciation > Baldwin > Innovation),<br/>check Macro-Outcomes
Turn->>Cog: evaluate_all_demes + sync_and_enqueue_batch
Note over Cog: Build next turn's action menu & forecasts,<br/>enqueue per-settlement /v1/systemone jobs
Turn-->>Main: Return { generation, new_entries, has_milestone, has_macro_outcome }
Stage 1: Environmental Phase (EvoEnvPhase)
- Increments
state.generation += 1, clearsstate.recent_extinction_hexes, and togglesstate.seasonbetween"wet_warm"(\(\gamma_{\text{season}} = 1.20\)) and"dry_cold"(\(\gamma_{\text{season}} = 0.75\)). - Ages existing severed roads in
state.disused_connections(age += 1, pruning links withage > 4) and clearsstate.active_flows. - Applies glacial sea-level cycles (every 8 generations), coastal flooding/emergence, submerged settlement relocation to adjacent empty passable hexes (
10%transit loss,20%reserve penalty,"migration"flow) or drowning ("extinction"), passive carrying capacity \(K\) recovery (+5%normal or+0.5%after a Tragedy of the Commons), and seasonal biomass \(R\) regeneration. - Regenerates player Selective Pressure ("Mana") points (
+15per generation).
Stage 2: Biophysical & Social Resolution (EvoBiophysPhase)
2A. Rural Hinterland Sync & Relation Aging (EvoRuralHinterland.sync_claims & EvoRelations.tick)
- Tier Hinterland Quotas (
RURAL_QUOTA = [0, 0, 1, 2, 4]): Tier II–IV settlements automatically claim up to1,2, or4adjacent uninhabited passable hexes (altitude <= 0.85), converting arid/tundra hexes into"pasture"(pasture_pen+granary) and fertile hexes into"crops"(crop_field+windmill). - Relation & Ultimatum Lifecycle (
EvoRelations.tick): - If a neighbor issued a
demand_tributeultimatum on the previous turn and the target settlement did not choosepay_tributethis turn,EvoRelations._refuse_tributeimmediately resolves a punitive enforcement raid against the refuser. - Increments active alliance pacts (
pact_turns += 1), decrements active feuds (feud_turns -= 1) and truces (truce_turns -= 1), decays bilateral trust slightly toward0, and transitions any inactive friendly road from the previous turn intostate.disused_connections(age = 1).
2B. Domestic Economy (EvoEconomyPhase.resolve)
- Wild + Rural Harvest (
EvoPayoffs.expected_income): - Each settlement harvests wild food from its host hex (scaled by extraction efficiency, urban foraging factor
[1.0, 1.0, 1.0, 0.55, 0.30],+10%ifforage, or+35%ifintensify), plusmin(R_rural, 0.35 * pop) * 0.70from each owned rural hinterland hex, multiplied by1.12x(+12%) if the settlement has at least one active alliance pact. - Carrying Capacity (\(K\)) Degradation vs. Conservation:
- Choosing
intensifypermanently degrades host hex carrying capacity \(K\) by-7%(INTENSIFY_K_DROP = 0.07). Dropping below \(60\%\) of \(K_{\max}\) triggers a Tragedy of the Commons ("tragedy_of_commons"), cutting natural \(K\) recovery tenfold. - Choosing
foragewith positive ecological impact (cul-communal-conservation) gently enriches \(K\) toward \(K_{\max}\). - Perimeter Fortifications (
fortify) & Innovation (innovate): fortify: Spends[22, 40, 60]food reserves (with a15%discount forcul-communal-conservationorbio-k-strategy) to upgradedefense_tier(Lv.1 Palisade+35%defense /30%loot shield \(\to\)Lv.2 Stone Wall+75%defense /60%loot shield \(\to\)Lv.3 Castle+130%defense /80%loot shield).innovate: Advancesinnovation_counterbyEvoPayoffs.innovation_step(deme, state)(0.38base, up to0.58withbio-encephalizationandcul-fire-processing).
2C. Diplomacy & Exchange (EvoDiplomacyPhase.resolve)
- Trade (
trade): - Mutual Trade (both neighbors target each other with
trade): Both earn100%ofEvoPayoffs.trade_gain(18%base +10%complementary biome +7%distinct culture, up to+35%of harvest),+0.20bilateral trust, and bilateral horizontal cultural diffusion ("symbiosis"). - Unilateral Trade Caravan: The initiator earns
55%oftrade_gain(EvoPayoffs.unreciprocated_trade_gain), its partner earns25%, bilateral trust rises by+0.12, and cultural knowledge diffuses across the border. - Surplus Aid (
aid): Transfersclamp(0.18 * reserves, 10, 32)food to the target neighbor, boosting bilateral trust by+0.25, global reputation by+0.10, and automatically sealing any pending alliance offer. - Alliance Pacts (
offer_pact,accept_pact): accept_pact(or mutualoffer_pact, oroffer_pacttoward same-lineage kin or a neighbor withtrust >= 0.30) immediately seals a formal alliance (pact_turns = 1,trust +0.25,"pact"flow and Chronicle entry). Otherwise,offer_pactregisters an open proposal (proposal_kind = "pact") for the target's next turn.- Tribute Coercion (
demand_tribute,pay_tribute): demand_tributeissues an explicit ultimatum (proposal_kind = "tribute",proposal_amount = clamp(0.22 * target.reserves, 10, 38)).- Choosing
pay_tributetransfers the demanded food with zero casualties and buys a 2-turn truce (truce_turns = 2).
2D. Conflict, Betrayal & Conquest (EvoConflictPhase.resolve)
- Opportunistic Betrayal (
betray): - Breaks an active alliance (
pact_turns = 0,feud_turns = 4), inflicts-0.50global reputation and-0.70bilateral trust, and launches a surprise attack (+35%combat power, halves defender wall bonus,+25%loot bonus). - Plunder Raids (
raid) & Hinterland Pillaging (has_ruins = true): - Resolves stochastic combat via
EvoPayoffs.raid_odds(att, def, state, false). On attacker victory, steals reserves (mitigated by defenderWALL_LOOT_SHIELD), inflicts casualties, and pillages one owned rural hinterland hex (+18.0extra food, resetsowner_deme_id = "",land_use = "wild", and markshas_ruins = true). On defender victory, logs a repelled"siege". - Wars of Conquest (
conquer): - Dispatches
45%of the attacker's population (warband) to seize the target hex (EvoPayoffs.conquest_odds). - Attacker Victory: Captures
50%of defender reserves and seizes the hex. If the surviving defender (population >= 10) has an adjacent empty passable hex, it retreats there; otherwise it is absorbed in place (1/3assimilated), preservingcell.deme_ids.size() <= 1. A new warband settlement (<base_id>-w<gen>) occupies the conquered hex and inherits adjacent rural hinterlands up to its tier quota.
2E. Unification, Frontier Settling & Demography (EvoSettlementPhase.resolve)
- Unification (
unite/accept_union): - When two allied towns (
pact_turns >= 3, bothtier >= 2) unite viaaccept_unionor mutualunite:- Same-Tier Cities (
tier_a == tier_b >= 2): Form a Continuous Multi-Hex Walled Union (walled_union_id = "union-<a>-<b>", max 3 hexes), upgradingdefense_tier >= 1, culling their shared internal perimeter wall, linking plazas via a golden"merge"boulevard, and pooling+55%population and+25%wall bonus in combat. - Different-Tier Towns (
tier_a != tier_b): The lower-tier settlement merges into the higher-tier host city (Asymmetric Category Absorption), expanding host \(K\) by+35and converting the vacated hex into a cultivated rural hinterland ("crops"or"pasture").
- Same-Tier Cities (
- Frontier Colonization (
settle): - Sends
35%of the parent settlement's population (min 24, requiringpopulation >= 80) and proportional food reserves to found a new daughter camp (<base_id>-m<gen>) on the chosen empty passable hex. - Metabolism, Urban Salubrity (
salubrity), Growth & Epidemics ("epidemic"): - Deducts metabolic food need (
EvoPayoffs.food_need, including wall upkeep[0, 1.5, 3.0, 5.0]), updatessalubrity, applies demographic growth/decline (r/Klife-history modifiers), triggers Urban Epidemics (22%mortality) whensalubrity < 0.35andpopulation >= 130, and records any extinction (population < 10, leaving stone ruinshas_ruins = true).
Stage 3 & 4: Milestones (EvoMilestonePhase) & Next-Turn Agency (EvoDecisionModel)
- Stage 3 (
EvoMilestonePhase.run_milestone_phase): Synthesizes at most one emergent evolutionary trait per turn globally (Allopatric Speciation \(\to\) Baldwin Effect \(\to\) Cultural Innovation) and checks global macro-outcomes (total_extinction,single_survivor,ecological_equilibrium). - Stage 4 (
EvoDecisionModel.evaluate_all_demes&sync_and_enqueue_batch): Applies completed live Ollama/v1/systemoneresults for every surviving settlement and enqueues the next turn's per-settlement action menus on the background worker pool.