| Age | Commit message (Collapse) | Author | Files | Lines |
|
doc references, JSDoc-only
|
|
|
|
Two related cleanups landed together because they touch the same pattern:
1. Intra-module imports now use relative paths rather than the module's
own path alias. rng/seeded.ts imports from './derive', not 'rng/derive';
time/gameTime.ts from './calendar', not 'time/calendar'; the utils
barrel from './result' etc. This matches rules/01-code-style.md:
"Relative imports only for same-directory siblings." The alias form
is reserved for imports *between* modules — how external callers refer
to a module's public surface.
(The TS language server in the IDE had trouble resolving the self-
aliased form even though svelte-check accepted it; this change
removes the ambiguity.)
2. utils/ is now folder-per-concept. Each utility owns a directory with
its files broken up into small pieces:
utils/result/ types, constructors, predicates, map, unwrap
utils/assert/ assert, assert-never, assert-defined
utils/equal/ deep
utils/types/ brand, deep-readonly, element-of, json, non-empty-array
utils/log/ log
utils/index.ts re-exports from each subfolder via the barrel. External
callers import from 'utils' unchanged; internal references are relative.
One reason to prefer folders over flat files here is headroom — when a
concept grows, new files sit alongside their siblings inside the
concept's folder rather than crowding the utils/ root.
No API changes. All 128 tests still green.
|
|
rng/ is the load-bearing primitive for simulation determinism
(ARCHITECTURE.md §26). All gameplay randomness routes through
createRNG; Math.random is forbidden in gameplay code by ESLint.
rng/derive.ts xmur3 string hash + deriveSeed(parentSeed, label),
stable across processes and runs
rng/seeded.ts SeededRNG interface, mulberry32 implementation,
next / nextInt / nextBool / pick / weightedPick / sub
rng/index.ts public re-exports
Sub-RNG derivation is the key technical move: seeding a child with
hash(parent_seed + label) lets NPCs' trajectories be regenerated
deterministically from their identity tuple alone — which is how
Tier 3 NPCs stay off-disk until the player needs them.
29 determinism tests in tests/determinism/rng.test.ts cover: same
seed → same sequence, sub-RNG independence from parent consumption,
sub-order matters, input validation, and a byte-level inline
snapshot that locks the PRNG output for seed "hollowdark". The
snapshot is load-bearing — if mulberry32 or xmur3 changes, every
existing save diverges, so treat a snapshot break as a migration
concern, not an update-the-snapshot fix.
|