Random, not so random?

Jesse Phillips jessekphillips+D at gmail.com
Mon Oct 24 14:14:02 PDT 2011


Kagamin Wrote:

> these fail because Random is a struct an its state is precisely replicated on copy, so two calls to randomCover accept gen in the same state, so their outputs are identical. All arr1, arr2, str1 and str2 are equivalent.

Yes, I found that. But the question remains, is it a bug. As I said reuse of a generator is good to allow random behavior throughout the program, but reproducible behavior throughout each run.

RandomCover is a very useful for selecting all options of a range. But you must create a new generator every-time to get random behavior from sequential calls.


More information about the Digitalmars-d-learn mailing list