[fpc-pascal] Better random numbers ?

Vincent Snijders vsnijders at quicknet.nl
Mon Feb 27 09:41:30 CET 2006


A.J. Venter wrote:
>>Some other workaround that comes to my mind is to do something like
>>   Randomize;
>>   RandSeed := RandSeed * getpid;
> 
> This worked, cut the initial generation time from about 30 seconds down to 
> under 1, of course right now it's NOT platform independent at all so I will 
> need to enhance it but I like the direction of your thinking, combining 
> randseed with some virtually guaranteed unique value solves the problem.

Maybe you use a global variable and just add one for each randseed call. After all 
the only thing that matters for the randseed, is that it is different.

BTW, I never would have guessed that the random number generator would have used 
threadvars. I would have thought, that on app start you would set one randseed and 
then call random from all threads.

Vincent.



More information about the fpc-pascal mailing list