Boost logo

Boost Users :

From: james.jones_at_[hidden]
Date: 2006-05-19 12:14:42


From: Greg Link <link_at_[hidden]>
> 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.

This is a clever idea, but I think it has some problems. First, if you do this, *protect the file very carefully*. Because if its contents are known and your random numbers are used for any sort of security, suddenly your system is not secure at all.

Secondly, you must ensure that the program *always* changes the file, or else you will get two identical runs. This may be annoying or actually dangerous depending on context. A good technique for always changing the file would be to read the contents, then delete it before doing anything with it. On exit, write the file again.

Thirdly, this method assumes that the program only gets run once at a time. What if it's running in two separate processes at the same time? If you don't delete the file as I suggest above, then both processes have the same seed - probably a bad idea. If you do delete the file, then the second process has to generate a new seed and the file did no good.

-
James Jones Administrative Data Mgmt.
Webmaster 375 Raritan Center Pkwy, Suite A
Data Architect Edison, NJ 08837


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net