|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectec.util.MersenneTwisterFast
unlekker.util.Rnd
public class Rnd
unlekker.util.Rnd
provides an alternative to java.util.rand by wrapping ec.util.MersenneTwisterFast in a Processing-friendly convenience class.
Mersenne Twister is an advanced pseudo-random number generator with a period of 2^19937-1. The code used here is from Sean Luke, and is part of his ECJ Evolutionary Computation Research System.
Constructor Summary | |
---|---|
Rnd()
Initialize rand number generator. |
|
Rnd(long seed)
|
Method Summary | |
---|---|
float |
rand()
Returns a rand value in the ranges [0..1>, [0..range> or [min..max> depending on the version used. |
float |
rand(float range)
|
float |
rand(float min,
float max)
|
boolean |
randBool()
Randomly returns true or false. |
int |
randInt(int range)
Returns a rand integer value in the range [0..range-1> or [min..max-1>. |
int |
randInt(int min,
int max)
|
boolean |
randProb(double chance)
Returns true if rndFloat(100) returns a result greater than the parameter "chance". |
Methods inherited from class ec.util.MersenneTwisterFast |
---|
clone, main, nextBoolean, nextBoolean, nextBoolean, nextByte, nextBytes, nextChar, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong, nextLong, nextShort, readState, setSeed, setSeed, stateEquals, writeState |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Rnd()
public Rnd(long seed)
Method Detail |
---|
public boolean randBool()
public boolean randProb(double chance)
chance
- double
public float rand()
public float rand(float range)
public float rand(float min, float max)
public int randInt(int range)
range
-
public int randInt(int min, int max)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |