Pyro

A scripting language for people who enjoy the simpler things in life.

Version 0.3.2

$std::prng


This module uses a 64-bit Mersenne Twister to generate pseudo-random numbers.

The output of the generator is completely deterministic and depends only on the initial seed value, i.e. the sequence of numbers generated will always be identical for a given seed.

The generator is automatically initialized at startup using a random seed but you can reinitialize the generator at any time by calling seed(arg). This reseeds the generator using the argument's 64-bit hash value.

Functions

rand_float()

Returns a uniformly-distributed random $f64 from the half-open interval [0, 1), i.e. the interval from zero up to but not including 1. The generator produces floats with 53 bits of precision.

rand_int(n)

Returns a uniformly-distributed random $i64 from the half-open interval [0, n), i.e. the interval from zero up to but not including n, where n is a positive integer.

rand_int_in_range(lower, upper)

Returns a uniformly-distributed random $i64 from the half-open interval [lower, upper), i.e. the interval from lower up to but not including upper.

The arguments can be positive or negative or mixed as long as lower is less than or equal to upper.

seed(arg)

Seeds the generator using the argument's 64-bit hash.

shuffle(vec)

Shuffles the vector vec in-place. Uses Fisher-Yates/Durstenfeld shuffling.