Class LegacyRandom
java.lang.Object
java.util.Random
com.github.tommyettinger.random.EnhancedRandom
com.github.yellowstonegames.old.v300.LegacyRandom
- All Implemented Interfaces:
Externalizable, Serializable, RandomGenerator
- Direct Known Subclasses:
DiverRNG, GWTRNG, LightRNG, LinnormRNG, LongPeriodRNG, SilkRNG, ThrustAltRNG, XoshiroStarPhi32RNG
public abstract class LegacyRandom
extends com.github.tommyettinger.random.EnhancedRandom
An alternate version of
EnhancedRandom that intentionally implements certain methods incorrectly, for
compatibility with SquidLib 3.0.0. Currently, nextSignedInt(int) and nextSignedLong(long) are
incorrectly implemented for compatibility, and that makes EnhancedRandom.nextSignedInt(int, int) incorrect too. Other
methods here are implemented as EnhancedRandom does in its default implementations.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface RandomGenerator
RandomGenerator.ArbitrarilyJumpableGenerator, RandomGenerator.JumpableGenerator, RandomGenerator.LeapableGenerator, RandomGenerator.SplittableGenerator, RandomGenerator.StreamableGenerator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleGets a random double between 0 and 1 (inclusive on 0, exclusive on 1).floatGets a random float between 0 and 1 (inclusive on 0, exclusive on 1).intnextInt(int bound) This is slightly different from how EnhancedRandom implements this method, and this version may have some bias for large bounds (more bias than EnhancedRandom has).intnextSignedInt(int outerBound) This is subtly incorrect; if outerBound is 0, then this returns 0 only very rarely, even if outerBound is small, like -1 or -2.longnextSignedLong(long outerBound) This is buggier than a bumblebee; do not use this in production.Methods inherited from class com.github.tommyettinger.random.EnhancedRandom
appendSerialized, appendSerialized, areEqual, copy, fixGamma, fixGamma, getMinimumPeriod, getSelectedState, getStateCount, getTag, lcm, mainlyGeneratesInt, maxDoubleOf, maxFloatOf, maxIntOf, maxLongOf, minDoubleOf, minFloatOf, minIntOf, minLongOf, next, 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, nextInt, nextLong, nextLong, nextLong, nextSign, nextSignedInt, nextSignedLong, nextTriangular, nextTriangular, nextTriangular, nextTriangular, nextUnsignedInt, previousInt, previousLong, probit, processSignedInt32, processUnsignedInt32, randomElement, randomElement, rateGamma, readExternal, seedFromMath, setSeed, setSelectedState, 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 class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface RandomGenerator
equiDoubles, isDeprecated
-
Constructor Details
-
LegacyRandom
public LegacyRandom()
-
-
Method Details
-
nextInt
public int nextInt(int bound) This is slightly different from how EnhancedRandom implements this method, and this version may have some bias for large bounds (more bias than EnhancedRandom has).- Specified by:
nextIntin interfaceRandomGenerator- Overrides:
nextIntin classcom.github.tommyettinger.random.EnhancedRandom- Parameters:
bound- the outer exclusive bound; if non-positive, this returns 0- Returns:
- a random int between 0 (inclusive) and bound (exclusive); never negative
-
nextSignedInt
public int nextSignedInt(int outerBound) This is subtly incorrect; if outerBound is 0, then this returns 0 only very rarely, even if outerBound is small, like -1 or -2. It is implemented as SquidLib 3.0.0 implemented it to reproduce behavior.- Overrides:
nextSignedIntin classcom.github.tommyettinger.random.EnhancedRandom- Parameters:
outerBound- outer bound, may be positive or negative- Returns:
- an int between 0 (inclusive, but very rarely) and outerBound (exclusive)
-
nextSignedLong
public long nextSignedLong(long outerBound) This is buggier than a bumblebee; do not use this in production. It is only here to reproduce bugs from 3.0.0.- Overrides:
nextSignedLongin classcom.github.tommyettinger.random.EnhancedRandom- Parameters:
outerBound- the outer bound, positive or negative; will probably not be respected- Returns:
- honestly, this could return anything -- a whale and a potted plant are possibilities
-
nextDouble
public double nextDouble()Gets a random double between 0 and 1 (inclusive on 0, exclusive on 1). This one isn't incorrectly implemented, it's just different from how EnhancedRandom does it.- Specified by:
nextDoublein interfaceRandomGenerator- Overrides:
nextDoublein classcom.github.tommyettinger.random.EnhancedRandom- Returns:
- a random double between 0 (inclusive) and 1 (exclusive)
-
nextFloat
public float nextFloat()Gets a random float between 0 and 1 (inclusive on 0, exclusive on 1). This one isn't incorrectly implemented, it's just different from how EnhancedRandom does it.- Specified by:
nextFloatin interfaceRandomGenerator- Overrides:
nextFloatin classcom.github.tommyettinger.random.EnhancedRandom- Returns:
- a random float between 0 (inclusive) and 1 (exclusive)
-