babylon.engine.simulation_engine
Simulation engine for the Babylon game loop.
The step() function is the core of Phase 2. It takes a WorldState and SimulationConfig and returns a new WorldState representing one tick of simulation time.
The step function is: - Pure: No side effects, no mutation of inputs - Deterministic: Same inputs always produce same outputs - Transparent: Order of operations encodes historical materialism
Turn Order (encodes historical materialism): 1. Economic Base - Value extraction (imperial rent) 2. Consciousness - Ideology drift based on material conditions 3. Survival Calculus - P(S|A) and P(S|R) updates 4. Contradiction Tension - Accumulated from wealth gaps 5. Event Logging - Record significant state changes
Phase 2.1: Refactored to modular System architecture. Phase 4a: Refactored to use ServiceContainer for dependency injection.
Functions
|
Advance simulation by one tick using the modular engine. |
Classes
|
Modular engine that advances the simulation by iterating through Systems. |
- class babylon.engine.simulation_engine.SimulationEngine(systems)[source]
Bases:
objectModular engine that advances the simulation by iterating through Systems.
The engine holds a list of systems and executes them in sequence. Order encodes historical materialism: 1. Economic Base (imperial rent) 2. Consciousness (ideology drift) 3. Survival Calculus (probability updates) 4. Contradiction (tension dynamics)
- babylon.engine.simulation_engine.step(state, config, persistent_context=None, defines=None)[source]
Advance simulation by one tick using the modular engine.
This is the heart of Phase 2. It transforms a WorldState through one tick of simulated time by applying the MLM-TW formulas.
- Parameters:
state (
WorldState) – Current world state (immutable)config (
SimulationConfig) – Simulation configuration with formula coefficientspersistent_context (
dict[str,Any] |None) – Optional context dict that persists across ticks. Used by systems that need to track state between ticks (e.g., ConsciousnessSystem’s previous_wages for bifurcation mechanic).defines (
GameDefines|None) – Optional custom GameDefines. If None, loads from default defines.yaml location. Use this for scenario-specific calibration.
- Return type:
- Returns:
New WorldState at tick + 1
- Order encodes historical materialism:
Economic base (value extraction)
Consciousness (responds to material conditions)
Survival calculus (probability updates)
Contradictions (tension from all above)
Event capture (log significant changes)