babylon.engine.observers.economic
EconomyMonitor observer for economic crisis detection (Sprint 3.1).
The EconomyMonitor is a SimulationObserver that detects sudden drops in the imperial_rent_pool and logs [CRISIS_DETECTED] warnings. This enables AI narrative generation to respond to economic instability.
- Theoretical Context:
The imperial_rent_pool represents the accumulated surplus extracted from the periphery. When it drops suddenly (>20%), it signals a crisis in the imperial extraction system - either from: - Successful peripheral resistance - Core over-consumption depleting reserves - Supply chain disruption
- Detection Logic:
percentage_change = (new_pool - prev_pool) / prev_pool if percentage_change <= CRISIS_THRESHOLD:
log WARNING with [CRISIS_DETECTED] marker
Classes
|
Observer detecting economic crises via imperial_rent_pool drops. |
- class babylon.engine.observers.economic.EconomyMonitor(logger=None)[source]
Bases:
objectObserver detecting economic crises via imperial_rent_pool drops.
Implements SimulationObserver protocol to receive state change notifications and analyze economic state for crisis conditions.
A crisis is detected when the imperial_rent_pool drops by 20% or more from the previous tick. The [CRISIS_DETECTED] log marker allows AI narrative systems to respond appropriately.
- Parameters:
logger (logging.Logger | None)
- CRISIS_THRESHOLD
Class constant defining crisis trigger (-0.20 = 20% drop).
- name
Observer identifier (“EconomyMonitor”).
Example
>>> from babylon.engine.observers.economic import EconomyMonitor >>> monitor = EconomyMonitor() >>> monitor.name 'EconomyMonitor'
- property name: str
Return observer identifier.
- Returns:
String “EconomyMonitor” for logging and debugging.
- on_simulation_start(initial_state, config)[source]
Called when simulation begins.
No-op for EconomyMonitor. Crisis detection only operates on state transitions, not initial state.
- Parameters:
initial_state (
WorldState) – WorldState at tick 0 (unused).config (
SimulationConfig) – SimulationConfig for this run (unused).
- Return type:
- on_tick(previous_state, new_state)[source]
Called after each tick completes with both states for delta analysis.
Compares imperial_rent_pool between states and logs a warning if the drop exceeds CRISIS_THRESHOLD (20%).
- Parameters:
previous_state (
WorldState) – WorldState before the tick.new_state (
WorldState) – WorldState after the tick.
- Return type:
- on_simulation_end(final_state)[source]
Called when simulation ends.
No-op for EconomyMonitor. No cleanup or summary needed.
- Parameters:
final_state (
WorldState) – Final WorldState when simulation ends (unused).- Return type: