org.artoflife.util
Class RandomGenerator

java.lang.Object
  |
  +--org.artoflife.util.RandomGenerator

public class RandomGenerator
extends java.lang.Object

Each Thread gets its own RandomGenerator to use, which wraps a Random to generate pseudo-random numbers.

Author:
Steve Meyfroidt

Method Summary
static float nextFloat()
           
static float nextGaussian()
           
static int nextInt(int limit)
           
static java.lang.Object randomEntry(java.util.List list)
           
static void restore(java.io.ObjectInputStream stream)
          Persist the random number generator to a stream.
static void save(java.io.ObjectOutputStream stream)
          Persist the random number generator to a stream.
static void setSeed(long seed)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setSeed

public static void setSeed(long seed)
See Also:
MersenneTwisterFast#setSeed(long)

nextGaussian

public static float nextGaussian()
Returns:
the next pseudorandom, Gaussian ("normally") distributed float value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence.
See Also:
Random.nextGaussian()

nextFloat

public static float nextFloat()
Returns:
the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from this random number generator's sequence.
See Also:
Random.nextDouble()

nextInt

public static int nextInt(int limit)
Parameters:
limit - (exclusive) for the int returned, for example if 4, the returned int will be 0, 1, 2 or 3
See Also:
Random.nextInt(int)

randomEntry

public static java.lang.Object randomEntry(java.util.List list)
Parameters:
list - to choose a random entry from
Returns:
a random entry from the list or null if list is empty or null

save

public static void save(java.io.ObjectOutputStream stream)
                 throws java.io.IOException
Persist the random number generator to a stream.

java.io.IOException
See Also:
restore(java.io.ObjectInputStream)

restore

public static void restore(java.io.ObjectInputStream stream)
                    throws java.io.IOException,
                           java.lang.ClassNotFoundException
Persist the random number generator to a stream.

java.io.IOException
java.lang.ClassNotFoundException
See Also:
save(java.io.ObjectOutputStream)

artoflife pre0.1.0-dev

Copyright © 2002 the Art Of Life team. All Rights Reserved.