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):
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).
- Continental pressures:
KingdomEconomy(12 canonicalSimKeys.GOODS):- Tracks supply/scarcity/price signals across:
grain,livestock,fish,timber,iron,silver,stone,cloth,medicine,manaCrystals,luxuryGoods,books.
- Tracks supply/scarcity/price signals across:
PolityState:- Political & fiscal indicators:
stability,legitimacy,treasury,debt,foodStockpile,militaryStrength,administrativeCapacity,corruption,nobleLoyalty,commonerSupport,templeSupport,successionPressure,warExhaustion,collapseRisk, and optionalCollapseState.
- Political & fiscal indicators:
2. Spatial & Physical Layer (SimRegion, SimSettlement, LocationState, EntityState)
| Entity | Granularity | Spatial binding | Key evolving fields |
|---|---|---|---|
SimRegion | Province / biome | hexCoordinates (List<String> of "x,y"), sourceRegionId, polityId, controllingFactionId | terrainType, climate, population, harvestQuality, devastation, grainSupply/grainPrice, luxurySupply/luxuryPrice, medicineSupply/medicinePrice, lawOrder, safety, localUnrest, localFear, localGossipHeat, refugeeFlow, provinceHead |
SimSettlement | Town / ward | regionId, 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 |
LocationState | Scene room / site | regionId, settlementId, hexCoordinate, nested parentLocationId / childLocationIds | Prose description, open-schema attributes (lighting, crowding, access), entities (Map<String, EntityState>), bounded changeLog (last 24 LocationChange records) |
EntityState | Physical prop / feature | Owned by LocationState.entities | kind (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+HiddenTrackerevolved byGroupEvolutionSystemoff what the faction's members actually did in scenes.
- Linked via
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, plusOpenSchemaProfile+HiddenTracker.
- Models noble houses, notable households, and the party's own base (
4. Cultural, Epistemic & Dynamic Layer (SimLoreObject, Rumor, IntrigueSecret, PressurePacket, DelayedConsequence)
SimLoreObject: Anchors abstract world elements (ontologyType:Artifact | Deity | Culture | Object) withholderIdandclaimantIdsso relics and religious claims participate in intrigue graphs andWorldFactreasoning.- Dynamic change primitives:
InboundWorldEvent(two-phase immediate + weekly reaction),PressurePacket(13 pressure sources),ObservableIncident(visibility-gatedDirect | Report | SecondhandRumor | Trace | DistantTrace | Hidden),DelayedConsequence(correlated into compound crises viacorrelationKey),Rumor+RumorBelief(SimOpinion), andIntrigueSecret+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):
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 onPolityState,SimRegion,SimFaction,SimHouse, andSimAgent. - Open-schema profiles stay authoritative for narrative texture:
GlobalWorldState,LocationState,SimFaction.profile,SimHouse.profile, andSimAgent.profilecarry genre-adaptiveOpenSchemaDimensionprose entries updated after scenes bySceneDirector(CharacterEvolutionSystem,GroupEvolutionSystem,PlaceEvolutionSystem,WorldStateUpdateSystem) viaEvidencePromoter.
Seeding vs. Blank-Canvas Worlds
A world simulation can be created in two modes via create_world_sim:
- Seeded world (
blank_canvas: false): Deterministically projects polities, regions, settlements, factions, houses, initial agents, lore objects, and map attributes from the suppliedseedand linked campaign/hex map (preview_world_sim_seedinspects the projection without persisting). - Blank-canvas world (
blank_canvas: true): Initializes an emptyWorldSimStateshell (elthoria_world_sim_v1) so GMs or authoring tools can add regions, factions, settlements, NPCs, and relics incrementally viaadd_world_entityandregister_npc_agent.
Related Developer Documentation
- Persistent NPC Architecture, Attributes & Lifecycle — Complete breakdown of
SimAgent,NpcAgent,SimKeys,NpcDevelopmentSystem, andHiddenTracker. - Agent Reasoning & Decision-Making Deep Dive — How
kompile-graph-reasoningdrives ToM, QBAF arbitration, sensitivity, belief revision, and weight learning. - ANTLR Map DSLs & World Simulator Data Format —
TTRPGMap.g4,HexMap.g4,WorldSimStateJSON skeleton, tick pipeline, and persistence records. - How an Elthoria World Works (GM Guide) — Plain-English tabletop overview for Game Masters.