bug-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: randomize/0 doesn't work (further comments)


From: Daniel Diaz
Subject: Re: randomize/0 doesn't work (further comments)
Date: Thu, 12 Sep 2002 11:00:12 +0200

Hi,

you are right and I have fixed this in the version 1.2.15 which will be
released soon.
Thank you

address@hidden wrote:
> 
> After sending the message below I took another look at the code and
> realized that even with the absolute instead of the relative time, line
> 790 of machine.c re-seeds the random number generator with an integer in
> the range 0..255; so there are only 256 possible seeds for a generator
> that ought to be able to do much better than that.
> 
> I don't understand why line 790 exists at all; it looks to me like it
> would be safe, and sensible, to delete that line entirely.  Another
> possibility would be to replace the yucky hardcoded constant 256 with
> RAND_MAX, so we don't lose more information than necessary by re-seeding
> the generator.
> --
> Matthew Skala
> address@hidden                    Embrace and defend.
> http://ansuz.sooke.bc.ca/
> 
> ---------- Forwarded message ----------
> Date: Sat, 17 Aug 2002 17:55:15 -0400 (EDT)
> From: address@hidden
> To: address@hidden
> Subject: randomize/0 doesn't work (fix included)
> 
> 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
> address@hidden                    Embrace and defend.
> http://ansuz.sooke.bc.ca/
> 
> _______________________________________________
> Bug-prolog mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-prolog
> 
> --
> Ce message a subi une analyse antivirus
> par MailScanner ; il est vraisemblablement
> sans danger.

--
Ce message a subi une analyse antivirus 
par MailScanner ; il est vraisemblablement
sans danger.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]