Design Principles

Config-as-Input

The scenario TOML is the product. Configs are human-readable, version-controllable, and designed to be shared and forked. The engine takes no position on what is likely — it enforces internal consistency and shows what the premises imply.

Deterministic Seeded RNG

All stochastic choices use a ChaCha-based RNG seeded from the scenario config. Same seed + same config = identical output on native and WASM. Reproducibility is guaranteed so runs can be shared for inspection.

Monte Carlo First

Single-run narrative replay is available for inspection, but the primary output is statistical. Thousands of runs produce probability distributions, time-to-outcome histograms, and sensitivity rankings.

Dual Target: Native and WASM

Pure simulation logic compiles to both wasm32-unknown-unknown (browser) and native targets (CLI). The CLI adds rayon for parallelism; WASM uses single-threaded async. Backends are isolated in their own crates.

Crate Dependency Graph

faultline-types is the leaf crate with no internal deps. All domain crates depend only on types. The engine assembles all domain crates, and the two backends sit at the top.

faultline-types leaf crate · no internal deps faultline-geo geography · pathfinding faultline-tech capability cards faultline-politics loyalty · defection faultline-events triggers · chains faultline-engine core tick loop · 9 phases faultline-stats Monte Carlo runner · aggregation faultline-backend-wasm browser UI · Canvas/WebGL faultline-cli headless batch runner

Simulation Tick Loop

Each simulated time step executes nine phases in order. All phases are deterministic given the same seeded RNG state.

1

Event Phase

Evaluate pending event triggers. Fire events whose conditions are satisfied. Apply immediate effects and enqueue chained events for future ticks.

2

Decision Phase

Each faction AI runs a utility-based decision function. Evaluates strategic objectives, available orders, and current world state to select actions for this tick.

3

Movement Phase

Execute ordered force movements. Pathfinding respects terrain movement modifiers, supply lines, and contested corridors. Forces may be intercepted before arriving.

4

Combat Phase

Resolve engagements between opposing forces in the same region. Applies Lanchester attrition rates modified by terrain, tech cards, and force composition.

5

Attrition Phase

Apply non-combat losses: supply shortfalls, morale decay, equipment degradation, and logistics strain. Forces out of supply degrade faster.

6

Political Phase

Update political climate variables. Process loyalty shifts, defection probability rolls, and institutional support changes. Infrastructure state feeds into political stability.

7

Information Phase

Update each faction's intelligence picture. Recon assets, signals intelligence, and cyber operations alter which forces and events are visible to each faction's decision model.

8

Victory Check

Evaluate all victory conditions defined in the scenario config. A condition that is satisfied locks in the winning faction. The simulation halts when a terminal condition is met.

9

Snapshot

Record the full world state for this tick. Snapshots are used to compute output statistics, generate narrative replays, and feed the WASM visualization layer.

Combat Model

Combat uses Lanchester's equations as the attrition substrate, with variant selection driven by scenario parameters.

Lanchester Linear (Aimed Fire)

For targeted engagements where each unit can select its own target — precision weapons, snipers, guided munitions. Loss rate is proportional to the product of force sizes.

dA/dt = -β · B
dB/dt = -α · A

// A beats B when:
α · A² > β · B²

Lanchester Square (Area Fire)

For mass attrition where firepower concentrates on an area — artillery, air strikes, suppression. Loss rate is proportional to opposing force size only.

dA/dt = -β · B
dB/dt = -α · A

// A beats B when:
α · A > β · B

Modifiers Applied

Raw Lanchester rates are multiplied by stacked modifiers drawn from the scenario config before each combat resolution. Modifiers are sampled from distributions, not point estimates.

Terrain defense bonus
Urbanization penalty
Tech card effects
Morale multiplier
Supply status
Force quality rating

Faction AI — Utility-Based Decisions

Each faction runs an independent utility-based decision model each tick. The AI scores all available actions and selects the highest-utility option with noise.

Action Scoring

Each possible action (advance, defend, hold, withdraw, request support) is evaluated against the faction's strategic objectives. Utility scores are weighted sums of expected regional control, supply security, and political costs.

Strategic Objectives

Factions have objective hierarchies defined in the scenario config: primary objectives (must-hold regions), secondary objectives (desired control), and avoid conditions (collateral damage thresholds, political red lines).

Information-Gated

Faction AIs only see world state that their intelligence picture allows. Units in low-visibility terrain or covered by opposing EW/SIGINT cards may be unknown to the deciding faction, producing fog-of-war effects.

Technology Card System

Technologies are named bundles of statistical modifiers. They capture capability without simulating hardware internals.

What a Card Contains

Each TechCard specifies a named set of multiplier distributions applied to simulation parameters. A card for drone swarms might boost ISR visibility while increasing logistics cost; a C-UAS card counters airborne attack modifiers.

// Simplified TechCard structure
TechCard {
  id: "drone_swarm_v2",
  effects: [
    { param: IsrVisibility, mult: Normal(1.4, 0.1) },
    { param: AttackModifier, mult: Normal(1.2, 0.15) },
    { param: LogisticsCost,  mult: Normal(1.1, 0.05) },
  ]
}

How Cards Apply

Cards are assigned to factions in the scenario config. During simulation, the engine queries the tech system before each phase that uses a modifiable parameter. Each relevant card contributes a sampled multiplier that stacks multiplicatively.

Counter-Cards

A card can specify counters fields that reference other card IDs. When an opposing faction holds a counter-card, the effect distributions are modified — reducing or negating the original card's advantages. This models technological competition without explicit hardware detail.

Example CardAffected ParametersTypical Effect
drone_swarmISR visibility, air attack modifier+20-40% recon coverage, +10-30% strike effectiveness
c_uasCounters drone_swarm air attackReduces opposing drone attack modifier by 60-90%
ew_jammingCommunications, command latency+1-3 tick decision delay for opponent factions
cyber_offenseInfrastructure operational statusDegrades target infra nodes by 10-40% per tick
sigintIntelligence picture fidelityReveals low-visibility units to owning faction
precision_munitionsCombat variant selectionShifts toward Linear (aimed fire) model

Monte Carlo and Statistical Output

The faultline-stats crate wraps the engine and runs hundreds or thousands of independent simulations, then aggregates results into probability distributions.

Outcome Probabilities

For each defined victory condition, the runner reports the fraction of runs in which that condition was met. Provides direct probability estimates with confidence intervals across the run batch.

Time-to-Outcome

For each terminal condition, the distribution of ticks elapsed before resolution. Reports median, mean, standard deviation, and percentile bands (10th, 25th, 75th, 90th).

Sensitivity Analysis

Pearson and Spearman correlations between input parameters and outcome measures. Identifies which scenario assumptions most strongly drive outcome variance — the key analytical output.