proc-seed
v0.1.0
Published
Shared deterministic PRNG/hash primitives and a reversible mixed-radix code codec for procedural content.
Maintainers
Readme
proc-seed
Shared deterministic PRNG/hash primitives and a reversible mixed-radix code codec for procedural content. The single source of truth for the seeding math used by zombie-field and its generator editors (tree-generator, rocks-generator), so a code curated in an editor reproduces the identical object in the game.
API
mulberry32(seed)/makeRng(seed)— the project-wide deterministic PRNG.fnv1a32(text),lowbias32(h),hashString(text)— string → well-mixed uint32 seed.hash2(cx, cz, seed)— 2D spatial hash for streamed-world per-cell seeds.saltedSeed(base, index)/GOLDEN_GAMMA— decorrelated per-stream seed derivation.defineCodec(fields)— reversible mixed-radix base-62 object codes over a{key, min, max, step}ranges table. The table IS the codec grid: wire order = field order (first field most significant). Schema evolution: PREPEND new fields (old codes decode with them at their min); appending at the end, or changing any min/max/step, re-interprets every existing code.normalizeHash/formatHash/randomHash— Crockford base-32 map-hash string utilities (behavior frozen; curated hash lists depend on the normalization rules).
Byte-compatibility
test/golden.test.ts pins outputs captured from the original in-repo implementations. Do not
change any algorithm here without accepting that every curated hash, cached asset fingerprint, and
seeded world layout downstream will shift.
