Files
rgoue/game/testdata/README.md
sneak e595b87718 Cross-validate item appearance tables against the C reference
Instrumented the C game on modern-rogue with a DUMP mode (patch in
testdata/c_seedcompat.patch) that forces the RNG seed and prints the
per-seed item appearance tables — potion colors, scroll names, ring
stones, wand/staff materials — in the normal init order, before initscr
so no terminal is needed. Captured its output for four seeds as
testdata/item_tables.golden.

TestSeedCompatItemTables regenerates the same tables from the Go port
via New(Params{Seed, Wizard: true}) and checks they match the golden
byte for byte. They do, for all four seeds — proving the LCG and its
consumption order through the whole init sequence (init_probs →
init_player → init_names → init_colors → init_stones → init_materials,
including init_player's arrow rnd(8)+rnd(15)) agree with C exactly.

testdata/README.md documents how to regenerate the golden.
2026-07-24 03:05:01 +07:00

1.2 KiB

Seed-compatibility golden

item_tables.golden is the per-seed item appearance tables (potion colors, scroll names, ring stones, wand/staff materials) captured from the C reference on the modern-rogue branch, for the seeds in the seeds list in TestSeedCompatItemTables. That test regenerates the same tables from the Go port and checks they match byte for byte — proving the LCG and its consumption order through the whole init sequence (init_probsinit_playerinit_namesinit_colorsinit_stonesinit_materials) agree with C.

Regenerating the golden

c_seedcompat.patch adds a DUMP mode to the C main.c: with DUMP set it forces the RNG seed from SEED, runs the item-table init in the normal order, prints the tables, and exits before initscr (so no terminal is needed).

# from a checkout of the C reference (modern-rogue branch):
git archive modern-rogue | tar -x -C /tmp/rogue-c
cd /tmp/rogue-c
patch -p1 < .../game/testdata/c_seedcompat.patch
./configure && make
for s in 1 42 12345 99999; do DUMP=1 SEED=$s ./rogue; done \
    > .../game/testdata/item_tables.golden

The seed list must match the seeds slice in TestSeedCompatItemTables.