Random
sealed class Randomimport Random from Wax;A deterministic pseudo-random generator using xoshiro256**, seeded with a uint64.
Equal seeds produce equal sequences. A zero seed is treated as one.
import Random from Wax;
api fn Main() : int32 {
var random = new Random(42ul);
int32 die = random.NextInRange(1, 7);
return die >= 1 && die < 7 ? 1 : 0;
}
Inherits from object. Follow these links for inherited members.
Members
constructorconstructor
public constructor (uint64 seed)Initializes deterministic xoshiro256** state from a seed; zero is treated as one. Not suitable for cryptographic randomness.
Stepmethod
public fn Step() : uint64Advances the generator state once and returns the next 64-bit output, like NextUInt64.
NextUInt64method
public fn NextUInt64() : uint64Returns a random value using all 64 bits.
NextInt64method
public fn NextInt64() : int64Returns a random signed 64-bit value.
NextUInt32method
public fn NextUInt32() : uint32Returns a random unsigned 32-bit value.
NextInt32method
public fn NextInt32() : int32Returns a non-negative random 31-bit integer.
NextFloatmethod
public fn NextFloat() : floatReturns a value in [0, 1) with 24 bits of precision.
NextDoublemethod
public fn NextDouble() : doubleReturns a value in [0, 1) with 53 bits of precision.
NextBoolmethod
public fn NextBool() : boolReturns a random Boolean.
NextInRangemethod
public fn NextInRange(int32 min, int32 max) : int32Returns an integer in [min, max) using unbiased rejection sampling.