group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
DeterminismHash.hpp File Reference

Deterministic state-hash for CI golden testing. More...

#include "ecs/registry/Registry.hpp"
#include <cstdint>
Include dependency graph for DeterminismHash.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  physics
 Pure physics math — no ECS types, no registry.
namespace  physics::diag

Functions

uint64_t physics::diag::hashPhysicsState (const Registry &registry) noexcept
 Compute a deterministic hash of physics-relevant ECS state.

Detailed Description

Deterministic state-hash for CI golden testing.

Walks every replicated physics component on every entity in a stable (entity-id-sorted) order and folds their bits into a 64-bit FNV-1a hash. Two runs producing the same hash → bit-equal physics state.

Intended use:

  1. CI runs a fixed-input scenario for N ticks twice; hashes must match.
  2. Client + server hash the same tick's state; they must match (otherwise prediction is diverging).

Cost. O(entity count) per call, ~50 ns per entity on a typical CPU. Cheap enough to run every frame in dev / debug builds.