hxprng

Pseudorandom number generator


Keywords
cross, game, haxe, random
License
Apache-2.0
Install
haxelib install hxprng 0.0.1

Documentation

hxprng

At the moment implements only PCG random number generator

Usage

You should call method random(n:Int) . This will return a random integer between 0 included and n excluded.

 var pg: PCG32 = new PCG32();
 var rnd : Int = pg.random(6) + 1; //add 1 to return a value between 1 and 6 (included)
 trace("Dice : " + rnd);

To get random number between range ( min - max) you can use randomFromInterval(min:Int, max:Int) , where min < max

 var pg: PCG32 = new PCG32();
 var month : Int = pg.randomFromInterval(1,12); // return a value between 1 and 12 (included)
 trace("Month : " + month);