Namespace ROT.RNG
This code is an implementation of Alea algorithm; (C) 2010 Johannes Baagøe.
Alea is licensed according to the http://en.wikipedia.org/wiki/MIT_License.
Defined in: <rot.js>.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
<static> |
ROT.RNG.clone()
Returns a cloned RNG
|
<static> |
ROT.RNG.getNormal(mean, stddev)
|
<static> |
ROT.RNG.getPercentage()
|
<static> |
ROT.RNG.getSeed()
|
<static> |
ROT.RNG.getState()
Get RNG state.
|
<static> |
ROT.RNG.getUniform()
|
<static> |
ROT.RNG.getUniformInt(lowerBound, upperBound)
|
<static> |
ROT.RNG.getWeightedValue(data)
|
<static> |
ROT.RNG.setSeed(seed)
|
<static> |
ROT.RNG.setState(state)
Set a previously retrieved state.
|
Method Detail
<static>
ROT.RNG.clone()
Returns a cloned RNG
<static>
{float}
ROT.RNG.getNormal(mean, stddev)
- Parameters:
- {float} mean Optional, Default: 0
- Mean value
- {float} stddev Optional, Default: 1
- Standard deviation. ~95% of the absolute values will be lower than 2*stddev.
- Returns:
- {float} A normally distributed pseudorandom value
<static>
{int}
ROT.RNG.getPercentage()
- Returns:
- {int} Pseudorandom value [1,100] inclusive, uniformly distributed
<static>
{number}
ROT.RNG.getSeed()
- Returns:
- {number}
<static>
{?}
ROT.RNG.getState()
Get RNG state. Useful for storing the state and re-setting it via setState.
- Returns:
- {?} Internal state
<static>
{float}
ROT.RNG.getUniform()
- Returns:
- {float} Pseudorandom value [0,1), uniformly distributed
<static>
{int}
ROT.RNG.getUniformInt(lowerBound, upperBound)
- Parameters:
- {int} lowerBound
- The lower end of the range to return a value from, inclusive
- {int} upperBound
- The upper end of the range to return a value from, inclusive
- Returns:
- {int} Pseudorandom value [lowerBound, upperBound], using ROT.RNG.getUniform() to distribute the value
<static>
{string}
ROT.RNG.getWeightedValue(data)
- Parameters:
- {object} data
- key=whatever, value=weight (relative probability)
- Returns:
- {string} whatever
<static>
ROT.RNG.setSeed(seed)
- Parameters:
- {number} seed
- Seed the number generator
<static>
ROT.RNG.setState(state)
Set a previously retrieved state.
- Parameters:
- {?} state