Random module

random_seed

procedure · 6 overloadsSource

Starts the generator from new_seed. A u64 seed fully determines the stream, as does a Random_State, which is copied with its low half forced odd, or a time value (low and high are copied the same way).

Without a state the context's generator is seeded. Seeding twice with equal values gives equal streams.

ExampleOpen in playground ↗
a, b: Random_State;
random_seed(*a, cast(u64) 7);
random_seed(*b, cast(u64) 7);
assert(random_get(*a) == random_get(*b));

Time :: struct { low: u64; high: s64; }
random_seed(*a, Time.{ 4, 9 });
assert(a.low == 5 && a.high == 9);
random_seed :: (state: *Random_State, new_seed: u64)

Parameters

state: *Random_State
new_seed: u64
random_seed :: (state: *Random_State, new_seed: Random_State)

Parameters

state: *Random_State
new_seed: Random_State
random_seed :: (state: *Random_State, time: $T/interface Some_Big_Time_Value)

Parameters

state: *Random_State
time: $T/interface Some_Big_Time_Value
random_seed :: (new_seed: u64)

Parameters

new_seed: u64
random_seed :: (new_seed: Random_State)

Parameters

new_seed: Random_State
random_seed :: (time: $T/interface Some_Big_Time_Value)

Parameters

time: $T/interface Some_Big_Time_Value

See also