3 ms·
The third one looks like a LFSR [0]. I didn't recognize it at first because the factors used here are not the common ones that produce well known periods; not s
by 60654 7y ago
The third one looks like a LFSR [0]. I didn't recognize it at first because the factors used here are not the common ones that produce well known periods; not sure what period this one would have.
For what it's worth, LFSRs can be nice for generating random sequences with periods of predictable length - and they're cheap! They also recently got a bit of a publicity bump with the rediscovery of how Doom used one for the "death fade" transition, that randomly but exhaustively overpainted all screen pixels with blood red. [2]
[0] https://en.m.wikipedia.org/wiki/Linear-feedback_shift_register https://en.m.wikipedia.org/wiki/Linear-feedback_shift_regist...
[1] http://fabiensanglard.net/fizzlefade/index.php http://fabiensanglard.net/fizzlefade/index.php
But in general - yeah, there's a lot to consider with picking RNGs, not the least of which being context. For games Xorshift is often a good enough choice because it's fast, small, and the game environment is chaotic already (because of the unpredictable players) so there is rarely need for something much stronger.
- OskarS 7y agoFair enough, I was perhaps a bit dismissive of that one and should have looked closer. LFSR can certainly be perfectly acceptible PRNGs for this kind of game. By the way, Doom's random number generator for the game mechanics... not so fantastic [0] :) [0] https://github.com/id-Software/DOOM/blob/master/linuxdoom-1.10/m_random.c https://github.com/id-Software/DOOM/blob/master/linuxdoom-1....
- 60654 7y agoOh hah, that's a bit unexpected. Ahh the crazy days of 386SX desktops without math coprocessors :)