Proposal : higher quality random numbers

Started by Xenakios, September 30, 2016, 09:38:01 PM

Previous topic - Next topic

Xenakios

It looks like the CDP code base does random number generation in some non-ideal ways :

1) It uses the standard C library rand() function, which has notoriously bad implementations in the wild. Solution : Use a higher quality random generator such as Mersenne Twister.
2) It uses the system time in seconds to seed that rand() generator. Solution : Get the random seed from a higher resolution clock or an actual entropy source on the system.

I am not sure how easy these are to fix in a C codebase, but I could look into what is available...

edit : I was able to pop in a Mersenne Twister generator that is seeded from a higher resolution clock. Of course this needs further testing etc...

edit2 : Here are the changed/added files (within the dev/sfsys directory) :

https://drive.google.com/file/d/0Bwi8r1Zqbjh_cmJ3QUd2OVFBZjg/view?usp=sharing