Data Models Reference
Complete specification of Babylon’s data structures, entity collections, and constrained types.
Constrained Types
Babylon uses constrained Pydantic types to enforce valid ranges:
Type |
Range |
Usage |
|---|---|---|
|
[0.0, 1.0] |
Organization, consciousness, survival probability |
|
>= 0.0 |
Wealth, wages, tribute amounts |
|
[0.0, 1.0] |
Tension, heat, solidarity strength |
|
[-1.0, 1.0] |
-1 = revolutionary, +1 = fascist |
|
Unbounded float |
Formula parameters, multipliers |
Import:
from babylon.models import Probability, Currency, Intensity, Ideology
Core Entity Models
Territory
Represents a spatial location with state attention dynamics.
class Territory(BaseModel):
id: str = Field(pattern=r"^T[0-9]{3}$")
name: str
sector_type: SectorType
territory_type: TerritoryType = "core"
host_id: str | None = None
occupant_id: str | None = None
profile: OperationalProfile = "low_profile"
heat: Intensity = 0.0
rent_level: Currency = 1.0
population: int = 0
under_eviction: bool = False
Enums:
SectorType |
Values |
|---|---|
|
Factory/manufacturing sector |
|
Housing/living areas |
|
Business/retail sector |
|
Educational institutions |
|
Port/shipping sector |
|
State administrative sector |
TerritoryType |
Values |
|---|---|
|
Imperial core territory |
|
Exploited peripheral territory |
|
Indigenous containment zone |
|
Carceral territory |
|
Extreme detention territory |
OperationalProfile |
Values |
|---|---|
|
Visible activity, generates heat |
|
Covert activity, heat decays naturally |
Relationship
Represents an edge in the topology graph.
class Relationship(BaseModel):
source: str
target: str
edge_type: EdgeType
weight: float = 1.0
Graph Structure
Node Types
Type |
ID Pattern |
Attributes |
|---|---|---|
|
C001, C002, … |
wealth, organization, ideology, consciousness |
|
T001, T002, … |
heat, profile, sector_type, territory_type |
Edge Types
EdgeType |
Direction |
Meaning |
|---|---|---|
|
bourgeoisie → proletariat |
Economic extraction relationship |
|
bidirectional |
Class consciousness connection |
|
employer → worker |
Labor-wage payment flow |
|
periphery → core |
Imperial value transfer |
|
class → territory |
Spatial occupation |
|
territory → territory |
Spatial proximity (spillover routes) |
Entity Collections
The Ledger stores 18 JSON entity collections in src/babylon/data/game/:
Collection |
Purpose |
|---|---|
|
Class definitions (proletariat, bourgeoisie, etc.) |
|
Spatial locations with operational profiles |
|
Initial edge definitions (solidarity, exploitation) |
|
Tension templates and resolution types |
|
Economic and political crisis definitions |
|
Cultural identity definitions |
|
Political groupings with agendas |
|
Ideological positions with drift modifiers |
|
State and civil society institutions |
|
Legal framework definitions |
|
Social movement definitions |
|
Government policy definitions |
|
Raw materials for production |
|
Uprising condition definitions |
|
Public sentiment data |
|
Technology definitions |
State Transformation API
Converting between Pydantic and Graph representations:
from babylon.models import WorldState
# Pydantic → Graph (for computation)
graph: nx.DiGraph = world_state.to_graph()
# Graph operations (mutation allowed)
engine.run_tick(graph, services, context)
# Graph → Pydantic (for validation)
new_state = WorldState.from_graph(graph, old_state.tick + 1)
See Also
Architecture: The Embedded Trinity - Why this architecture
Simulation Systems Reference - Systems that operate on these models
Configuration System - Configuration parameters
babylon.models- Source code
SocialClass
Represents a social class in the simulation.
Enums:
SocialRole
Values
PROLETARIATWorking class (wage laborers)
BOURGEOISIECapitalist class (owners)
LUMPENPROLETARIATExcluded/marginalized class
PETIT_BOURGEOISIESmall business owners
LABOR_ARISTOCRACYPrivileged workers (core nations)