3 ms·
The problem this seems to be solving, which is that the seeded random number used to generate the level is mixed with the seeded random number used to affect co
by zackees 5y ago
The problem this seems to be solving, which is that the seeded random number used to generate the level is mixed with the seeded random number used to affect combat.
It just seems trivial to solve though... or maybe I'm getting something wrong... but the solution seems to be to use the seeded random number to generate the level, and then copy the the last output of the random number to seed a new random number controlling combat.
That is, the random number generating the level is immutable with respect to the combat random number?
What am I missing?
- hexmiles 5y agoI also don't understand, i solved (what i think is) the same problem by having a master rng whose output seeded individual rng, one for map generation, one for enemy ai, one for loot, etc...
- attractivechaos 5y agoThis depends on what RNG you are using. If the master and the secondary RNGs use the same algorithm without extra internal states (e.g. splitmix or LCG), you will be generating the same stream over and over with small shifts. The end result may not be obvious in your use case, but can be a catastrophe for statistical simulation or the implementation of dropout. PCG32 is a proper solution. Xorshiro provides another solution by using one simple function to advance the internal state by 2^64 iterations.
- 37ef_ced3 5y agoBTW, xoroshiro should not be used. See the last section of this: https://lemire.me/blog/2017/09/08/the-xorshift128-random-number-generator-fails-bigcrush/ https://lemire.me/blog/2017/09/08/the-xorshift128-random-num...
- attractivechaos 5y agoI was aware of that blog post as well as the counter argument by the xoroshiro author against PCG. I am not studying RNG and can't say which is more correct. To me, I use xoroshiro mainly because PCG64 is complex to implement. My applications do not need extreme randomness so far.
- irskep 5y agoYou're right, it's trivial, and I was dramatically overthinking it when I wrote this article. I expect my blog traffic to be about zero, so sometimes things end up half-baked.