Author Topic: Proposal : higher quality random numbers  (Read 2523 times)

Xenakios

  • Sr. Member
  • ****
  • Posts: 83
    • View Profile
Proposal : higher quality random numbers
« on: September 30, 2016, 09:38:01 PM »
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



« Last Edit: October 01, 2016, 01:04:52 AM by Xenakios »