hxd.Rand is a seeded random number generator, that allows to get always the same results starting from a given seed.

Static methods

staticcreate():Rand

Create a randomized hxd.Rand (using a Std.random number as seed)

@:value({ seed : 5381 })statichash(n:Int, seed:Int = 5381):Int

staticinlineinlineHash(n:Int, seed:Int):Int

Constructor

new(seed:Int)

Create a random generator with a seed.

Methods

init(seed:Int):Void

Initialize the random generator with a seed.

inlinerand():Float

Return a random float between 0.0 and 1.0 (excluded)

inlinerandom(n:Int):Int

Return a random integer between 0 and n (excluded).

inlineshuffle<T>(a:Array<T>):Void

Shuffle values of an array.

@:value({ scale : 1.0 })inlinesrand(scale:Float = 1.0):Float

Return a random float between -scale and +scale (excluded)