public class StatefulRNG extends RNG implements java.io.Serializable, IStatefulRNG
RNG.CustomRandom| Constructor and Description |
|---|
StatefulRNG() |
StatefulRNG(java.lang.CharSequence seedString)
String-seeded constructor uses the hash of the String as a seed for DiverRNG, which is of high quality, but
low period (which rarely matters for games), and has good speed and tiny state size.
|
StatefulRNG(long seed)
Seeded constructor uses DiverRNG, which is of high quality, but low period (which rarely matters for games),
and has good speed and tiny state size.
|
StatefulRNG(RandomnessSource random) |
| Modifier and Type | Method and Description |
|---|---|
StatefulRNG |
copy()
Creates a copy of this StatefulRNG; it will generate the same random numbers, given the same calls in order, as
this StatefulRNG at the point copy() is called.
|
long |
getState()
Get a long that can be used to reproduce the sequence of random numbers this object will generate starting now.
|
void |
setRandomness(RandomnessSource random) |
void |
setState(long state)
Sets the state of the random number generator to a given long, which will alter future random numbers this
produces based on the state.
|
java.io.Serializable |
toSerializable()
Returns this StatefulRNG in a way that can be deserialized even if only
IRNG's methods can be called. |
java.lang.String |
toString() |
approximateBits, asRandom, betweenWeighted, equals, getRandomCellsIterable, getRandomElement, getRandomness, getRandomStartIterable, getRandomUniqueCells, getRandomUniqueCells, getRandomUniqueCells, hashCode, maxDoubleOf, maxFloatOf, maxIntOf, maxLongOf, minDoubleOf, minFloatOf, minIntOf, minLongOf, next, nextBoolean, nextBytes, nextCoord, nextCurvedFloat, nextDouble, nextDoubleInclusive, nextDoubleInclusive, nextFloat, nextFloatInclusive, nextFloatInclusive, nextInt, nextIntHasty, nextLong, randomInterleave, randomOrdering, randomOrdering, randomPortion, randomPortion, randomRange, randomRotation, shuffle, shuffle, shuffle, shuffle, shuffleInPlace, shuffleInPlacebetween, between, between, getRandomElement, getRandomElement, nextDouble, nextFloat, nextInt, nextLong, nextSignedInt, nextSignedLong, swapclone, finalize, getClass, notify, notifyAll, wait, wait, waitbetween, between, between, getRandomElement, getRandomElement, getRandomElement, next, nextBoolean, nextDouble, nextDouble, nextFloat, nextFloat, nextInt, nextInt, nextLong, nextLong, nextSignedInt, nextSignedLong, randomOrdering, randomOrdering, randomPortion, shuffle, shuffle, shuffle, shuffle, shuffleInPlace, shuffleInPlacepublic StatefulRNG()
public StatefulRNG(RandomnessSource random)
public StatefulRNG(long seed)
public StatefulRNG(java.lang.CharSequence seedString)
new StatefulRNG(text) with new StatefulRNG(new LightRNG(CrossHash.hash(text))). The new technique
assigns to all 64 bits and has less correlation between similar inputs causing similar starting states. It's also
faster, but that shouldn't matter in a constructor. It uses a better hashing algorithm because CrossHash no
longer has the older, worse one. The latest change in June switched to DiverRNG instead of LightRNG.public void setRandomness(RandomnessSource random)
setRandomness in class RNGpublic StatefulRNG copy()
copy in interface RandomnessSourcecopy in interface StatefulRandomnesscopy in class RNGpublic long getState()
getState in interface StatefulRandomnesspublic void setState(long state)
setState in interface StatefulRandomnessstate - a long, which typically should not be 0 (some implementations may tolerate a state of 0, however).public java.io.Serializable toSerializable()
IRNG's methods can be called.toSerializable in interface IRNGtoSerializable in class RNGSerializable view of this StatefulRNG; always thisCopyright © Eben Howard 2012–2022. All rights reserved.