Skip to content

Living World Architecture & Entity Hierarchy ​

This deep dive documents how an entire Elthoria living world is structured in elthoria-world-simulation-model and orchestrated by elthoria-world-simulation-engine — covering the entity hierarchy from continental macro state down to nested scene props, how numeric mechanics and open-schema narrative state stay synchronized, and how downward and upward propagation couple every layer.

TIP

Looking for the plain-English Game Master overview? Read How an Elthoria World Works. Want to see how this entire world state is projected and bounded for an LLM context window? Read World State as Presented to an LLM.


End-to-End World Entity Hierarchy ​

Every living world is stored as a single deterministic WorldSimState document (simConfigVersion: "elthoria_world_sim_v1") whose entities reference each other exclusively by stable string IDs (never object graphs or JPA foreign keys):

text
WorldSimState (seed, week, season, scaleMode, mapAttributes, tacticalMapAttributes)
│
├── MacroWorldState (continental pressures, activeWars, KingdomEconomy [12 goods])
│    └── PolityState (kingdom stability, legitimacy, treasury, debt, collapseState)
│         ├── SimRegion (hexCoordinates, climate, harvests, supply/prices, unrest)
│         │    ├── SimSettlement (10 types, hexCoordinate, law/order, markets, guilds)
│         │    │    └── LocationState (nested parent/child scene rooms + attributes)
│         │    │         └── EntityState (8 physical kinds: Fixture..Sign, condition)
│         │    └── SimFaction territoryRegionIds
│         ├── SimFaction (headAgentId, power/wealth/influence, morale, corruption,
│         │               policyDrift, partyPerception, collapseState, OpenSchemaProfile)
│         │    └── FactionRelation (directed tension/trust/cooperation between factions)
│         └── SimHouse (noble houses + party base: wealth, debt, scandal, covertScheme,
│                       collapseState, OpenSchemaProfile, HiddenTracker)
│
├── SimAgent (party focal agent + Tier A/B/C NPCs — see Persistent NPCs Deep Dive)
│    ├── RelationshipVector (8-axis directed social graph + RelationshipProvenance)
│    ├── Rumor & RumorBelief (subjective-logic SimOpinion per agent × rumor)
│    └── IntrigueSecret & SecretKnowledge (holders, stakes, suspicion, leaks)
│
├── SimLoreObject (Artifact | Deity | Culture | Object — holderId + claimantIds)
├── GlobalWorldState (open-schema prose dimensions G^{(t)} + bounded changeLog)
└── SceneTrajectory (rolling played Scene window + TrajectoryMetrics)

Layer-by-Layer Entity Reference ​

1. Macro Layer (MacroWorldState, PolityState, KingdomEconomy, WarState) ​

All continuous macro quantities live in [0, 1]:

  • MacroWorldState:
    • Continental pressures: continentStability, warPrevalence, faminePressure, plaguePressure, refugeePressure, magicCatastrophePressure, tradeConnectivity.
    • Collections: polities (Map<String, PolityState>), activeWars (Map<String, WarState>), kingdomEconomy (KingdomEconomy).
  • KingdomEconomy (12 canonical SimKeys.GOODS):
    • Tracks supply/scarcity/price signals across: grain, livestock, fish, timber, iron, silver, stone, cloth, medicine, manaCrystals, luxuryGoods, books.
  • PolityState:
    • Political & fiscal indicators: stability, legitimacy, treasury, debt, foodStockpile, militaryStrength, administrativeCapacity, corruption, nobleLoyalty, commonerSupport, templeSupport, successionPressure, warExhaustion, collapseRisk, and optional CollapseState.

2. Spatial & Physical Layer (SimRegion, SimSettlement, LocationState, EntityState) ​

EntityGranularitySpatial bindingKey evolving fields
SimRegionProvince / biomehexCoordinates (List<String> of "x,y"), sourceRegionId, polityId, controllingFactionIdterrainType, climate, population, harvestQuality, devastation, grainSupply/grainPrice, luxurySupply/luxuryPrice, medicineSupply/medicinePrice, lawOrder, safety, localUnrest, localFear, localGossipHeat, refugeeFlow, provinceHead
SimSettlementTown / wardregionId, hexCoordinate ("x,y")type (Village, MarketTown, PortCity, FortressTown, TempleTown, AcademyDistrict, MiningTown, CapitalWard, MageEnclave, FrontierHamlet), productionSpecialties, populationShare, developmentLevel, modernityLevel, productivity, marketAccess, roadAccess, transportCapacity, rawMaterialAccess, educationAccess, literacyRate, guildPresence, templePresence, mageInfrastructure, security, lawOrder, sanitation, costOfLiving, wageLevel, unrestRisk
LocationStateScene room / siteregionId, settlementId, hexCoordinate, nested parentLocationId / childLocationIdsProse description, open-schema attributes (lighting, crowding, access), entities (Map<String, EntityState>), bounded changeLog (last 24 LocationChange records)
EntityStatePhysical prop / featureOwned by LocationState.entitieskind (Fixture, Prop, Hazard, Resource, Threshold, Vehicle, Remains, Sign), prose state, condition (1.0 pristine → 0.0 destroyed), visible, tags, lastChangedWeek, lastChangedSceneId

