babylon.formulas.state_ai

State AI formulas (Feature 039).

Provides the faction shift calculation that adjusts FactionBalance weights based on player heat and events. Heat drives Security-State weight upward; dropping heat allows reversion toward Finance-Capital dominance.

See also

specs/039-state-apparatus-ai/contracts/faction-balance.md: F-01 through F-05. babylon.config.defines.StateApparatusAIDefines: Shift limits.

Functions

calculate_faction_shift(heat, ...)

Calculate faction balance shift driven by player heat.

check_fascist_reversion(balance, settler_ci, ...)

Check whether conditions are met to exit fascist mode.

is_fascist_convergence(balance, settler_ci, ...)

Detect fascist convergence using the three-pillar model.

babylon.formulas.state_ai.calculate_faction_shift(heat, current_balance, defines)[source]

Calculate faction balance shift driven by player heat.

Higher heat increases Security-State weight at the expense of Finance-Capital and Settler-Populist. The shift per tick is clamped to defines.max_faction_shift_per_tick.

When heat is low (< 0.3), a gradual reversion toward the default equilibrium occurs.

Parameters:
Return type:

FactionBalance

Returns:

New FactionBalance with shifted weights.

babylon.formulas.state_ai.check_fascist_reversion(balance, settler_ci, defines)[source]

Check whether conditions are met to exit fascist mode.

Fascist mode is a near-absorbing state with asymmetric exit thresholds that are substantially harder to reach than entry thresholds:

  • Entry: SS > 0.4, settler CI > 0.6, FC < 0.25

  • Exit: SS < 0.25 AND settler CI < 0.30

Both exit conditions must hold simultaneously.

Parameters:
  • balance (FactionBalance) – Current FactionBalance.

  • settler_ci (float) – Settler collective identity level [0.0, 1.0].

  • defines (StateApparatusAIDefines) – State AI configuration with reversion thresholds.

Return type:

bool

Returns:

True if fascist mode should be exited (reversion achieved).

babylon.formulas.state_ai.is_fascist_convergence(balance, settler_ci, consecutive_ticks, defines)[source]

Detect fascist convergence using the three-pillar model.

All three conditions must hold simultaneously for at least convergence_confirmation_ticks consecutive ticks:

  1. Security-State dominance: SS > fascist_security_threshold (0.4)

  2. Settler-Populist mass base: settler CI > fascist_settler_ci_threshold (0.6)

  3. Finance-Capital acquiescence: FC < fascist_finance_ceiling (0.25)

Parameters:
  • balance (FactionBalance) – Current FactionBalance.

  • settler_ci (float) – Settler collective identity level [0.0, 1.0].

  • consecutive_ticks (int) – Number of consecutive ticks conditions have held.

  • defines (StateApparatusAIDefines) – State AI configuration with fascist thresholds.

Return type:

bool

Returns:

True if fascist convergence is confirmed.