Skip to content
DavisDevelopment edited this page Dec 30, 2014 · 1 revision

class tannus.math.Random

Seedable Pseudo-Random-Number Generation class


Class Methods

static function stringSeed(str_seed : String):Random

generates an integer from the bytes of str_seed, then returns a new Random instance using that as it's seed


Instance Fields

private var state : Int

effectively, the current "seed" in use by this instance


Instance Methods

function nextInt() : Int

mutates state and returns the result

function nextFloat() : Float

returns the relationship between state and ECMAScript's integer-cap

function randbool() : Bool

returns random Boolean value

function randint(min:Int, max:Int):Int

returns random Integer between min and max

function choice <T> (options : Array<T>) : T

returns a randomly-selected item from options
if options.length < 2, result is unspecified

function shuffle <T> (items : Array<T>):Array<T>

returns a new Array with all of the same contents as items,
but with all of their indices randomly re-assigned