News for hackers. Stuff that matters.
Re:Predictably Random by 60654 on Tuesday August 13, 2019 @10:06AM (#20685940)
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_regist...

[1] 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.

Re:Predictably Random by OskarS on Tuesday August 13, 2019 @10:32AM (#20686183)
Fair 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....

Re:Predictably Random by 60654 on Tuesday August 13, 2019 @10:30PM (#20692245)
Oh hah, that's a bit unexpected. Ahh the crazy days of 386SX desktops without math coprocessors :)