A seedable pseudorandom generator of the Mersenne Twister variety, with an extremely
long period. Note that this is not a cryptographically sound generator.
This implementation is based on one found at --
http://onegame.bona.jp/tips/mersennetwister.html
An explanation of the algorithm can be found at --
http://en.wikipedia.org/wiki/Mersenne_twister
protected var p:int
protected var q:int
protected var r:int
protected static var seedUniquifier:uint = 2812526361
protected var x:Array
public function Random(seed:uint = 0)
Creates a pseudo random number generation.
Parameters
| seed:uint (default = 0 ) — a seed of 0 will randomly seed the generator, anything
other than 0 will create a generator with the specified seed.
|
protected function imul(a:Number, b:Number):Number
Parameters
Returns
protected function next(bits:int):uint
Parameters
Returns
public function nextBoolean():Boolean
Returns a random Boolean value.
Returns
public function nextInt(n:int = 0):int
Returns the an int value n where 0 <= value < n.
Parameters
| n:int (default = 0 ) — the range to return. If this is set to 0 it will return a
random integer value. Anything less than 0 will thrown an error.
|
Returns
public function nextNumber():Number
Returns a random Number where 0.0 <= value < 1.0.
Returns
public function setSeed(seed:uint):void
Sets the seed of the generator. This will result in the same generator
sequence of values as a new generator created with the specified seed.
Parameters
protected static const LOWER_MASK:uint = 0x7fffffff
protected static const M:int = 397
protected static const MATRIX_A:uint = 0x9908b0df
protected static const N:int = 624
protected static const UPPER_MASK:uint = 0x80000000
Copyright © 2007-2009 Three Rings Design, Inc.