World Evolution

Branching world state, checkpoints, and diff-based progression — deterministic forking of simulation timelines.

What is world evolution?

Ananke's world evolution system lets a host branch, checkpoint, and replay deterministic world states — think of it as git for simulated history. Because every tick is deterministic (same seed + same commands → same output), any saved checkpoint can be restored and re-simulated from that point forward, producing identical results every time.

Key concepts:

  • Session — a live simulation session containing entity state, world state, tick counter, and world seed. Created with createSession(config), stepped with stepSession(session, commands).
  • Checkpoint — a serialized snapshot of a session at a specific tick. Created with serializeSession(session). Stored by the host as a named point in the branch tree (e.g. "cp-100"). Can be restored with deserializeSession(snapshot).
  • Fork — a new session branching from an existing one at a chosen tick. Created with forkSession(session). The fork shares the same seed and history up to the branch point but diverges from there. Use this for "what-if" alternate histories.
  • Diff — comparing two serialized sessions field-by-field to see what changed between two branches. Ananke doesn't ship a diff utility (host concerns vary too much), but the serialized format is plain JSON for easy diffing.
  • Replay — re-running a session from a checkpoint with the same command log produces byte-identical state. This is the foundation for golden fixture testing and determinism validation.

Typical host workflow: maintain a checkpoint at each major narrative event → on player choice, fork from the relevant checkpoint → run both branches → expose branch outcomes to the player or AI director → prune abandoned branches to save memory.

What this uses

src/sim/world.ts src/sim/kernel.ts src/sim/tech.ts src/sim/disease.ts src/sim/weather.ts src/sim/biome.ts forkSession serializeSession docs/host-contract.md

World evolution is the mechanism by which a host branches, checkpoints, and replays deterministic world states. Ananke provides the forking primitives; the host manages the branch graph. Because all state is deterministic, any checkpoint can be restored and re-simulated from that point.

Tier 2 — experimental World-level branching API is not yet in the stable contract. Track STABLE_API.md for promotion.

Branch tree — static preview

static preview

Illustrative branch graph. A real host would generate this from checkpoint metadata.

⬡ genesis
tick 0
◉ cp-100
tick 100
● main
tick 200
◉ cp-300
tick 300
● HEAD
tick 450
⤷ alt-diplomacy
fork tick 100
● alt tick 180
abandoned
⤷ what-if-war
fork tick 150
⬡● main checkpoint branch

Checkpoint diff — sample

static preview

State deltas between cp-100 (main) and alt-diplomacy tick 180. Real diffs are produced by diffing two serialized session envelopes.

entity[3].vitals.shock_Q 4096 1024
world.polities[1].stability_Q 32768 52428
world.tech.currentEra "iron_age" "iron_age" unchanged
world.weather.temperature_Q 12903 13500

Try this

  1. Create a session with createSession(config) and step it to a stable state — this is your genesis point.
  2. Serialize the session: const snap = serializeSession(session). Store this as a named checkpoint.
  3. Fork the session: const branch = forkSession(session). Apply divergent commands to the branch.
  4. To diff two checkpoints, deserialize both and compare entity/world state field-by-field.
  5. Because steps are deterministic, restoring a checkpoint and re-running the same commands always yields the same world state.