object

# `random`

Portable random number generator predicates. Core predicates originally written by Richard O’Keefe. Based on algorithm AS 183 from Applied Statistics.

Availability:
`logtalk_load(random(loader))`
Author: Paulo Moura
Version: 2:11:0
Date: 2023-11-24
Compilation flags:
`static, context_switching_calls`
Implements:
`public` pseudo_random_protocol
Uses:
list
Remarks:

> - Multiple random number generators: To define multiple random number generators, simply extend this object. The derived objects must send to self the `reset_seed/0` message.

> - Randomness: Loading this object always initializes the random generator seed to the same value, thus providing a pseudo random number generator. The `randomize/1` predicate can be used to initialize the seed with a random value.

Inherited public predicates:
between/3 enumerate/2 get_seed/1 maybe/0 maybe/1 maybe/2 maybe_call/1 maybe_call/2 member/2 permutation/2 random/1 random/3 randseq/4 randset/4 select/3 select/4 sequence/4 set/4 set_seed/1 swap/2 swap_consecutive/2

## Public predicates

### `reset_seed/0`

Resets the random generator seed to its default value. Use `get_seed/1` and `set_seed/1` instead if you need reproducibility.

Compilation flags:
`static, synchronized`
Mode and number of proofs:
`reset_seed` - `one`

### `randomize/1`

Randomizes the random generator using a positive integer to compute a new seed. Use of a large integer is recommended. In alternative, when using a small integer argument, discard the first dozen random values.

Compilation flags:
`static, synchronized`
Template:
`randomize(Seed)`
Mode and number of proofs:
`randomize(+positive_integer)` - `one`

## Protected predicates

(no local declarations; see entity ancestors if any)

## Private predicates

### `seed_/3`

Stores the current random generator seed values.

Compilation flags:
`dynamic`
Template:
`seed_(S0,S1,S2)`
Mode and number of proofs:
`seed_(-integer,-integer,-integer)` - `one`

## Operators

(none)

See also

fast_random, backend_random