Skip to content

fix_moon_phase: also pin ubirthday and getyear() to the seed - #130

Open
kenforthewin wants to merge 1 commit into
NetHack-LE:mainfrom
kenforthewin:nethax-determinism
Open

fix_moon_phase: also pin ubirthday and getyear() to the seed#130
kenforthewin wants to merge 1 commit into
NetHack-LE:mainfrom
kenforthewin:nethax-determinism

Conversation

@kenforthewin

Copy link
Copy Markdown

Fixes #129.

fix_moon_phase pins the struct tm path but ubirthday was still raw time(NULL), so wall-clock leaked into fully seeded games through the flavor-variation hashes (shopkeeper names in shknam.c, shop surcharge parity in shk.c, antholemon() species in mkroom.c, scroll labels in read.c). getyear() also bypassed the fixed-tm wrapper.

This derives ubirthday from settings.time_seed via the same ISAAC64 pattern as nle_fill_fixed_tm(), and routes getyear() through nle_getlt_maybe_fixed(). No behavior change when fix_moon_phase is off.

Verified: same seed run in sessions 96 seconds apart yields identical action SHA-256 and identical shopkeeper name; previously the same seed produced different shopkeeper names (and step counts, via message pagination) across sessions. No seeded outcome changed in our regression fixtures (details in #129).

NetHack hashes ubirthday for between-game flavor variation without
consuming game RNG: shopkeeper names (shknam.c), shop surcharge parity
(shk.c), antholemon() species (mkroom.c), scroll labels (read.c).
fix_moon_phase pins the struct-tm path but ubirthday was still raw
time(NULL), so wall-clock leaked into fully seeded games (observed as
session-dependent shopkeeper names and message-pagination step drift;
prices and anthole species are gameplay-relevant channels).

Derive ubirthday from settings.time_seed via the same ISAAC64 pattern
as nle_fill_fixed_tm, and route getyear() through the fixed-tm wrapper.
No change when fix_moon_phase is off.
@StephenOman

Copy link
Copy Markdown
Collaborator

Thanks for the PR!

Is there any way that you could add a test to the suite for this functionality?

Comment thread src/nlernd.c
isaac64_init(&time_rng, seed_bytes, sizeof(seed_bytes));

/* Arbitrary fixed epoch range: 2000-01-01 plus up to ~40 years. */
return (time_t) (946684800UL

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you replace these UL literals with macros that describe what they mean please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix_moon_phase does not pin ubirthday — wall-clock still leaks into seeded games

2 participants