
One particularly effective technique is to seed it once, and only once. Iterate (through the random stream) a bit, then save that value to a file. Anytime your program closes, just grab one last number from the stream, save it to the file, and re-load that as your next seed. That way you're using one (and only one) random sequence for all runs of your program, and since any good random number generator (e.g. Mersenne Twister, etc) is pretty close to random along an entire stream, you're doing pretty well. Re-seeding naively can be dangerous, as it's not just entropy you want in a seed - it's things like relative primality, etc. As noted, seeding with a clock isn't nearly as effective as most think. Process ID's tend to be 'low' (not 11+ bits long, at least), as do ThreadID's, and other such things. Not nearly as much entropy as many think. - Greg On May 19, 2006, at 11:08 AM, Peter Dimov wrote:
Andrew Holden wrote:
Does anybody else know of other good sources of entropy to seed the generator?
On Windows I use QueryPerformanceCounter, GetCurrentProcessId, GetCurrentThreadId and GlobalMemoryStatus as entropy sources. OpenSSL uses the contents of the screen.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users