babylon.engine.formula_registry
Formula registry for hot-swappable mathematical functions.
This module provides a FormulaRegistry class that stores named callables, enabling runtime replacement of formulas for testing and modding.
Sprint 3: Central Committee (Dependency Injection)
Classes
Registry for named mathematical formulas. |
- class babylon.engine.formula_registry.FormulaRegistry[source]
Bases:
objectRegistry for named mathematical formulas.
Provides a central lookup for all simulation formulas, enabling: - Hot-swapping formulas for testing with mocks - Modding support for custom formula implementations - Centralized formula management
Example
>>> registry = FormulaRegistry.default() >>> rent = registry.get("imperial_rent") >>> result = rent(alpha=0.5, periphery_wages=0.4, periphery_consciousness=0.2)
- classmethod default()[source]
Create a registry pre-populated with all standard formulas.
Registers all 12 formulas from babylon.systems.formulas: - imperial_rent - labor_aristocracy_ratio - is_labor_aristocracy - consciousness_drift - acquiescence_probability - revolution_probability - crossover_threshold - loss_aversion - exchange_ratio - exploitation_rate - value_transfer - prebisch_singer
- Return type:
- Returns:
FormulaRegistry with all standard formulas registered