Class XoshiroStarPhi32RNG
java.lang.Object
java.util.Random
com.github.tommyettinger.random.EnhancedRandom
com.github.yellowstonegames.old.v300.LegacyRandom
com.github.yellowstonegames.old.v300.XoshiroStarPhi32RNG
- All Implemented Interfaces:
Externalizable, Serializable, RandomGenerator
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface RandomGenerator
RandomGenerator.ArbitrarilyJumpableGenerator, RandomGenerator.JumpableGenerator, RandomGenerator.LeapableGenerator, RandomGenerator.SplittableGenerator, RandomGenerator.StreamableGenerator -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new generator seeded using four calls to Math.random().XoshiroStarPhi32RNG(int seed) Constructs this XoshiroStarPhi32RNG by dispersing the bits of seed usingsetSeed(int)across the four parts of state this has.XoshiroStarPhi32RNG(int stateA, int stateB, int stateC, int stateD) Constructs this XoshiroStarPhi32RNG by callingsetState(int, int, int, int)on stateA and stateB as given; see that method for the specific details (the states are kept as-is unless they are all 0).XoshiroStarPhi32RNG(long seed) Constructs this XoshiroStarPhi32RNG by dispersing the bits of seed usingsetSeed(long)across the four parts of state this has. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Produces a copy of this RandomnessSource that, if next() and/or nextLong() are called on this object and the copy, both will generate the same sequence of random numbers from the point copy() was called.booleanlonggetSelectedState(int selection) intintintintintgetTag()inthashCode()intnext(int bits) intnextInt()Can return any int, positive or negative, of any size permissible in a 32-bit signed integer.longnextLong()voidsetSeed(int seed) Sets the state of this generator using one int, running it through a GWT-compatible variant of SplitMix32 four times to get four ints of state, all guaranteed to be different.voidsetSeed(long seed) Sets the state of this generator using one long, running it through a GWT-compatible variant of SplitMix32 four times to get four ints of state, guaranteed to repeat a state no more than two times.voidsetSelectedState(int selection, long value) voidsetState(int stateA, int stateB, int stateC, int stateD) Sets the current internal state of this XoshiroStarPhi32RNG with four ints, where each can be any int unless they are all 0 (which will be treated as if stateA is 1 and the rest are 0).voidsetStateA(int stateA) Sets the first part of the state to the given int.voidsetStateB(int stateB) Sets the second part of the state to the given int.voidsetStateC(int stateC) Sets the third part of the state to the given int.voidsetStateD(int stateD) Sets the second part of the state to the given int.toString()Methods inherited from class LegacyRandom
nextDouble, nextFloat, nextInt, nextSignedInt, nextSignedLongMethods inherited from class com.github.tommyettinger.random.EnhancedRandom
appendSerialized, appendSerialized, areEqual, fixGamma, fixGamma, getMinimumPeriod, lcm, mainlyGeneratesInt, maxDoubleOf, maxFloatOf, maxIntOf, maxLongOf, minDoubleOf, minFloatOf, minIntOf, minLongOf, nextBoolean, nextBoolean, nextBytes, nextDouble, nextDouble, nextExclusiveDouble, nextExclusiveDouble, nextExclusiveDouble, nextExclusiveDoubleEquidistant, nextExclusiveFloat, nextExclusiveFloat, nextExclusiveFloat, nextExclusiveFloatEquidistant, nextExclusiveSignedDouble, nextExclusiveSignedFloat, nextExponential, nextFloat, nextFloat, nextGaussian, nextGaussian, nextGaussianFloat, nextGaussianFloat, nextInclusiveDouble, nextInclusiveDouble, nextInclusiveDouble, nextInclusiveFloat, nextInclusiveFloat, nextInclusiveFloat, nextInt, nextLong, nextLong, nextSign, nextSignedInt, nextSignedLong, nextTriangular, nextTriangular, nextTriangular, nextTriangular, nextUnsignedInt, previousInt, previousLong, probit, processSignedInt32, processUnsignedInt32, randomElement, randomElement, rateGamma, readExternal, seedFromMath, setState, setState, setState, setState, setState, setState, setState, setState, setState, setState, setState, setWith, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, skip, stringDeserialize, stringDeserialize, stringSerialize, stringSerialize, writeExternalMethods inherited from class Random
doubles, doubles, doubles, doubles, from, ints, ints, ints, ints, longs, longs, longs, longsMethods inherited from interface RandomGenerator
equiDoubles, isDeprecated
-
Field Details
-
stateA
protected int stateA -
stateB
protected int stateB -
stateC
protected int stateC -
stateD
protected int stateD
-
-
Constructor Details
-
XoshiroStarPhi32RNG
public XoshiroStarPhi32RNG()Creates a new generator seeded using four calls to Math.random(). -
XoshiroStarPhi32RNG
public XoshiroStarPhi32RNG(int seed) Constructs this XoshiroStarPhi32RNG by dispersing the bits of seed usingsetSeed(int)across the four parts of state this has.- Parameters:
seed- an int that won't be used exactly, but will affect all components of state
-
XoshiroStarPhi32RNG
public XoshiroStarPhi32RNG(long seed) Constructs this XoshiroStarPhi32RNG by dispersing the bits of seed usingsetSeed(long)across the four parts of state this has.- Parameters:
seed- a long that will be split across all components of state
-
XoshiroStarPhi32RNG
public XoshiroStarPhi32RNG(int stateA, int stateB, int stateC, int stateD) Constructs this XoshiroStarPhi32RNG by callingsetState(int, int, int, int)on stateA and stateB as given; see that method for the specific details (the states are kept as-is unless they are all 0).- Parameters:
stateA- the number to use as the first part of the state; this will be 1 instead if both seeds are 0stateB- the number to use as the second part of the statestateC- the number to use as the third part of the statestateD- the number to use as the fourth part of the state
-
-
Method Details
-
getTag
- Specified by:
getTagin classcom.github.tommyettinger.random.EnhancedRandom
-
next
public int next(int bits) - Overrides:
nextin classcom.github.tommyettinger.random.EnhancedRandom
-
nextInt
public int nextInt()Can return any int, positive or negative, of any size permissible in a 32-bit signed integer.- Specified by:
nextIntin interfaceRandomGenerator- Overrides:
nextIntin classcom.github.tommyettinger.random.EnhancedRandom- Returns:
- any int, all 32 bits are random
-
nextLong
public long nextLong()- Specified by:
nextLongin interfaceRandomGenerator- Specified by:
nextLongin classcom.github.tommyettinger.random.EnhancedRandom
-
copy
Produces a copy of this RandomnessSource that, if next() and/or nextLong() are called on this object and the copy, both will generate the same sequence of random numbers from the point copy() was called. This just needs to copy the state so it isn't shared, usually, and produce a new value with the same exact state.- Specified by:
copyin classcom.github.tommyettinger.random.EnhancedRandom- Returns:
- a copy of this RandomnessSource
-
setSeed
public void setSeed(int seed) Sets the state of this generator using one int, running it through a GWT-compatible variant of SplitMix32 four times to get four ints of state, all guaranteed to be different.- Parameters:
seed- the int to use to produce this generator's states
-
setSeed
public void setSeed(long seed) Sets the state of this generator using one long, running it through a GWT-compatible variant of SplitMix32 four times to get four ints of state, guaranteed to repeat a state no more than two times.- Specified by:
setSeedin classcom.github.tommyettinger.random.EnhancedRandom- Parameters:
seed- the long to use to produce this generator's states
-
getStateA
public int getStateA() -
setStateA
public void setStateA(int stateA) Sets the first part of the state to the given int. As a special case, if the parameter is 0 and this would set all states to be 0, this will set stateA to 1 instead. Usually, you should usesetState(int, int, int, int)to set all four states at once, but the result will be the same if you set the four states individually.- Parameters:
stateA- any int
-
getStateB
public int getStateB() -
setStateB
public void setStateB(int stateB) Sets the second part of the state to the given int. As a special case, if the parameter is 0 and this would set all states to be 0, this will set stateA to 1 in addition to setting stateB to 0. Usually, you should usesetState(int, int, int, int)to set all four states at once, but the result will be the same if you set the four states individually.- Parameters:
stateB- any int
-
getStateC
public int getStateC() -
setStateC
public void setStateC(int stateC) Sets the third part of the state to the given int. As a special case, if the parameter is 0 and this would set all states to be 0, this will set stateA to 1 in addition to setting stateC to 0. Usually, you should usesetState(int, int, int, int)to set all four states at once, but the result will be the same if you set the four states individually.- Parameters:
stateC- any int
-
getStateD
public int getStateD() -
setStateD
public void setStateD(int stateD) Sets the second part of the state to the given int. As a special case, if the parameter is 0 and this would set all states to be 0, this will set stateA to 1 in addition to setting stateD to 0. Usually, you should usesetState(int, int, int, int)to set all four states at once, but the result will be the same if you set the four states individually.- Parameters:
stateD- any int
-
setState
public void setState(int stateA, int stateB, int stateC, int stateD) Sets the current internal state of this XoshiroStarPhi32RNG with four ints, where each can be any int unless they are all 0 (which will be treated as if stateA is 1 and the rest are 0).- Parameters:
stateA- any int (if all parameters are both 0, this will be treated as 1)stateB- any intstateC- any intstateD- any int
-
getStateCount
public int getStateCount()- Overrides:
getStateCountin classcom.github.tommyettinger.random.EnhancedRandom
-
getSelectedState
public long getSelectedState(int selection) - Overrides:
getSelectedStatein classcom.github.tommyettinger.random.EnhancedRandom
-
setSelectedState
public void setSelectedState(int selection, long value) - Overrides:
setSelectedStatein classcom.github.tommyettinger.random.EnhancedRandom
-
toString
-
equals
-
hashCode
-