rand.pcg32 #

struct PCG32RNG #

struct PCG32RNG {
mut:
	state u64 = u64(0x853c49e6748fea9b) ^ seed.time_seed_64()
	inc   u64 = u64(0xda3e39cb94b95bdb) ^ seed.time_seed_64()
}

PCG32RNG ported from http://www.pcg-random.org/download.html, https://github.com/imneme/pcg-c-basic/blob/master/pcg_basic.c, and https://github.com/imneme/pcg-c-basic/blob/master/pcg_basic.h

fn (PCG32RNG) seed #

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

seed seeds the PCG32RNG with 4 u32 values. The first 2 represent the 64-bit initial state as [lower 32 bits, higher 32 bits] The last 2 represent the 64-bit stream/step of the PRNG.

fn (PCG32RNG) u32 #

fn (mut rng PCG32RNG) u32() u32

u32 returns a pseudorandom unsigned u32.

fn (PCG32RNG) u64 #

fn (mut rng PCG32RNG) u64() u64

u64 returns a pseudorandom 64-bit unsigned u64.

fn (PCG32RNG) u32n #

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

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

fn (PCG32RNG) u64n #

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

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

fn (PCG32RNG) u32_in_range #

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

u32_in_range returns a pseudorandom 32-bit unsigned u32 in range [min, max).

fn (PCG32RNG) u64_in_range #

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

u64_in_range returns a pseudorandom 64-bit unsigned u64 in range [min, max).

fn (PCG32RNG) int #

fn (mut rng PCG32RNG) int() int

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

fn (PCG32RNG) i64 #

fn (mut rng PCG32RNG) i64() i64

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

fn (PCG32RNG) int31 #

fn (mut rng PCG32RNG) int31() int

int31 returns a 31-bit positive pseudorandom int.

fn (PCG32RNG) int63 #

fn (mut rng PCG32RNG) int63() i64

int63 returns a 63-bit positive pseudorandom i64.

fn (PCG32RNG) intn #

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

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

fn (PCG32RNG) i64n #

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

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

fn (PCG32RNG) int_in_range #

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

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

fn (PCG32RNG) i64_in_range #

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

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

fn (PCG32RNG) f32 #

fn (mut rng PCG32RNG) f32() f32

f32 returns a pseudorandom f32 value in range [0, 1).

fn (PCG32RNG) f64 #

fn (mut rng PCG32RNG) f64() f64

f64 returns a pseudorandom f64 value in range [0, 1).

fn (PCG32RNG) f32n #

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

f32n returns a pseudorandom f32 value in range [0, max).

fn (PCG32RNG) f64n #

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

f64n returns a pseudorandom f64 value in range [0, max).

fn (PCG32RNG) f32_in_range #

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

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

fn (PCG32RNG) f64_in_range #

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

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