babylon.engine.scenarios
Factory functions for creating simulation scenarios.
These functions create pre-configured WorldState and SimulationConfig pairs for testing and exploration.
Sprint 6: Phase 2 integration testing support. Multiverse Protocol: Scenario injection for counterfactual simulation.
Functions
|
Apply scenario modifiers to WorldState and SimulationConfig. |
Create a scenario with high initial tension. |
|
Create the 4-node Imperial Circuit scenario. |
|
Create a scenario with a labor aristocracy (Wc > Vc). |
|
|
Create the minimal viable dialectic: one worker, one owner, one exploitation edge. |
Generate 2^3 = 8 permutations of High/Low scenario values. |
- babylon.engine.scenarios.create_two_node_scenario(worker_wealth=0.5, owner_wealth=0.5, extraction_efficiency=0.8, repression_level=0.5, worker_organization=0.1, worker_ideology=0.0)[source]
Create the minimal viable dialectic: one worker, one owner, one exploitation edge.
This is the two-node scenario from the Phase 1 blueprint, now ready for Phase 2 simulation. It models the fundamental class relationship: - Worker produces value (source of exploitation edge) - Owner extracts imperial rent (target of exploitation edge) - Tension accumulates on the edge
- Parameters:
worker_wealth (
float) – Initial wealth for periphery worker (default 0.5)owner_wealth (
float) – Initial wealth for core owner (default 0.5)extraction_efficiency (
float) – Alpha in imperial rent formula (default 0.8)repression_level (
float) – State violence capacity (default 0.5)worker_organization (
float) – Worker class cohesion (default 0.1)worker_ideology (
float) – Worker ideology, -1=revolutionary to +1=reactionary (default 0.0)
- Return type:
- Returns:
Tuple of (WorldState, SimulationConfig, GameDefines) ready for step() function.
Example
>>> state, config, defines = create_two_node_scenario() >>> for _ in range(100): ... state = step(state, config) >>> print(f"Worker wealth after 100 ticks: {state.entities['C001'].wealth}")
- babylon.engine.scenarios.create_high_tension_scenario()[source]
Create a scenario with high initial tension.
Worker is poor, owner is rich, tension is already elevated. Useful for testing phase transitions and rupture conditions.
- Return type:
- Returns:
Tuple of (WorldState, SimulationConfig, GameDefines) near rupture point.
- babylon.engine.scenarios.create_labor_aristocracy_scenario()[source]
Create a scenario with a labor aristocracy (Wc > Vc).
Worker receives more than they produce, enabled by imperial rent from elsewhere. Tests consciousness decay mechanics.
- Return type:
- Returns:
Tuple of (WorldState, SimulationConfig, GameDefines) with labor aristocracy.
- babylon.engine.scenarios.create_imperial_circuit_scenario(periphery_wealth=0.1, core_wealth=0.9, comprador_cut=0.15, imperial_rent_pool=100.0, extraction_efficiency=0.8, repression_level=0.5, solidarity_strength=0.0)[source]
Create the 4-node Imperial Circuit scenario.
This scenario fixes the “Robin Hood” bug in create_two_node_scenario() where super-wages incorrectly flow to periphery workers. In MLM-TW theory, super-wages should only go to the Labor Aristocracy (core workers), NOT periphery workers.
Topology:
graph LR Pw["P_w (Periphery Workers)"] -->|EXPLOITATION| Pc["P_c (Comprador)"] Pc -->|TRIBUTE| Cb["C_b (Core Bourgeoisie)"] Cb -->|WAGES| Cw["C_w (Labor Aristocracy)"] Cb -->|CLIENT_STATE| Pc Pw -.->|"SOLIDARITY (0.0)"| CwValue Flow:
EXPLOITATION: P_w -> P_c (imperial rent extraction from workers)
TRIBUTE: P_c -> C_b (comprador sends tribute, keeps comprador_cut)
WAGES: C_b -> C_w (super-wages to labor aristocracy, NOT periphery!)
CLIENT_STATE: C_b -> P_c (subsidy to stabilize client state)
SOLIDARITY: P_w -> C_w (potential internationalism, starts at 0)
- Parameters:
periphery_wealth (
float) – Initial wealth for periphery worker P001 (default 0.1)core_wealth (
float) – Initial wealth for core bourgeoisie C001 (default 0.9)comprador_cut (
float) – Fraction comprador keeps from extracted value (default 0.15)imperial_rent_pool (
float) – Initial imperial rent pool (default 100.0)extraction_efficiency (
float) – Alpha in imperial rent formula (default 0.8)repression_level (
float) – Base repression level (default 0.5)solidarity_strength (
float) – Initial solidarity between P_w and C_w (default 0.0). When > 0, wage crisis routes to class consciousness (revolutionary). When = 0, wage crisis routes to national identity (fascist).
- Return type:
- Returns:
Tuple of (WorldState, SimulationConfig, GameDefines) ready for step() function.
Example
>>> state, config, defines = create_imperial_circuit_scenario() >>> # Verify wages go to labor aristocracy, not periphery >>> wages_edges = [r for r in state.relationships if r.edge_type == EdgeType.WAGES] >>> assert state.entities[wages_edges[0].target_id].role == SocialRole.LABOR_ARISTOCRACY
- babylon.engine.scenarios.get_multiverse_scenarios()[source]
Generate 2^3 = 8 permutations of High/Low scenario values.
This implements the Multiverse Protocol: running deterministic simulations across parameter space to prove mathematical divergence.
- Parameter ranges:
superwage_multiplier: 0.3 (Low) or 1.5 (High)
solidarity_index: 0.2 (Low) or 0.8 (High)
repression_capacity: 0.2 (Low) or 0.8 (High)
- Expected outcomes:
High SW + Low Solidarity + High Repression -> Low P(S|R) (Stable for Capital)
Low SW + High Solidarity + Low Repression -> High P(S|R) (Revolution likely)
- Return type:
- Returns:
List of 8 ScenarioConfig objects covering all permutations.
Example
>>> scenarios = get_multiverse_scenarios() >>> for s in scenarios: ... print(f"{s.name}: sw={s.superwage_multiplier}, sol={s.solidarity_index}")
- babylon.engine.scenarios.apply_scenario(state, config, scenario)[source]
Apply scenario modifiers to WorldState and SimulationConfig.
This function transforms a base (state, config) pair into a counterfactual scenario by applying the three modifiers:
superwage_multiplier: Passed to config.superwage_multiplier for PPP calculation. - PPP Model: Affects worker effective wealth, NOT extraction_efficiency. - The wages phase uses this to calculate Purchasing Power Parity bonus.
solidarity_index: Sets solidarity_strength on all SOLIDARITY edges. - Does not affect EXPLOITATION or other edge types.
repression_capacity: Updates repression_faced on all SocialClass entities AND repression_level in SimulationConfig.
- Parameters:
state (
WorldState) – Base WorldState to modify (not mutated)config (
SimulationConfig) – Base SimulationConfig to modify (not mutated)scenario (
ScenarioConfig) – ScenarioConfig with modifier values
- Return type:
- Returns:
Tuple of (new_state, new_config) with scenario modifiers applied.
Example
>>> state, config = create_two_node_scenario() >>> scenario = ScenarioConfig(name="test", superwage_multiplier=1.5) >>> new_state, new_config = apply_scenario(state, config, scenario) >>> new_config.superwage_multiplier # Will be 1.5 (for PPP calculation)