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.
This commit is contained in:
28
game/testdata/README.md
vendored
Normal file
28
game/testdata/README.md
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
# 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_probs` →
|
||||
`init_player` → `init_names` → `init_colors` → `init_stones` →
|
||||
`init_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).
|
||||
|
||||
```sh
|
||||
# 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`.
|
||||
37
game/testdata/c_seedcompat.patch
vendored
Normal file
37
game/testdata/c_seedcompat.patch
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
--- a/main.c 2026-07-24 03:02:38
|
||||
+++ b/main.c 2026-07-24 02:48:31
|
||||
@@ -63,6 +63,34 @@
|
||||
#endif
|
||||
dnum = lowtime + md_getpid();
|
||||
seed = dnum;
|
||||
+
|
||||
+ /* SEEDCOMPAT: dump the per-game item appearance tables for a fixed
|
||||
+ * seed and exit, without initscr. The init sequence and everything
|
||||
+ * it consumes from rnd() mirror the normal startup (main.c), so the
|
||||
+ * tables are exactly what a real game with SEED would show. */
|
||||
+ if (getenv("DUMP") != NULL)
|
||||
+ {
|
||||
+ int di;
|
||||
+ char *sv = getenv("SEED");
|
||||
+ if (sv != NULL)
|
||||
+ seed = atoi(sv);
|
||||
+ printf("SEED %d\n", seed);
|
||||
+ init_probs();
|
||||
+ init_player();
|
||||
+ init_names();
|
||||
+ init_colors();
|
||||
+ init_stones();
|
||||
+ init_materials();
|
||||
+ printf("POTIONS\n");
|
||||
+ for (di = 0; di < MAXPOTIONS; di++) printf("%s\n", p_colors[di]);
|
||||
+ printf("SCROLLS\n");
|
||||
+ for (di = 0; di < MAXSCROLLS; di++) printf("%s\n", s_names[di]);
|
||||
+ printf("RINGS\n");
|
||||
+ for (di = 0; di < MAXRINGS; di++) printf("%s\n", r_stones[di]);
|
||||
+ printf("STICKS\n");
|
||||
+ for (di = 0; di < MAXSTICKS; di++) printf("%s %s\n", ws_type[di], ws_made[di]);
|
||||
+ exit(0);
|
||||
+ }
|
||||
|
||||
open_score();
|
||||
|
||||
260
game/testdata/item_tables.golden
vendored
Normal file
260
game/testdata/item_tables.golden
vendored
Normal file
@@ -0,0 +1,260 @@
|
||||
SEED 1
|
||||
POTIONS
|
||||
tangerine
|
||||
white
|
||||
ecru
|
||||
gold
|
||||
amber
|
||||
violet
|
||||
vermilion
|
||||
pink
|
||||
aquamarine
|
||||
plaid
|
||||
clear
|
||||
orange
|
||||
cyan
|
||||
tan
|
||||
SCROLLS
|
||||
miwhon garsnanih
|
||||
xomimi roke eshwedshu
|
||||
potwexrol ipbjorod turs evsnelg
|
||||
bekornan oxyfatox
|
||||
iv wexpo wun
|
||||
ha sefnelgtue whon pay
|
||||
alari wedit
|
||||
zantmon umzonski umwhonjo yot
|
||||
bluoxun rokkho yottrol sta
|
||||
vomarg microgcomp iteulkshu mung
|
||||
jo urokeep yuskiun
|
||||
ox xozantaks klisstaevs ag
|
||||
ipnih bek
|
||||
shu ami erk
|
||||
nejti zim
|
||||
iprol mic ishoxyvom fagan
|
||||
reacreti oodrol
|
||||
bytsri solsa tabu fri
|
||||
RINGS
|
||||
agate
|
||||
zircon
|
||||
jade
|
||||
tiger eye
|
||||
onyx
|
||||
germanium
|
||||
lapis lazuli
|
||||
emerald
|
||||
taaffeite
|
||||
kryptonite
|
||||
garnet
|
||||
ruby
|
||||
turquoise
|
||||
pearl
|
||||
STICKS
|
||||
wand steel
|
||||
wand platinum
|
||||
staff redwood
|
||||
staff pine
|
||||
wand silicon
|
||||
staff spruce
|
||||
staff pecan
|
||||
wand bone
|
||||
staff maple
|
||||
wand zinc
|
||||
wand iron
|
||||
wand pewter
|
||||
wand electrum
|
||||
staff dogwood
|
||||
SEED 42
|
||||
POTIONS
|
||||
blue
|
||||
green
|
||||
grey
|
||||
amber
|
||||
violet
|
||||
gold
|
||||
pink
|
||||
tan
|
||||
purple
|
||||
yellow
|
||||
plaid
|
||||
magenta
|
||||
turquoise
|
||||
cyan
|
||||
SCROLLS
|
||||
bek itod oxytaod oxy
|
||||
tarhovzant cre sname oxroy
|
||||
plemik ganod hyd wergerkpot
|
||||
hyd sol um bekzok
|
||||
esh eep ganmung
|
||||
anera ishsa ingala mon
|
||||
alasniklech viv
|
||||
yunejorn garro con nej
|
||||
dotrolther gopum eltitrol trolmonsri
|
||||
nes alazum
|
||||
itegopmung ti
|
||||
ere haeta wergla
|
||||
nejerecre poipi iprea
|
||||
ha falechrhov
|
||||
monskiwex sabitla frido
|
||||
rhovmar sno
|
||||
mar bekurzant satbuzum
|
||||
somon sri
|
||||
RINGS
|
||||
carnelian
|
||||
onyx
|
||||
jade
|
||||
granite
|
||||
stibotantalite
|
||||
kryptonite
|
||||
lapis lazuli
|
||||
germanium
|
||||
garnet
|
||||
tiger eye
|
||||
opal
|
||||
topaz
|
||||
agate
|
||||
peridot
|
||||
STICKS
|
||||
staff birch
|
||||
staff ebony
|
||||
staff redwood
|
||||
wand gold
|
||||
wand copper
|
||||
wand aluminum
|
||||
wand titanium
|
||||
wand mercury
|
||||
staff cypress
|
||||
staff bamboo
|
||||
staff dogwood
|
||||
wand silicon
|
||||
staff zebrawood
|
||||
wand beryllium
|
||||
SEED 12345
|
||||
POTIONS
|
||||
purple
|
||||
black
|
||||
grey
|
||||
brown
|
||||
plaid
|
||||
violet
|
||||
vermilion
|
||||
ecru
|
||||
orange
|
||||
turquoise
|
||||
tan
|
||||
magenta
|
||||
silver
|
||||
gold
|
||||
SCROLLS
|
||||
readalf shuplu ivnin
|
||||
plelaiv solel skibyt monha
|
||||
xo wun
|
||||
wedyfri o ewhonxo favompay
|
||||
eep zantreanelg
|
||||
plu buxo
|
||||
un zontabdan
|
||||
bie snik
|
||||
ulkitzant bluri
|
||||
apporg ash posnevly dennepwex
|
||||
u urval rol
|
||||
arzepotsno snovly pay snoropay
|
||||
pottox erewed faoxro
|
||||
ther sun ulkipo mik
|
||||
argzebfri elgrekli tuenepzon sehturssef
|
||||
isheep blumur
|
||||
wedash yuzimsun
|
||||
plupofri ski rejo fa
|
||||
RINGS
|
||||
onyx
|
||||
tiger eye
|
||||
alexandrite
|
||||
turquoise
|
||||
pearl
|
||||
emerald
|
||||
germanium
|
||||
sapphire
|
||||
zircon
|
||||
ruby
|
||||
granite
|
||||
stibotantalite
|
||||
opal
|
||||
diamond
|
||||
STICKS
|
||||
wand silicon
|
||||
staff ironwood
|
||||
staff holly
|
||||
wand gold
|
||||
staff mahogany
|
||||
wand iron
|
||||
wand brass
|
||||
wand pewter
|
||||
staff hemlock
|
||||
staff cherry
|
||||
staff elm
|
||||
wand mercury
|
||||
staff banyan
|
||||
staff dogwood
|
||||
SEED 99999
|
||||
POTIONS
|
||||
aquamarine
|
||||
plaid
|
||||
gold
|
||||
black
|
||||
vermilion
|
||||
red
|
||||
cyan
|
||||
tan
|
||||
orange
|
||||
violet
|
||||
brown
|
||||
clear
|
||||
silver
|
||||
green
|
||||
SCROLLS
|
||||
zant jocompan vomervly
|
||||
mur shusat prok
|
||||
prokmurklis oxysriklis
|
||||
ingcre prokbu whonengarg kli
|
||||
kli bot
|
||||
rokcoswerg ipsolsan klisvlypay
|
||||
glen yot whontox
|
||||
lechme markho fazim
|
||||
dalfsunbie micjosef cre comp
|
||||
vlyfumi bjorzantbot werg
|
||||
po argfidcos klipones
|
||||
ashtemarg ycrezim dalfiv whon
|
||||
turs unmisa zimpo therdo
|
||||
miccompuni uni neswex sef
|
||||
odwexing elwergmur mung
|
||||
itcon rhov nejmic lech
|
||||
garturs engseh ganish
|
||||
oodta whonorgsno monabmik vomyeng
|
||||
RINGS
|
||||
obsidian
|
||||
moonstone
|
||||
jade
|
||||
carnelian
|
||||
tiger eye
|
||||
taaffeite
|
||||
turquoise
|
||||
stibotantalite
|
||||
agate
|
||||
ruby
|
||||
onyx
|
||||
topaz
|
||||
germanium
|
||||
granite
|
||||
STICKS
|
||||
wand titanium
|
||||
wand brass
|
||||
wand silicon
|
||||
staff zebrawood
|
||||
wand mercury
|
||||
staff dogwood
|
||||
wand pewter
|
||||
staff cinnibar
|
||||
staff kukui wood
|
||||
staff banyan
|
||||
wand magnesium
|
||||
wand gold
|
||||
staff maple
|
||||
wand nickel
|
||||
Reference in New Issue
Block a user