F5: Simulation core and player command stream

Add the fixed-tick Simulation, the EntityRegistry with never-reused IDs, SimRng's named
seeded streams, and the 14-byte PlayerCommand used by humans, bots and the network.
state_hash is a SHA-256 over a canonical encoding of the state. Movement is a flat
placeholder until the v0.2 character controller. Tests replay a 24-player command log
over 10,000 ticks and scan src/sim for unseeded randomness and presentation code.

Closes #5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 17:16:03 -05:00
co-authored by Claude Opus 5.5
parent 16ad1b7754
commit 27e08db51d
21 changed files with 686 additions and 9 deletions
+9 -2
View File
@@ -55,7 +55,10 @@ Clients stamp commands for the tick they predict, and each packet repeats recent
commands to survive loss. The server applies the command for each tick, or a neutral
command with the player's last look direction if none has arrived.
The binary encoding is a fixed 15 bytes per command. See `src/sim/player_command.gd`.
The binary encoding is a fixed 14 bytes per command, little-endian, in the order of
the table above. See `src/sim/player_command.gd`. Decoding a truncated buffer returns
nothing, and out-of-range values are clamped, so bad input can't reach the simulation.
The player a command belongs to comes from its connection, never from the packet.
## Entity IDs
@@ -68,13 +71,17 @@ deterministic.
- A match has one `u64` seed, always logged.
- Gameplay randomness comes only from named streams, created from the match seed and a
stable name: `SimRng.stream("loot")`, `"weapons"`, `"bots"`, `"worldgen"`, and so on.
stable name: `rng.stream("loot")`, `"weapons"`, `"bots"`, `"worldgen"`, and so on, on one `SimRng`.
One system's extra rolls can't disturb another's.
- Simulation code **never** calls `randf`, `randi`, `Time`, or anything else that varies
between runs. Presentation can use whatever randomness it likes, for effects.
- The same seed and the same command log produce the same state hash, on the same engine
build. Worldgen runs on both ends from the same seed, so the terrain itself is never sent.
`Simulation.state_hash()` is a SHA-256 over a canonical encoding of the tick, the next
entity ID, every RNG stream's state and every entity in ID order, with positions rounded
to millimetres.
Determinism is for tests, replays and worldgen. Clients don't rely on bit-exact matches
with the server. Reconciliation corrects any difference.