code wiki / _hdl_build / nx_loottable.nx
nx_loottable.nx
buildroot/runtime/_hdl_build/nx_loottable.nx
about
nx_loottable.nx -- the SOVEREIGN LOOT / ITEM-AFFIX PART. The last hard GAP on the nx_gamebench board:
blocks Open Diablo II and Dungeon Crawl Stone Soup, and is the Diablo-class archetype's defining system.
THE BUGS THIS PART EXISTS TO KILL:
1. ★THE UNREACHABLE TIER. Weighted selection is usually written with a cumulative loop and an off-by-one
that makes the first or last tier impossible to roll -- legendary items that literally cannot drop,
and nobody notices because "rare is rare". Here selection is a half-open cumulative scan and the gate
proves EVERY declared tier is actually observed over a large sample.
2. ★DISTRIBUTION DRIFT. Declared weights and observed frequencies diverge silently. The gate measures the
real distribution over 100k rolls and requires each tier within tolerance of its declared weight.
3. DUPLICATE AFFIXES -- "+10 STR, +10 STR" on one item, from sampling with replacement.
4. NON-REPRODUCIBLE DROPS -- an item must be a pure function of its seed, so a drop can be replayed,
logged compactly, and verified (our determinism exceed, applied to loot).
Tables are DATA (rule 11): tiers, weights, affix pool and value ranges are all caller-supplied arrays.
LIB ONLY -- no main() by ecosystem convention.
license_tier: ORIGINAL expect_exit: 0
dependencies 1 imports · 5 importers
imports: nx_syscalls.nx
imported by: nx_drift_engine.nxnx_frontier_engine.nxnx_loottable_gate.nxnx_m2d_engine.nxnx_wire_diablo2_gate.nx
structs
| none |
consts
| 19 | const LT_MAXAFFIX: i64 = 6 // hard ceiling on affixes per item |
functions
| 21 | func lt_rng(st: *i64) -> i64 called by 1: lt_roll |
| 34 | func lt_pick(weights: *i64, n: i64, r: i64) -> i64 |
| 54 | func lt_affix_count(tier_affixes: *i64, tier: i64) -> i64 |
| 68 | func lt_roll(seed: i64, |