Systems
Simulation systems that transform world state each tick.
Formulas
Mathematical formulas implementing MLM-TW theory.
Mathematical formulas for the Babylon simulation.
This module contains the pure mathematical functions that drive the dialectical mechanics of the simulation. These are deterministic functions with no side effects - the same inputs always produce the same outputs.
Key Formulas: 1. Fundamental Theorem of MLM-TW:
Imperial Rent: Φ(Wp, Ψp) = α × Wp × (1 - Ψp)
Labor Aristocracy: Wc/Vc > 1
Consciousness Drift: dΨc/dt = k(1 - Wc/Vc) - λΨc
Survival Calculus: - Acquiescence: P(S|A) = 1 / (1 + e^(-k(x - x_critical))) - Revolution: P(S|R) = Cohesion / (Repression + ε) - Loss Aversion: λ = 2.25
Unequal Exchange: - Exchange Ratio: ε = (Lp/Lc) × (Wc/Wp) - Prebisch-Singer Effect
- babylon.systems.formulas.calculate_imperial_rent(alpha, periphery_wages, periphery_consciousness)[source]
Calculate Imperial Rent: Φ(Wp, Ψp) = α × Wp × (1 - Ψp).
Imperial Rent is the value extracted from the periphery that flows to the core, enabling the labor aristocracy.
- Parameters:
- Return type:
- Returns:
Imperial rent value (always >= 0)
Examples
>>> calculate_imperial_rent(0.5, 0.3, 0.2) 0.12 >>> calculate_imperial_rent(1.0, 0.5, 0.0) 0.5 >>> calculate_imperial_rent(0.0, 0.5, 0.5) 0.0 >>> calculate_imperial_rent(0.8, 0.6, 1.0) # Full consciousness = no extraction 0.0
- babylon.systems.formulas.calculate_labor_aristocracy_ratio(core_wages, value_produced)[source]
Calculate labor aristocracy ratio: Wc/Vc.
When this ratio > 1, the worker receives more than they produce, with the difference coming from Imperial Rent.
- Parameters:
- Return type:
- Returns:
Labor aristocracy ratio
- Raises:
ValueError – If value_produced is zero or negative
Examples
>>> calculate_labor_aristocracy_ratio(120.0, 100.0) # Labor aristocracy 1.2 >>> calculate_labor_aristocracy_ratio(80.0, 100.0) # Exploited worker 0.8 >>> calculate_labor_aristocracy_ratio(100.0, 100.0) # Fair exchange 1.0
- babylon.systems.formulas.is_labor_aristocracy(core_wages, value_produced)[source]
Determine if a worker is part of the labor aristocracy.
A worker is labor aristocracy when Wc/Vc > 1, meaning they receive more in wages than the value they produce.
- Parameters:
- Return type:
- Returns:
True if worker is labor aristocracy
- Raises:
ValueError – If value_produced is zero or negative
Examples
>>> is_labor_aristocracy(120.0, 100.0) True >>> is_labor_aristocracy(80.0, 100.0) False >>> is_labor_aristocracy(100.0, 100.0) # Exact equality = not aristocracy False
- babylon.systems.formulas.calculate_consciousness_drift(core_wages, value_produced, current_consciousness, sensitivity_k, decay_lambda, solidarity_pressure=0.0, wage_change=0.0)[source]
Calculate consciousness drift with Fascist Bifurcation mechanic.
Base formula: dΨc/dt = k(1 - Wc/Vc) - λΨc
Extended with Fascist Bifurcation (Sprint 3.4.2b): When wages are FALLING (wage_change < 0), crisis creates “agitation energy” that channels into either: - Revolution (if solidarity_pressure > 0) - negative drift - Fascism (if solidarity_pressure = 0) - positive drift via loss aversion
This encodes the historical insight: “Agitation without solidarity produces fascism, not revolution.” (Germany 1933 vs Russia 1917)
- Parameters:
core_wages (
float) – Wages received by core workervalue_produced (
float) – Value produced by core workercurrent_consciousness (
float) – Current consciousness level (0 to 1)sensitivity_k (
float) – Sensitivity coefficient for material conditionsdecay_lambda (
float) – Decay coefficient (consciousness fades without basis)solidarity_pressure (
float) – Sum of incoming SOLIDARITY edge strengths [0, 1+]wage_change (
float) – Change in wages since last tick (negative = falling)
- Return type:
- Returns:
Rate of change of consciousness (positive = revolutionary drift, negative = reactionary/fascist drift when wages fall without solidarity)
- Raises:
ValueError – If value_produced is zero or negative
- babylon.systems.formulas.calculate_acquiescence_probability(wealth, subsistence_threshold, steepness_k)[source]
Calculate P(S|A) = 1 / (1 + e^(-k(x - x_critical))).
Sigmoid function modeling survival through compliance. At the threshold, probability is 0.5 (coin flip).
- Parameters:
- Return type:
- Returns:
Probability of survival through acquiescence [0, 1]
Examples
>>> calculate_acquiescence_probability(100.0, 100.0, 0.1) # At threshold 0.5 >>> p = calculate_acquiescence_probability(150.0, 100.0, 0.1) # Above threshold >>> p > 0.99 True >>> p = calculate_acquiescence_probability(50.0, 100.0, 0.1) # Below threshold >>> p < 0.01 True
- babylon.systems.formulas.calculate_revolution_probability(cohesion, repression)[source]
Calculate P(S|R) = Cohesion / (Repression + ε).
Survival through collective action depends on organization outpacing state repression.
- Parameters:
- Return type:
- Returns:
Probability of survival through revolution [0, 1]
Examples
>>> calculate_revolution_probability(0.8, 0.2) # Strong org, weak state 1.0 >>> round(calculate_revolution_probability(0.2, 0.8), 2) # Weak org, strong state 0.25 >>> calculate_revolution_probability(0.0, 0.5) # No organization 0.0 >>> p = calculate_revolution_probability(0.5, 0.5) # Balanced >>> p > 0.99 True
- babylon.systems.formulas.calculate_crossover_threshold(cohesion, repression, subsistence_threshold, steepness_k)[source]
Find wealth level where P(S|R) = P(S|A) (revolution becomes rational).
This is the critical point where collective action becomes a rational survival strategy.
- babylon.systems.formulas.apply_loss_aversion(value)[source]
Apply Kahneman-Tversky loss aversion (λ = 2.25).
Losses are perceived as 2.25x more impactful than equivalent gains. This affects decision-making under risk.
- Parameters:
value (
float) – Raw value change (negative = loss, positive = gain)- Return type:
- Returns:
Perceived value after loss aversion
Examples
>>> apply_loss_aversion(100.0) # Gains unchanged 100.0 >>> apply_loss_aversion(-100.0) # Losses amplified -225.0 >>> apply_loss_aversion(0.0) # Zero unchanged 0.0
- babylon.systems.formulas.calculate_exchange_ratio(periphery_labor_hours, core_labor_hours, core_wage, periphery_wage)[source]
Calculate exchange ratio: ε = (Lp/Lc) × (Wc/Wp).
The exchange ratio quantifies unequal exchange. When ε > 1, the periphery gives more value than it receives.
- Parameters:
- Return type:
- Returns:
Exchange ratio
- Raises:
ValueError – If any denominator value is zero or negative
Examples
>>> calculate_exchange_ratio(100.0, 100.0, 20.0, 5.0) # Equal labor, 4x wage gap 4.0 >>> calculate_exchange_ratio(200.0, 100.0, 20.0, 10.0) # 2x labor, 2x wage 4.0 >>> calculate_exchange_ratio(100.0, 100.0, 10.0, 10.0) # Fair exchange 1.0
- babylon.systems.formulas.calculate_exploitation_rate(exchange_ratio)[source]
Convert exchange ratio to exploitation rate percentage.
ε = 2 means 100% exploitation (double value extracted). ε = 1 means 0% exploitation (fair exchange).
- babylon.systems.formulas.calculate_value_transfer(production_value, exchange_ratio)[source]
Calculate value transferred from periphery to core.
Value transfer = production × (1 - 1/ε)
- babylon.systems.formulas.prebisch_singer_effect(initial_price, production_increase, elasticity)[source]
Calculate Prebisch-Singer effect on commodity prices.
Terms of trade decline for commodity exporters: More production → lower prices → same poverty.
- babylon.systems.formulas.calculate_solidarity_transmission(source_consciousness, target_consciousness, solidarity_strength, activation_threshold=0.3)[source]
Calculate consciousness transmission via solidarity edges.
Formula: dPsi_target = sigma * (Psi_source - Psi_target)
Where: - sigma = solidarity_strength (STORED ON EDGE, not auto-calculated) - Psi_source = source_consciousness (periphery worker) - Psi_target = target_consciousness (core worker)
Transmission only occurs if: 1. source_consciousness > activation_threshold (strictly greater) 2. solidarity_strength > 0
This implements the Fascist Bifurcation scenario: - Periphery revolts BUT solidarity_strength=0 -> NO transmission (Fascist turn) - Periphery revolts AND solidarity_strength>0 -> Transmission (Revolutionary turn)
- Parameters:
source_consciousness (
float) – Consciousness level of source (periphery worker) [0, 1]target_consciousness (
float) – Consciousness level of target (core worker) [0, 1]solidarity_strength (
float) – Strength of solidarity infrastructure on edge [0, 1]activation_threshold (
float) – Minimum source consciousness for transmission (default 0.3)
- Return type:
- Returns:
Change in target consciousness (delta). Can be negative if target has higher consciousness than source.
Examples
>>> round(calculate_solidarity_transmission(0.8, 0.2, 0.5), 2) # High source, low target 0.3 >>> calculate_solidarity_transmission(0.2, 0.5, 0.5) # Below threshold 0.0 >>> calculate_solidarity_transmission(0.8, 0.2, 0.0) # No solidarity 0.0 >>> round(calculate_solidarity_transmission(0.5, 0.8, 0.5), 2) # Target > source -0.15
- babylon.systems.formulas.calculate_ideological_routing(wage_change, solidarity_pressure, current_class_consciousness, current_national_identity, current_agitation, agitation_decay=0.1)[source]
Calculate ideological routing from crisis conditions.
Sprint 3.4.3 (George Jackson Refactor): This formula implements the multi-dimensional consciousness routing mechanic.
Key insight: “Fascism is the defensive form of capitalism.” - Agitation (from wage fall) + Solidarity -> Class Consciousness - Agitation (from wage fall) + No Solidarity -> National Identity
- Parameters:
wage_change (
float) – Change in wages since last tick (negative = crisis)solidarity_pressure (
float) – Sum of incoming SOLIDARITY edge strengths [0, inf)current_class_consciousness (
float) – Current class consciousness [0, 1]current_national_identity (
float) – Current national identity [0, 1]current_agitation (
float) – Current accumulated agitation [0, inf)agitation_decay (
float) – Rate at which agitation decays per tick (default 0.1)
- Return type:
- Returns:
Tuple of (new_class_consciousness, new_national_identity, new_agitation)
Example
Worker with falling wages and high solidarity routes to revolutionary:
cc, ni, ag = calculate_ideological_routing( wage_change=-20.0, solidarity_pressure=0.9, current_class_consciousness=0.5, current_national_identity=0.5, current_agitation=0.0, ) # cc will increase, ni will stay flat
Worker with falling wages and no solidarity routes to fascism:
cc, ni, ag = calculate_ideological_routing( wage_change=-20.0, solidarity_pressure=0.0, current_class_consciousness=0.5, current_national_identity=0.5, current_agitation=0.0, ) # ni will increase, cc will stay flat
- class babylon.systems.formulas.BourgeoisieDecision[source]
Bases:
objectEnumeration of bourgeoisie decision types.
Sprint 3.4.4: Dynamic Balance - The “Driver” decisions based on imperial rent pool level and aggregate class tension.
- NO_CHANGE = 'no_change'
- BRIBERY = 'bribery'
- AUSTERITY = 'austerity'
- IRON_FIST = 'iron_fist'
- CRISIS = 'crisis'
- babylon.systems.formulas.calculate_bourgeoisie_decision(pool_ratio, aggregate_tension, high_threshold=0.7, low_threshold=0.3, critical_threshold=0.1)[source]
Calculate bourgeoisie policy decision based on pool level and tension.
Sprint 3.4.4: Dynamic Balance - The bourgeoisie as a rational actor responding to material conditions.
- Decision Matrix:
pool_ratio >= high AND tension < 0.3 -> BRIBERY (increase wages +5%) pool_ratio < critical -> CRISIS (wages to minimum, repression +20%) pool_ratio < low AND tension > 0.5 -> IRON_FIST (repression +10%) pool_ratio < low AND tension <= 0.5 -> AUSTERITY (wages -5%) else -> NO_CHANGE (maintain status quo)
- Parameters:
pool_ratio (
float) – Current pool / initial pool (0.0 to 1.0+)aggregate_tension (
float) – Average tension across class relationships (0.0 to 1.0)high_threshold (
float) – Pool ratio above which prosperity is declared (default 0.7)low_threshold (
float) – Pool ratio below which austerity begins (default 0.3)critical_threshold (
float) – Pool ratio below which crisis fires (default 0.1)
- Returns:
str, wage_delta: float, repression_delta: float) - decision: One of BourgeoisieDecision values - wage_delta: Change to wage rate (positive = increase) - repression_delta: Change to repression level (positive = increase)
- Return type:
Tuple of (decision
Example
# Prosperity: high pool, low tension -> increase wages decision, wage_d, repr_d = calculate_bourgeoisie_decision(0.8, 0.2) # Returns (“bribery”, 0.05, 0.0)
# Crisis: pool below critical -> emergency measures decision, wage_d, repr_d = calculate_bourgeoisie_decision(0.05, 0.5) # Returns (“crisis”, -0.15, 0.20)
- babylon.systems.formulas.calculate_biocapacity_delta(regeneration_rate, max_biocapacity, extraction_intensity, current_biocapacity, entropy_factor=1.2)[source]
Calculate change in biocapacity stock: ΔB = R - (E × η).
The core metabolic formula. Extraction always costs more than the raw value obtained due to entropy/waste (η > 1.0).
- Parameters:
regeneration_rate (
float) – Fraction of max_biocapacity restored per tick [0, 1]max_biocapacity (
float) – Maximum biocapacity ceilingextraction_intensity (
float) – Current extraction pressure [0, 1]current_biocapacity (
float) – Current biocapacity stockentropy_factor (
float) – Waste multiplier for extraction (default 1.2)
- Return type:
- Returns:
Change in biocapacity (positive = regeneration, negative = depletion)
Examples
>>> calculate_biocapacity_delta(0.02, 100.0, 0.0, 50.0) # No extraction 2.0 >>> calculate_biocapacity_delta(0.02, 100.0, 0.05, 50.0) # Light extraction -1.0 >>> calculate_biocapacity_delta(0.02, 100.0, 0.0, 100.0) # At max, no regen 0.0
- babylon.systems.formulas.calculate_overshoot_ratio(total_consumption, total_biocapacity, max_ratio=999.0)[source]
Calculate ecological overshoot ratio: O = C / B.
When O > 1.0, consumption exceeds biocapacity (overshoot). When O <= 1.0, the system is within ecological limits.
- Parameters:
- Return type:
- Returns:
Overshoot ratio (>1.0 = ecological overshoot)
Examples
>>> calculate_overshoot_ratio(100.0, 200.0) # Sustainable 0.5 >>> calculate_overshoot_ratio(200.0, 100.0) # Overshoot 2.0 >>> calculate_overshoot_ratio(100.0, 0.0) # Depleted biocapacity 999.0
Economic System
Economic systems for the Babylon simulation - The Base.
Sprint 3.4.1: Imperial Circuit - 4-node value flow model. Sprint 3.4.4: Dynamic Balance - Pool tracking and decision heuristics.
The Imperial Circuit has five phases: 1. EXPLOITATION: P_w -> P_c (imperial rent extraction) 2. TRIBUTE: P_c -> C_b (comprador keeps 15% cut) -> FEEDS POOL 3. WAGES: C_b -> C_w (dynamic rate super-wages to labor aristocracy) -> DRAINS POOL 4. CLIENT_STATE: C_b -> P_c (subsidy when unstable, converts to repression) -> DRAINS POOL 5. DECISION: Bourgeoisie heuristics update wage_rate/repression based on pool/tension
- class babylon.engine.systems.economic.ImperialRentSystem[source]
Bases:
objectImperial Circuit Economic System - 5-phase value extraction with pool tracking.
Sprint 3.4.4: Dynamic Balance - The Gas Tank and Driver.
Implements the MLM-TW model of value flow with finite resources: - Phase 1: Extraction (P_w -> P_c via EXPLOITATION) - Phase 2: Tribute (P_c -> C_b via TRIBUTE, minus comprador cut) -> FEEDS POOL - Phase 3: Wages (C_b -> C_w via WAGES, dynamic rate) -> DRAINS POOL - Phase 4: Subsidy (C_b -> P_c via CLIENT_STATE, stabilization) -> DRAINS POOL - Phase 5: Decision (Bourgeoisie heuristics adjust wage_rate/repression)
The imperial_rent_pool in GlobalEconomy tracks available resources: - Inflow: Tribute received by Core Bourgeoisie (post-comprador cut) - Outflow: Wages paid + Subsidies paid - When pool depletes, bourgeoisie must choose between austerity or repression
- name = 'Imperial Rent'
- step(graph, services, context)[source]
Apply the 5-phase Imperial Circuit to the graph.
Phases execute in sequence, as each depends on the previous: 1. Extraction must happen before tribute (P_c needs wealth to send) 2. Tribute must happen before wages (C_b needs wealth to pay) - FEEDS POOL 3. Wages capped at available pool - DRAINS POOL 4. Subsidy capped at available pool after wages - DRAINS POOL 5. Decision phase: Bourgeoisie heuristics update economy for next tick
The economy state is read from graph.graph[“economy”] and written back after all phases complete.
Solidarity System
Solidarity system for the Babylon simulation - Proletarian Internationalism.
Sprint 3.4.2: The Counterforce to Imperial Rent Bribery. Sprint 3.4.3: Updated for IdeologicalProfile (multi-dimensional consciousness).
When periphery workers are in revolutionary struggle (consciousness >= threshold), their consciousness transmits through SOLIDARITY edges to core workers, awakening class consciousness that counters the super-wage bribery.
Key Design Decision: solidarity_strength is a PERSISTENT ATTRIBUTE ON THE EDGE, NOT auto-calculated from source organization. This enables the Fascist Bifurcation scenario where periphery revolts but core workers remain passive due to lack of built solidarity infrastructure.
- class babylon.engine.systems.solidarity.SolidaritySystem[source]
Bases:
objectProletarian Internationalism - Consciousness Transmission System.
Implements consciousness transmission via SOLIDARITY edges: - Unidirectional flow (Periphery -> Core) - solidarity_strength stored on edge (key for Fascist Bifurcation) - Emits CONSCIOUSNESS_TRANSMISSION and MASS_AWAKENING events
Sprint 3.4.3: Updated to work with IdeologicalProfile, affecting only the class_consciousness dimension.
- name = 'Solidarity'
- step(graph, services, context)[source]
Apply solidarity transmission to all SOLIDARITY edges.
For each SOLIDARITY edge: 1. Check if source consciousness > activation_threshold 2. Check if solidarity_strength > 0 3. Calculate transmission delta 4. Apply delta to target class_consciousness 5. Emit events for narrative layer
Ideology System
Ideology systems for the Babylon simulation - The Superstructure.
Sprint 3.4.2b: Extended with Fascist Bifurcation mechanic. Sprint 3.4.3: George Jackson Refactor - Multi-dimensional consciousness model.
When wages FALL, crisis creates “agitation energy” that channels into: - Class Consciousness (if solidarity_pressure > 0) - Revolutionary Path - National Identity (if solidarity_pressure = 0) - Fascist Path via loss aversion
- class babylon.engine.systems.ideology.ConsciousnessSystem[source]
Bases:
objectPhase 2: Consciousness Drift based on material conditions.
Sprint 3.4.3 (George Jackson Refactor): Uses multi-dimensional IdeologicalProfile. - class_consciousness: Relationship to Capital [0=False, 1=Revolutionary] - national_identity: Relationship to State/Tribe [0=Internationalist, 1=Fascist] - agitation: Raw political energy from crisis (falling wages)
Extended with Fascist Bifurcation mechanic: - Reads incoming SOLIDARITY edges to calculate solidarity_pressure - Tracks wage changes between ticks to detect crisis conditions - Routes agitation to either class_consciousness or national_identity
- name = 'Consciousness Drift'
- step(graph, services, context)[source]
Apply consciousness drift to all entities with bifurcation routing.
Survival System
Survival systems for the Babylon simulation - The Calculus of Living.
Sprint 3.4.2: Fixed Bug 1 - Organization is now dynamic based on SOLIDARITY edges. P(S|R) = (base_organization + solidarity_bonus) / repression
The solidarity_bonus is the sum of incoming SOLIDARITY edge weights (solidarity_strength). This makes organization a function of class solidarity infrastructure, not just a static value.
- class babylon.engine.systems.survival.SurvivalSystem[source]
Bases:
objectPhase 3: Survival Calculus (P(S|A) vs P(S|R)).
Bug Fix (Sprint 3.4.2): Organization is now DYNAMIC. organization = base_organization + solidarity_bonus
Where solidarity_bonus = sum of incoming SOLIDARITY edge weights. This ensures that High Solidarity scenarios produce higher P(S|R).
- name = 'Survival Calculus'
- step(graph, services, _context)[source]
Update P(S|A) and P(S|R) for all entities.
- Organization is calculated as:
effective_org = base_org + solidarity_bonus
Where solidarity_bonus = sum(solidarity_strength for incoming SOLIDARITY edges)
Contradiction System
Contradiction systems for the Babylon simulation - The Rupture.
Territory System
Territory systems for the Babylon simulation - Layer 0.
Sprint 3.5.4: The Territorial Substrate. Sprint 3.7: The Carceral Geography - Necropolitical Triad. Sprint 3.7.1: Dynamic Displacement Priority Modes.
TerritorySystem manages: 1. Heat dynamics: HIGH_PROFILE gains heat, LOW_PROFILE decays heat 2. Eviction pipeline: triggered when heat >= threshold, routes to sink nodes 3. Heat spillover: via ADJACENCY edges 4. Necropolitics: CONCENTRATION_CAMP elimination, PENAL_COLONY suppression
Displacement Priority Modes (Sprint 3.7.1): - EXTRACTION: Prison > Reservation > Camp (labor valuable, default) - CONTAINMENT: Reservation > Prison > Camp (crisis/transition) - ELIMINATION: Camp > Prison > Reservation (late fascism)
- class babylon.engine.systems.territory.TerritorySystem[source]
Bases:
objectTerritory Dynamic System - Layer 0 spatial dynamics.
Implements the territorial substrate mechanics: - Heat dynamics based on operational profile - Eviction pipeline when heat exceeds threshold - Heat spillover between adjacent territories - Necropolitics for sink nodes (Sprint 3.7)
“Legibility over Stealth” - The State knows where you are. The game is about staying below the repression threshold.
Sprint 3.7 additions: - Population transfers to sink nodes during eviction - CONCENTRATION_CAMP population decay (elimination) - PENAL_COLONY organization suppression (atomization)
- name = 'Territory'
- step(graph, services, context)[source]
Apply territorial dynamics to the graph.
Phases execute in sequence: 1. Heat dynamics (profile-based accumulation/decay) 2. Eviction pipeline (triggered at threshold, routes to sinks) 3. Heat spillover (via adjacency edges) 4. Necropolitics (sink node effects)
Sprint 3.7.1: Context can contain ‘displacement_mode’ to override the default EXTRACTION mode for sink node routing.