Add --fix-moon-phase flag for deterministic time-based game effects#113
Add --fix-moon-phase flag for deterministic time-based game effects#113akhti wants to merge 3 commits intoNetHack-LE:mainfrom
Conversation
When fix_moon_phase=True and seeds are set, derive deterministic values for moon phase, friday 13th, night, and midnight from the seed instead of using real system time. This ensures reproducibility across runs regardless of when they are executed.
- Rename getlt_fixed -> nle_getlt_fixed to mark as NLE addition - Replace custom hash constants with a private ISAAC64 RNG instance seeded from core+1, matching NetHack's own RNG mechanism - Add time_seed_is_set flag to fall back to real time when no seed set
|
Thanks for the review! I rewrote the code to use built-in rng so it's easier to read. Also renamed |
|
This is a better approach than using the magic numbers; I like it! In addition, To round out this PR, think about adding some tests of this new functionality, and perhaps this is as good a time as any to add a new documentation page (in Thanks for the contribution! |
|
@StephenOman thanks for the comments I had to leave small shim |
- Move ISAAC64 time derivation from hacklib.c to nle_fill_fixed_tm() in nlernd.c, keeping hacklib.c changes minimal - Add test_fix_moon_phase_deterministic_moon_messages: verifies that specific seeds produce expected moon phase/friday 13th messages, proven to fail when time_seed derivation changes - Add tests for determinism, different seeds, no-seed fallback, and default-off behavior - Add doc/nle/source/deterministic_seeds.rst covering all seeding mechanisms (core/disp, lgen, fix_moon_phase)
|
fixed lint |
This addresses the same issue as #13 , but without changing default
When fix_moon_phase=True and seeds are set, derive deterministic values for moon phase, friday 13th, night, and midnight from the seed instead of using real system time. This ensures reproducibility across runs regardless of when they are executed.