[fpc-pascal]Random generator

jordi jordiv at catalonia.net
Sat Dec 6 20:26:53 CET 2003


El ds, 06 de 12 de 2003 a las 19:31, Jonas Maebe escribió:

> 
> You are using random/randomize wrong here. The correct way is
> 
> randomize;
> for loop := 1 to 100 do begin
>    writeln (random (1000) +1);
> end;
> 
I know that this is the correct way, mine was only one bad example to
re-seed.

> Randomize initialises the random number generator based on the current 
> system time. So if you call it multiple times in a short time period, 
> you will get a similar (or even the same) randseed.
> 
With this, you have answered perfectly my question, to get a diferent
sequence can I set randseed in a diferent way? for example:

Procedure set_new_random_seed;
  begin
    randseed := who knows yet...
  end;

For loop := 1 to 100 do begin
  set_new_random_seed;
  writeln (random (1000) +1);
end;

Thank you very much.

Jordi.





More information about the fpc-pascal mailing list