The OpenD Programming Language

Mt19937

A MersenneTwisterEngine instantiated with the parameters of the original engine MT19937, generating uniformly-distributed 32-bit numbers with a period of 2 to the power of 19937. Recommended for random number generation unless memory is severely restricted, in which case a LinearCongruentialEngine would be the generator of choice.

import std.random;
alias Mt19937 = MersenneTwisterEngine!(uint, 32, 624, 397, 31, 0x9908b0df, 11, 0xffffffff, 7, 0x9d2c5680, 15, 0xefc60000, 18, 1_812_433_253)

Examples

// seed with a constant
Mt19937 gen;
auto n = gen.front; // same for each run
assert(n == 3499211612);

// Seed with an unpredictable value
gen.seed(unpredictableSeed);
n = gen.front; // different across runs

Meta