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.
38 lines
1.1 KiB
Diff
38 lines
1.1 KiB
Diff
--- 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();
|
|
|