
seed(+Seed)

   Seed the pseudo-random number generator

Arguments
   Seed                Integer.

Type
   Arithmetic

Description

   Used to initialise the seed value used for generating sequences
   of pseudo-random numbers in random/1, random/2 and frandom/1.
   Every seed leads to a particular pseudo-random sequence.  Random
   generation is repeatable by setting the seed to identical values.

   The seed value should be an integer in the range 1 .. 2^31-1.

   The scope of the seed setting depends on the setting of the
   'random_mode' flag (see set_flag/2, get_flag/2):

    lcg (default)
        The seed is local to the calling engine.
    
    xs
        The seed is local to the calling engine.
    
    system
        The seed has process-wide effect.
    

    The initial seed on startup depends on the environment and should
    be considered random.  When a new engine is created from a parent
    engine, it inherits its seed from the parent.  When an engine is
    cloned from an original, it inherits its seed from the original.


Modes and Determinism
   seed(+) is det

Exceptions
     4 --- Seed is not instantiated.
     5 --- Seed is instantiated, but not to an integer.

Examples
   
    ?- (for(_,1,9), foreach(R,Rs) do random(100,R)).
    Rs = [93, 56, 11, 88, 98, 34, 22, 18, 30]
    Yes (0.00s cpu)

    ?- seed(123), (for(_,1,9), foreach(R,Rs) do random(100,R)).
    Rs = [33, 92, 47, 28, 50, 28, 42, 59, 89]
    Yes (0.00s cpu)

    ?- seed(123), (for(_,1,9), foreach(R,Rs) do random(100,R)).
    Rs = [33, 92, 47, 28, 50, 28, 42, 59, 89]
    Yes (0.00s cpu)


See Also
   random / 1, random / 2, frandom / 1
