Logo

Programming-Idioms

History of Idiom 69 > diff from v14 to v15

Edit summary for version 15 by :

Version 14

2015-08-22, 21:49:34

Version 15

2015-08-22, 21:50:57

Idiom #69 Seed random generator

Use seed s to initialize a random generator.

If s is constant, the generator output will be the same each time the program runs. If s is based on the current value of the system clock, the generator output will be different each time.

Idiom #69 Seed random generator

Use seed s to initialize a random generator.

If s is constant, the generator output will be the same each time the program runs. If s is based on the current value of the system clock, the generator output will be different each time.

Code
var
  SomeInteger: Integer;
  Value: double;
...
  Randomize;  //initializes the PRNG's seed with a value depensing on system time
  Value := random;
...
  RandSeed := SomeInteger;  //I Output will be the same eacht time the program runs
  Value := random;
...
Code
var
  SomeInteger: Integer;
  Value: double;
begin
  ...
   //initializes the PRNG's seed with a value depensing on system time
  Randomize; 
  Value := random;
  ...
   //Output will be the same eacht time the program runs
  RandSeed := SomeInteger; 
  Value := random;
...
end.