Boolsheet wrote:It's not incorrect. It's meant to warm up the generator. Depending on the algorithm behind math.randomseed and math.random, the first random value may be very closely related to the seed. This can trip you up if you expect an actual random first number and instead get slowly increasing numbers because you seed from time. Three steps into it will mix the seed up to a point where we hopefully don't have that effect anymore.
First, if you are constantly seeding from time, then you use the random generator in a wrong way. The idea is to seed it once and then just use it.
Second, nevertheless I doubt, that seeding from two similar seeds will produce similar random numbers. Not even the first one. So even if you seeded from time constantly, and you made sure you don't seed with the same number then drawing three random numbers before the actual use would not increase the quality of the random numbers.
And to be specific. I am talking about an implementation of rand like this:
Code: Select all
next = next * 1103515245 + 12345;
return (UINT32)(next>>16) & RAND_MAX;
(I got it from
Stackoverflow), which is a linear congruential generator. Seeding in this generator means that you set the variable "next" to a specific value. When rand is called then first some calculatation are done on "next" and then an output is generated. Even if two seeds only differ by 1, the new values of "next" differ by 1,103,515,245 and then a bit shift is done which puts the front digits to the back and vice versa.
But maybe I missed something. Can you provide an example or specify what you mean by "this can trip you up"?