3. Institutional Layer (SimFaction, FactionRelation, SimHouse) ​

  • SimFaction:
    • Linked via sourceFactionOrganizationId (campaign DB), headAgentId, polityId, parentFactionId, territoryRegionIds.
    • Types include government, royal_court, temple, military, merchant_guild, guild, province_government, noble_house, academy, criminal_network, mage_tower, spy_network, creditor_circle, foreign_embassy.
    • Numeric vectors: power, wealth, influence, legitimacy, publicSupport, informationNetwork, desperation, opportunity, agendaVector, MoraleProfile, PolicyDrift, CorruptionProfile, PartyPerception, CollapseState.
    • Narrative counterpart: OpenSchemaProfile + HiddenTracker evolved by GroupEvolutionSystem off what the faction's members actually did in scenes.
  • SimHouse:
    • Models noble houses, notable households, and the party's own base (party.partyHouseId).
    • Fields: factionId, regionId, headAgentId, primarySettlementId, memberAgentIds, wealth, debt, status, courtAccess, estateSecurity, scandalExposure, servantLoyalty, foodReserve, marriagePressure, militaryObligation, covertSchemeProgress, covertSchemeTargetId, CollapseState, plus OpenSchemaProfile + HiddenTracker.

4. Cultural, Epistemic & Dynamic Layer (SimLoreObject, Rumor, IntrigueSecret, PressurePacket, DelayedConsequence) ​

  • SimLoreObject: Anchors abstract world elements (ontologyType: Artifact | Deity | Culture | Object) with holderId and claimantIds so relics and religious claims participate in intrigue graphs and WorldFact reasoning.
  • Dynamic change primitives: InboundWorldEvent (two-phase immediate + weekly reaction), PressurePacket (13 pressure sources), ObservableIncident (visibility-gated Direct | Report | SecondhandRumor | Trace | DistantTrace | Hidden), DelayedConsequence (correlated into compound crises via correlationKey), Rumor + RumorBelief (SimOpinion), and IntrigueSecret + SecretKnowledge.

Bidirectional Propagation: How Layers Drive Each Other ​

Every weekly tick in WorldSimEngine.simulateWeek(state, action) runs two coupled propagation directions (plus two collapse evaluations — pre-propagation and late-tick):

text
  DOWNWARD PROPAGATION (Macro → Meso → Micro)
  ───────────────────────────────────────────
  MacroWorldSystem / EconomySystem / FactionSystem / CollapseSystem (pass 1)
    ──► PropagationSystem.applyDownwardPropagation(state)
        • War, famine, debt & commodity scarcity raise regional devastation,
          grain prices, localUnrest, and localFear.
        • Regional unrest & house debt push PressurePackets onto factions,
          houses, and individual NPCs' needs (security, wealth, stress).
        • PressureSystem synthesizes CharacterSituations & opens NPC goals.

  UPWARD PROPAGATION (Micro → Meso → Macro)
  ─────────────────────────────────────────
  PartyAction / Travel / NPC Planning / Incidents / Rumors / TMS / Graph Reasoning
    ──► PropagationSystem.applyUpwardEventPropagation(state)
    ──► RelationshipSystem.updateRelationshipsAndReputation(state)
    ──► MacroWorldSystem.applyMacroFeedback(state, rng)
    ──► CollapseSystem.evaluateCollapseStates(state) (pass 2)
        • Scandal, assassination, sabotage, or faction betrayal shifts house
          scandalExposure, faction morale/legitimacy, and FactionRelation tension.
        • Sustained local fallout feeds back into polity stability, collapseRisk,
          warPrevalence, and tradeConnectivity.

Numeric Mechanics vs. Open-Schema EvolvingWorld Co-Evolution ​

Elthoria intentionally separates quantitative simulation state from open-schema narrative state so neither corrupts the other:

  • Numeric vectors stay authoritative for mechanics: Collapse, war, economy, policy solvers, and Bayesian/PSL reasoning read the fixed [0, 1] fields on PolityState, SimRegion, SimFaction, SimHouse, and SimAgent.
  • Open-schema profiles stay authoritative for narrative texture: GlobalWorldState, LocationState, SimFaction.profile, SimHouse.profile, and SimAgent.profile carry genre-adaptive OpenSchemaDimension prose entries updated after scenes by SceneDirector (CharacterEvolutionSystem, GroupEvolutionSystem, PlaceEvolutionSystem, WorldStateUpdateSystem) via EvidencePromoter.

Seeding vs. Blank-Canvas Worlds ​

A world simulation can be created in two modes via create_world_sim:

  1. Seeded world (blank_canvas: false): Deterministically projects polities, regions, settlements, factions, houses, initial agents, lore objects, and map attributes from the supplied seed and linked campaign/hex map (preview_world_sim_seed inspects the projection without persisting).
  2. Blank-canvas world (blank_canvas: true): Initializes an empty WorldSimState shell (elthoria_world_sim_v1) so GMs or authoring tools can add regions, factions, settlements, NPCs, and relics incrementally via add_world_entity and register_npc_agent.

Built on the upstream Kompile harness. Released under the MIT License.