rand.mt19937 #

struct MT19937RNG #

struct MT19937RNG {
mut:
	state    []u64 = calculate_state(seed.time_seed_array(2), mut []u64{len: mt19937.nn})
	mti      int   = mt19937.nn
	next_rnd u32
	has_next bool
}

MT19937RNG is generator that uses the Mersenne Twister algorithm with period 2^19937.

fn (MT19937RNG) seed #

fn (mut rng MT19937RNG) seed(seed_data []u32)

seed sets the current random state based on seed_data. seed expects seed_data to be only two u32s in little-endian format as [lower, higher].

fn (MT19937RNG) u32 #

fn (mut rng MT19937RNG) u32() u32

u32 returns a pseudorandom 32bit int in range [0, 2³²).

fn (MT19937RNG) u64 #

fn (mut rng MT19937RNG) u64() u64

u64 returns a pseudorandom 64bit int in range [0, 2⁶⁴).

fn (MT19937RNG) int #

fn (mut rng MT19937RNG) int() int

int returns a 32-bit signed (possibly negative) int.

fn (MT19937RNG) i64 #

fn (mut rng MT19937RNG) i64() i64

i64 returns a 64-bit signed (possibly negative) i64.

fn (MT19937RNG) int31 #

fn (mut rng MT19937RNG) int31() int

int31 returns a 31bit positive pseudorandom int.

fn (MT19937RNG) int63 #

fn (mut rng MT19937RNG) int63() i64

int63 returns a 63bit positive pseudorandom i64.

fn (MT19937RNG) u32n #

fn (mut rng MT19937RNG) u32n(max u32) u32

u32n returns a 32bit u32 in range [0, max).

fn (MT19937RNG) u64n #

fn (mut rng MT19937RNG) u64n(max u64) u64

u64n returns a 64bit u64 in range [0, max).

fn (MT19937RNG) u32_in_range #

fn (mut rng MT19937RNG) u32_in_range(min u32, max u32) u32

u32n returns a pseudorandom u32 value that is guaranteed to be in range [min, max).

fn (MT19937RNG) u64_in_range #

fn (mut rng MT19937RNG) u64_in_range(min u64, max u64) u64

u64n returns a pseudorandom u64 value that is guaranteed to be in range [min, max).

fn (MT19937RNG) intn #

fn (mut rng MT19937RNG) intn(max int) int

intn returns a 32bit positive int in range [0, max).

fn (MT19937RNG) i64n #

fn (mut rng MT19937RNG) i64n(max i64) i64

i64n returns a 64bit positive i64 in range [0, max).

fn (MT19937RNG) int_in_range #

fn (mut rng MT19937RNG) int_in_range(min int, max int) int

int_in_range returns a 32bit positive int in range [min, max).

fn (MT19937RNG) i64_in_range #

fn (mut rng MT19937RNG) i64_in_range(min i64, max i64) i64

i64_in_range returns a 64bit positive i64 in range [min, max).

fn (MT19937RNG) f32 #

fn (mut rng MT19937RNG) f32() f32

f32 returns a 32bit real (f32) in range [0, 1).

fn (MT19937RNG) f64 #

fn (mut rng MT19937RNG) f64() f64

f64 returns 64bit real (f64) in range [0, 1).

fn (MT19937RNG) f32n #

fn (mut rng MT19937RNG) f32n(max f32) f32

f32n returns a 32bit real (f32) in range [0, max)`.

fn (MT19937RNG) f64n #

fn (mut rng MT19937RNG) f64n(max f64) f64

f64n returns a 64bit real (f64) in range [0, max).

fn (MT19937RNG) f32_in_range #

fn (mut rng MT19937RNG) f32_in_range(min f32, max f32) f32

f32_in_range returns a pseudorandom f32 that lies in range [min, max).

fn (MT19937RNG) f64_in_range #

fn (mut rng MT19937RNG) f64_in_range(min f64, max f64) f64

i64_in_range returns a pseudorandom i64 that lies in range [min, max).