net.sourceforge.cilib.games.random
Class GameSeedingStrategy
java.lang.Object
net.sourceforge.cilib.games.random.GameSeedingStrategy
- All Implemented Interfaces:
- Serializable, Cloneable
- Direct Known Subclasses:
- FixedSeedStrategy, ListSeedingStrategy, UniqueSeedingStrategy
public abstract class GameSeedingStrategy
- extends Object
- implements Cloneable
This class is used to generate random numbers for Game's. By making sure the seed is only set once, and at the start of the game,
it becomes possible to duplicate games played by fixing the seed.
- Author:
- leo
- See Also:
- Serialized Form
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
generator
protected Random generator
currentSeed
protected long currentSeed
GameSeedingStrategy
public GameSeedingStrategy()
GameSeedingStrategy
public GameSeedingStrategy(GameSeedingStrategy other)
- The copy constructor makes a shallow clone. The copy constructor of the Random class re-seeds the generator and that behavior is
unwanted. There should only be one instance of this class per game instance.
NOTE: I'm not convinced a thread local singleton should be used here, but it is debateable.
- Parameters:
other
-
getClone
public abstract GameSeedingStrategy getClone()
- Create a cloned copy of the current object and return it. In general
the created copy will be a deep copy of the provided instance. As
a result this operation an be quite expensive if used incorrectly.
- Specified by:
getClone
in interface Cloneable
- Returns:
- An exact clone of the current object instance.
- See Also:
Object.clone()
seedGenerator
public abstract void seedGenerator()
- Get a seed value and seed the generator.
getGenerator
public Random getGenerator()
setGenerator
public void setGenerator(Random generator)
getCurrentSeed
public long getCurrentSeed()
Copyright © 2009 CIRG. All Rights Reserved.