Mersenne twister MT19937 pseudorandom number generator for Haxe language, tested on Haxe 3.3
based on http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html and https://gist.github.com/banksean/300494
haxelib install mtprng
var mt = new mtprng.MT( 42 ); // 42 is the PRNG seed
var mt = new mtprng.MT(); // use default seed (haxe.Timer.stamp())
randomUInt()
-- returns pseudorandomUInt
in range [0,2^32)randomInt()
-- returns pseudorandomInt
in range [-2^31,2^31)randomFloat()
-- returns pseudorandomFloat
with 53-bits precisionrandomFloat32()
-- returns pseudorandomFloat
with 32-bits precision
MT.makeFromArray( initKey: Array<UInt> )
var x = mtprng.MT.instance.randomInt();
var y = mtprng.MT.instance.randomFloat();
- cpp, cs, java, js, neko, swf: works, passes all tests
- lua, python: works somehow, passes half of the tests
- php: fails all tests