randomize/0 doesn't work (fix included)
| Newsgroups | gmane.comp.gnu.prolog.bugs |
|---|---|
| Message-ID | <Pine.LNX.4.21.0208171740070.6156-100000@diamond.ansuz.sooke.bc.ca> |
I have a program that calls randomize/0 in its initialization. It usually gets the same random seed, because although randomize/0 is documented as using "a random value depending on the absolute time", it actually gets its seed by calling M_Real_Time(), which is the number of milliseconds since the process started. If I compile my code and put randomize/0 in the initialization, then as long as my system load stays reasonably low, the number of milliseconds between process start and the randomize/0 call will be the same every time, and so I get the same seed value every time. That's not what I want, nor what the documentation leads me to expect. I suggest changing line 789 of src/EnginePL/machine.c from: M_Set_Seed(M_Real_Time()); to M_Set_Seed(M_Real_Time() + start_real_time); That way it uses the current time, as documented. -- Matthew Skala [email protected] Embrace and defend. http://ansuz.sooke.bc.ca/