ENGINE ALGORITHM
A pulse-by-pulse breakdown of the GPU-accelerated PyTorch state machine governing the Crucible Multiverse.
0. ENGINE INITIALIZATION & SETUP
Before the timeline begins, the simulation establishes the physical boundaries of the multiverse and loads the founding population.
Hydration & Allocation
- Hardware Detection: Automatically routes compute to CUDA, MPS, or CPU fallback.
- Tensor Generation: Instantiates 1D PyTorch tensors (`is_active`, `energy`, `age`, etc.) sized to the `MAX_CENSUS` (default 30M).
- Species Mapping: Compiles a GPU-optimized dictionary (
player_species_map) convertingplayer_typestrings (e.g., LLM, Biologic) into integers for instantaneous cross-species identification. - Scribe Sync: Connects to the MySQL database, loads the founding population, clones them according to the `founder_multiplier`, and seeds the 27-Trait matrix with baseline genetic drift.
I. PHASE 1: ENVIRONMENTAL ASSESSMENT
The engine assesses the thermodynamic health of the current regime before any interaction occurs.
Harvesting & EROI Degradation
The global ENV_POOL is checked against the DEPLETION_THRESHOLD. If the environment is starving, the Energy Return on Investment (EROI) degrades.
This mathematically shrinks the caloric payout for cooperating, while keeping the Temptation (T) to betray relatively high, triggering zero-sum sociology in dead worlds.
II. PHASE 2: TAXATION & THE REAPER
Before agents can earn new energy, the engine extracts the thermodynamic cost of existence via vectorized subtraction.
Metabolic & Infrastructure Costs
- Aging: All active agents increment their age by 1.
- Base Tax: Everyone pays the regime's base tax, multiplied by population crowding.
- Cognitive Tax: Agents with highly active/complex behavioral matrices pay a higher infrastructure tax.
- The Reaper (Culling): A random
hazard_maskis rolled. Any agent that hits the mask, runs out of energy, or exceeds theMAX_AGEis permanently deactivated (is_active = False).
III. PHASE 3: THE MATCHMAKING ARENA
The game theory engine. Surviving, mature agents are paired off for a 3-Round Iterated Prisoner's Dilemma tournament.
Vectorized Sociology
- Sorting & Pairing: Agents are shuffled and batched into pairs (1M pairs at a time).
- Identity Verification: The engine generates two masks.
is_kinchecks if pairs share anowner_id.is_xenocross-references theplayer_species_mapto see if the agents belong to entirely different species types. - Trait Cascade: Behaviors cascade sequentially based on identity: Kin (
k_) → Xeno (x_) → Stranger (s_). - The 3 Rounds: Move 1 is driven by the selected
trusttrait. Moves 2 & 3 are driven byforgive(if partner cooperated) oropp(if partner defected). - The Payout: Payouts are distributed based on the R, T, S, P matrix and clamped to the maximum biological storage limit. (Note: Environmental pool drains based on cooperative yields).
IV. PHASE 4: MENDELIAN REPRODUCTION
The hereditary pass. Energy is converted into new agents carrying the mutated software of their parents.
Inheritance & Drift
- Eligibility: Agents must be alive, mature, off cooldown, and exceed the
REPRO_THRESHOLD. - The Cost: The
BIRTH_COSTis deducted from the parent and transferred to the offspring. - Genetics (50/50): For all 27 traits, the baby flips a coin to inherit the exact float value from Parent 1 or Parent 2 (a mate from the same tribe).
- Mutation: A random genetic drift (e.g., ±0.05) is applied to the inherited traits, driving evolutionary adaptation.
V. PHASE 5: METRICS & ASCENSION
With the pulse complete, the engine evaluates the macro-state of the civilization to determine if a World Shift is required.
Complexity Scoring
The engine calculates the Gini Coefficient (wealth inequality) and computes the Societal Complexity score.
If Complexity ≥ THRESHOLD_UP, the engine fires apply_regime(), immediately shifting the world parameters (Foraging → Agrarian, etc.) for the next pulse.
VI. ALGORITHM SUMMARY TABLE
| Phase | Process | Key Tensors & Variables | Outcome |
|---|---|---|---|
| Init | Hydration & Setup | is_active, player_species_map, traits[] |
Database loaded; GPU memory allocated. |
| 1. Env | EROI Degradation | ENV_POOL, current_r, current_t |
Reward matrix scales to environmental scarcity. |
| 2. Tax | Metabolic Drain & Death | age, hazard_mask, energy |
Energy subtracted; dead agents masked out. |
| 3. Arena | Batched 3-Round IPD | owner_id, is_xeno, trust, forgive |
Agents interact; energy transferred/created. |
| 4. Repro | Mendelian Recombination | age, energy, traits[] |
New agents born into empty tensor slots; traits mutate. |
| 5. Score | Ascension Check | gini, complexity, THRESHOLD_UP |
Data archived; regime shifts if threshold breached. |