Packagecom.threerings.util
Classpublic class Random

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 Properties
 PropertyDefined by
  p : int
Random
  q : int
Random
  r : int
Random
  seedUniquifier : uint = 2812526361
[static]
Random
  x : Array
Random
Public Methods
 MethodDefined by
  
Random(seed:uint = 0)
Creates a pseudo random number generation.
Random
  
nextBoolean():Boolean
Returns a random Boolean value.
Random
  
nextInt(n:int = 0):int
Returns the an int value n where 0 <= value < n.
Random
  
nextNumber():Number
Returns a random Number where 0.0 <= value < 1.0.
Random
  
setSeed(seed:uint):void
Sets the seed of the generator.
Random
Protected Methods
 MethodDefined by
  
imul(a:Number, b:Number):Number
Random
  
next(bits:int):uint
Random
Protected Constants
 ConstantDefined by
  LOWER_MASK : uint = 0x7fffffff
[static]
Random
  M : int = 397
[static]
Random
  MATRIX_A : uint = 0x9908b0df
[static]
Random
  N : int = 624
[static]
Random
  UPPER_MASK : uint = 0x80000000
[static]
Random
Property detail
pproperty
protected var p:int
qproperty 
protected var q:int
rproperty 
protected var r:int
seedUniquifierproperty 
protected static var seedUniquifier:uint = 2812526361
xproperty 
protected var x:Array
Constructor detail
Random()constructor
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.
Method detail
imul()method
protected function imul(a:Number, b:Number):NumberParameters
a:Number
 
b:Number

Returns
Number
next()method 
protected function next(bits:int):uintParameters
bits:int

Returns
uint
nextBoolean()method 
public function nextBoolean():Boolean

Returns a random Boolean value.

Returns
Boolean
nextInt()method 
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
int
nextNumber()method 
public function nextNumber():Number

Returns a random Number where 0.0 <= value < 1.0.

Returns
Number
setSeed()method 
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
seed:uint
Constant detail
LOWER_MASKconstant
protected static const LOWER_MASK:uint = 0x7fffffff
Mconstant 
protected static const M:int = 397
MATRIX_Aconstant 
protected static const MATRIX_A:uint = 0x9908b0df
Nconstant 
protected static const N:int = 624
UPPER_MASKconstant 
protected static const UPPER_MASK:uint = 0x80000000