Random

The Random class provides 256-bit seedable, deterministic, and secure random number generators, based on the ChaCha20 algorithm (e.g. Rust's StdRng).

Instantiation

A new RNG may be created using Sparkle's Random. By default the seed is based on the system clock.

let rng be new Sparkle's Random

It may also be seeded with a string, which gets hashed for use as a 256-bit seed.

let rng be new Sparkle's Random with just "the best seed"

Methods

Returns a newly generated number between 0 and 1.

let n be call rng's random

Returns a newly generated integer between min and max, inclusive.

let n be call rng's random_integer with 1, and 6