[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Getting randomic integers
- From: "Alex Davies" <alex.mania@...>
- Date: Sun, 17 Jan 2010 17:21:11 +0800
But if you're executing the script, in it's entirely, more than once a
second you're randomseed()'ing with the same time in that second and
you'll get the same random numbers...
Well if you're not able to have a "RunOnce"or "Init" function, then add this
to your script:
if not Seeded then
Seeded = true
Unless you're also running each script in its own little sandbox without
access to globals, in which case perhaps that is a problem..
You should know though that whilst each sequence of random() numbers are
supposed to be random, no guarantee is given that two sequences from seeds
that are very similar (ie differ by 1) won't share patterns. A fair few
generators fail there (Delphi's math library comes to mind) - sometimes
re-randomseeding with a random number produced by the sequence a few times
can separate the seeds out a bit. Whether or not your C compiler suffers
this, who knows. ie:
for i = 1,4 do
It's every bit a hack as it looks too.