News for hackers. Stuff that matters.
Re:SDL2 common mistakes and how to avoid them by rollcat on Sunday January 08, 2023 @06:31AM (#34298207)
From TFA:

> My solution [for generating random numbers] has been to mix event timestamps into the random state: [...]

That's a good, old, and proven technique that is worth highlighting (I would use only the youngest 2-3 bits however).

I wonder though if the author is not shooting themselves in the foot long-term for things like games, where you want to be able to replay the random number stream to hunt down bugs, or for networked game clients that need to run the simulation deterministically and in lockstep.

Re:SDL2 common mistakes and how to avoid them by somat on Sunday January 08, 2023 @11:37AM (#34300520)
If it's deterministic it's not random, it's a hash function. yes I know, it's called rand(). it is still a hash function(except on openbsd), just one with no standard.

http://man.openbsd.org/rand

Re:SDL2 common mistakes and how to avoid them by rollcat on Sunday January 08, 2023 @01:12PM (#34301492)
For games you don't need randomness; you need a function that returns next in a series of uniformly distributed numbers (which RNGs happen to satisfy). But more importantly, you do need determinism, for the reasons I stated above. We're calling that function "random" for the same reasons we'd call another function "dial", even though there's no telephone involved.