PCG module

random_seed

procedure · 2 overloadsSource

Starts the generator from new_seed: the state becomes seed * 6364136223846793005 + 1442695040888963407 (wrapping), so the first draw comes from that value. Equal seeds give equal sequences.

Without a state it seeds the shared global. Writing a different u64 straight into your own state is also valid; seeding only spreads small seeds over the 64 bits.

ExampleOpen in playground ↗
a, b: u64;
random_seed(*a, 1234);
random_seed(*b, 1234);
for 1..10 assert(random_get(*a) == random_get(*b));
random_seed :: (state: *u64, new_seed: u32)

Parameters

state: *u64
new_seed: u32
random_seed :: (new_seed: u32)

Parameters

new_seed: u32

See also