4 ms·
> Turns out, every function in NetHack seems to find a way to call random(), causing the RNG state to drift. I recently stumbled across the concept of splittab
by DataWraith 8y ago
> Turns out, every function in NetHack seems to find a way to call random(), causing the RNG state to drift.
I recently stumbled across the concept of splittable RNGs, which works around this very problem.
Once seeded, you can either "hand in" the generator to get a random number, or you can split it into two (or more) new generators that themselves can be handed in or split.
From a single seed generator, you would split off multiple generators for things like map generation and monster behavior, which then split their generators in turn to generate the level or move monsters.
As a consequence, if you change some monster behavior that uses the RNG, that does not cause the level generation to change, because that was split off earlier and is thus on an independent chain of random numbers.
- HelloNurse 8y agoSplitting the PRNG would provide resistance to tampering by walking into walls and the like, but it would also reduce the avalanche effect of code changes, hiding inaccurate probability distributions (e.g. if a polymorph potion turns you into a yeti the next spawned monster is likely to have low hit points) that would cease to change drastically as PRNG calls are added or removed anywhere.