Commit Graph

29 Commits

Author SHA1 Message Date
82ca9080a5 replay: route player input through a command chokepoint (Phase 1)
Reshapes every UI-driven sim mutation to flow through one path so it can be
recorded and replayed later, with behaviour unchanged.

- Command model (lib): Command base + derived types (PlaceBuilding, Demolish,
  RotateInPlace, SetRecipe, SetShipLayout, Set[Site]SplitterFilters,
  ClearBeltTiles, ApplySchematicChoice, Reset), each with a playerId for the
  future-multiplayer shape. PlaceBuilding is atomic (carries optional
  recipe/layout/filters) because deferred commands never return the new
  BuildingId to the caller.
- CommandManager (lib): FIFO queue holding a Simulation&; enqueue + drain.
- Simulation::apply(const Command&): the single chokepoint, dispatching by
  kind to the existing mutators. Mutators stay public (enforced by convention,
  not compile-time, so the test suite keeps driving the sim directly).
- Timing: GameWorldView owns the CommandManager and drains it once per frame in
  onFrame, before the tick batch (runs at 0x too, so build-while-paused is
  preserved). A drained Reset triggers the view reset.
- UI fan-in: GameWorldView enqueues its own input directly; MainWindow and
  SelectedBuildingPanel emit CommandRequestedEvent, which GameWorldView
  subscribes to and enqueues. No UI site mutates the sim directly anymore.
- CommandTest: asserts apply(...) yields byte-identical state to the direct
  mutator path, and that CommandManager drains FIFO through apply.

Full suite green (338 cases / 3353 assertions); determinism double-run still
passes. Design doc updated with the atomic-PlaceBuilding and convention-
enforcement decisions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DUsFgd2Ga6pmLz8giS8WUn
2026-06-30 19:44:50 +02:00
a45df902aa replay: add determinism foundation and double-run verification (Phase 0)
Introduces the state-checksum machinery the replay feature rests on, and a
test that proves the simulation is deterministic for a given seed/binary.

- StateChecksum: FNV-1a Hasher (bit-pattern float hashing, -0 normalization,
  length-tagged strings) plus a portable mt19937 state fingerprint.
- BeltSystem/BuildingSystem: appendChecksum(Hasher&) folding transport and
  building/site/occupancy state in deterministic (sorted/insertion) order.
- Simulation: rngFingerprint() (cheap, for the future file checksum) and
  computeStateChecksum() (full state: RNG, scalars, wave/schematic/unlock
  state, subsystems, and ECS position/health/facing/body/scrap/identity).
- DeterminismTest: Hasher unit tests, RNG-fingerprint tests, and a double-run
  test asserting identical per-tick full-state checksums from one seed; plus a
  different-seed divergence guard.

Exit criteria met: double-run determinism test passes; full suite green
(334 cases / 3346 assertions).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DUsFgd2Ga6pmLz8giS8WUn
2026-06-30 17:44:17 +02:00
9573b9789a change repair_tool application and add beams for salvager and repair_tool 2026-06-19 21:15:47 +02:00
e8dd73bcb0 refactor AI system 2026-06-15 09:16:56 +02:00
1ea1cc59fb show threat rate in debug output 2026-06-14 13:39:10 +02:00
3716c2b734 show implicitly unlocked items in schematic unlock dialog 2026-06-13 18:19:25 +02:00
5317f35198 switch to using own event system 2026-06-13 17:52:22 +02:00
49f7129bd5 schematic selection dialog 2026-06-13 14:19:51 +02:00
1641189b75 explicit recipe unlocking 2026-06-12 17:15:06 +02:00
54a6056b77 implicit item locking 2026-06-12 16:14:21 +02:00
af96b95f61 allow to unlock modules when destroying defence stations 2026-06-10 22:37:38 +02:00
aad094f842 allow to configure when which schematic gets unlockable 2026-06-10 21:09:03 +02:00
8dad554800 show threat budget in debug text overlay 2026-06-06 21:07:18 +02:00
9677133c54 add event system and use it to propagate to print traces 2026-06-05 17:18:17 +02:00
15d8fa4f2c add boss wave counter and countdown to the title bar 2026-06-03 22:44:56 +02:00
0cd0529468 split MovementSystem to MovementIntentSystem and DynamicBodySystem 2026-05-25 07:25:54 +02:00
b57299fd2a rename EntityId to BuildingId 2026-05-23 07:53:56 +02:00
ca07cbaf0e switch to ECS architecture 2026-05-22 20:31:39 +02:00
452c26c8b3 split off MovementSystem and AiSystem from ShipSystem 2026-05-20 22:26:45 +02:00
ed6b503767 implement ships depart in waves 2026-04-27 21:31:04 +02:00
fb83db98ab rename blueprint to schematic 2026-04-26 21:00:55 +02:00
78f746d352 implement load config on game restart 2026-04-22 22:53:56 +02:00
4f27c8f3a9 fix: demolish did not return blocks 2026-04-21 21:16:10 +02:00
b7f2005504 add restart button to game over screen 2026-04-21 20:38:18 +02:00
94123e93d6 implement ui 2026-04-20 20:33:37 +02:00
498b97db20 implement waves 2026-04-20 14:10:01 +02:00
411be72a5c implement scrap and ship skeleton 2026-04-20 07:32:18 +02:00
bf29cc40e3 implement building system 2026-04-19 20:53:08 +02:00
ffe69f08b5 implement simulation shell 2026-04-19 15:49:18 +02:00