3 ms·
There are all kinds of apps that might not need crypto quality randomness, but do at least need the random number streams to be different between invocations of
by jsnell 12y ago
There are all kinds of apps that might not need crypto quality randomness, but do at least need the random number streams to be different between invocations of the program! A Monte Carlo simulation that always gets the same results isn't going to be too hot. A game that seeds the RNG with 16 bits of entropy will be fine for a single player, but not for a community. (Think of FreeCell or Minesweeper in Windows, though those might even have been just 15 bits).
- sarciszewski 12y ago> There are all kinds of apps that might not need crypto quality randomness, but do at least need the random number streams to be different between invocations of the program! If you need high quality randomness, you probably should use urandom. If no where else, when the program is first executed. And if you're on Windows: https://github.com/php/php-src/blob/e6ea376a91514c59d21f4b53ccbb8c06fa42447b/win32/winutil.c#L80-L123 https://github.com/php/php-src/blob/e6ea376a91514c59d21f4b53...
- pbsd 12y agoOn Windows, the easy way is to call `rand_s`: http://msdn.microsoft.com/en-us/library/sxtz2fa8.aspx http://msdn.microsoft.com/en-us/library/sxtz2fa8.aspx
- conistonwater 12y ago> A Monte Carlo simulation that always gets the same results isn't going to be too hot. A Monte Carlo simulation absolutely needs to be able to produce the same numbers every time if you want to have a hope of debugging it. In a release version, yes, sure. But even there, people will still have concerns about replicating other people's results, so being careful with random seeds is important.
- smeyer 12y agoThere's a difference between "always uses the same seed" and "can be seeded for reproducibility". You probably want the latter and probably don't want the former.