public class EditRNG extends StatefulRNG implements java.io.Serializable
RNG.CustomRandom| Modifier and Type | Field and Description |
|---|---|
double |
rawLatest
The latest generated double, between 0.0 and 1.0, before changes for centrality and expected average.
|
| Constructor and Description |
|---|
EditRNG()
Constructs an EditRNG with a pseudo-random seed from Math.random().
|
EditRNG(java.lang.CharSequence seed)
Construct a new EditRNG with the given seed.
|
EditRNG(long seed)
Construct a new EditRNG with the given seed.
|
EditRNG(long seed,
double expected)
Construct a new EditRNG with the given seed.
|
EditRNG(long seed,
double expected,
double centrality)
Construct a new EditRNG with the given seed.
|
EditRNG(RandomnessSource rs)
Construct a new EditRNG with the given seed.
|
EditRNG(RandomnessSource rs,
double expected)
Construct a new EditRNG with the given seed.
|
EditRNG(RandomnessSource rs,
double expected,
double centrality)
Construct a new EditRNG with the given seed.
|
EditRNG(java.lang.String seed,
double expected)
Construct a new EditRNG with the given seed.
|
EditRNG(java.lang.String seed,
double expected,
double centrality)
Construct a new EditRNG with the given seed.
|
| Modifier and Type | Method and Description |
|---|---|
EditRNG |
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.
|
boolean |
equals(java.lang.Object o) |
double |
getCentrality()
Gets the current centrality measure of this EditRNG.
|
double |
getExpected()
Gets the current expected average for this EditRNG.
|
RandomnessSource |
getRandomness() |
double |
getRawLatest()
Gets the latest "un-biased" random double used to produce the most recent (potentially) biased random number
generated for another method in this class, such as nextDouble(), between(), or getRandomElement().
|
int |
hashCode() |
int |
next(int bits)
Get up to 32 bits (inclusive) of random output; the int this produces
will not require more than
bits bits to represent. |
boolean |
nextBoolean()
Get a random bit of state, interpreted as true or false with approximately equal likelihood.
|
double |
nextDouble()
Generate a random double, altered to try to match the expected average and centrality.
|
double |
nextDouble(double max)
This returns a random double between 0.0 (inclusive) and max (exclusive).
|
float |
nextFloat()
Gets a random float between 0.0f inclusive and 1.0f exclusive.
|
int |
nextInt()
Returns a random integer, which may be positive or negative.
|
int |
nextInt(int bound)
Returns a random integer below the given bound, or 0 if the bound is 0 or
negative.
|
int |
nextIntHasty(int bound)
Returns a random non-negative integer below the given bound, or 0 if the bound is 0.
|
long |
nextLong()
Returns a random long, which may be positive or negative.
|
long |
nextLong(long bound)
Returns a random long below the given bound, or 0 if the bound is 0 or
negative.
|
void |
setCentrality(double centrality)
Gets the current centrality measure of this EditRNG.
|
void |
setExpected(double expected)
Sets the expected average for random doubles this produces, which must always be between 0.1 and 0.9, and will be
set to 0.5 if an invalid value is passed.
|
void |
setRandomness(RandomnessSource random) |
java.io.Serializable |
toSerializable()
Returns this EditRNG in a way that can be deserialized even if only
IRNG's methods can be called. |
java.lang.String |
toString() |
getState, setStateapproximateBits, asRandom, betweenWeighted, getRandomCellsIterable, getRandomElement, getRandomStartIterable, getRandomUniqueCells, getRandomUniqueCells, getRandomUniqueCells, maxDoubleOf, maxFloatOf, maxIntOf, maxLongOf, minDoubleOf, minFloatOf, minIntOf, minLongOf, nextBytes, nextCoord, nextCurvedFloat, nextDoubleInclusive, nextDoubleInclusive, nextFloatInclusive, nextFloatInclusive, randomInterleave, randomOrdering, randomOrdering, randomPortion, randomPortion, randomRange, randomRotation, shuffle, shuffle, shuffle, shuffle, shuffleInPlace, shuffleInPlacebetween, between, between, getRandomElement, getRandomElement, nextFloat, nextSignedInt, nextSignedLong, swapclone, finalize, getClass, notify, notifyAll, wait, wait, waitbetween, between, between, getRandomElement, getRandomElement, getRandomElement, nextFloat, nextSignedInt, nextSignedLong, randomOrdering, randomOrdering, randomPortion, shuffle, shuffle, shuffle, shuffle, shuffleInPlace, shuffleInPlacepublic double rawLatest
public EditRNG()
public EditRNG(long seed)
seed - used to seed the default RandomnessSource.public EditRNG(java.lang.CharSequence seed)
seed - used to seed the default RandomnessSource.public EditRNG(long seed,
double expected)
seed - used to seed the default RandomnessSource.expected - the expected average for random doubles, which will be capped between 0.1 and 0.9public EditRNG(java.lang.String seed,
double expected)
seed - used to seed the default RandomnessSource.expected - the expected average for random doubles, which will be capped between 0.1 and 0.9public EditRNG(long seed,
double expected,
double centrality)
seed - used to seed the default RandomnessSource.expected - the expected average for random doubles, which will be capped between 0.1 and 0.9centrality - if positive, makes results more likely to be near expected; if negative, the opposite. The
absolute value of centrality affects how centered results will be, with 0 having no effectpublic EditRNG(java.lang.String seed,
double expected,
double centrality)
seed - used to seed the default RandomnessSource.expected - the expected average for random doubles, which will be capped between 0.1 and 0.9centrality - if positive, makes results more likely to be near expected; if negative, the opposite. The
absolute value of centrality affects how centered results will be, with 0 having no effectpublic EditRNG(RandomnessSource rs)
rs - the implementation used to generate random bits.public EditRNG(RandomnessSource rs, double expected)
rs - the implementation used to generate random bits.expected - the expected average for random doubles, which will be capped between 0.1 and 0.9public EditRNG(RandomnessSource rs, double expected, double centrality)
rs - the implementation used to generate random bits.expected - the expected average for random doubles, which will be capped between 0.1 and 0.9centrality - if positive, makes results more likely to be near expected; if negative, the opposite. The
absolute value of centrality affects how centered results will be, with 0 having no effectpublic double nextDouble()
nextDouble in interface IRNGnextDouble in class RNGpublic double nextDouble(double max)
nextDouble in interface IRNGnextDouble in class AbstractRNGmax - the outer exclusive bound as a double; can be negative or positivepublic int nextInt(int bound)
nextInt in interface IRNGnextInt in class AbstractRNGbound - the upper bound (exclusive)public int nextInt()
public long nextLong()
public long nextLong(long bound)
nextLong in interface IRNGnextLong in class AbstractRNGbound - the upper bound (exclusive)public double getExpected()
public void setExpected(double expected)
expected - the expected average to use, which should be 0.1 <= fairness < 0.9public double getCentrality()
public void setCentrality(double centrality)
centrality - the new centrality measure to usepublic int next(int bits)
RNGbits bits to represent.public float nextFloat()
RNGpublic boolean nextBoolean()
RNGrng.next(1), depending on the RandomnessSource implementation; the
default DiverRNG will behave fine, as will LightRNG and ThrustAltRNG (these all use similar algorithms), but
the normally-high-quality XoRoRNG will produce very predictable output with rng.next(1) and very good
output with rng.nextBoolean(). This is a known and considered flaw of Xoroshiro128+, the algorithm used
by XoRoRNG, and a large number of generators have lower quality on the least-significant bit than the most-
significant bit, where this method only checks the most-significant bit.nextBoolean in interface IRNGnextBoolean in class RNGpublic RandomnessSource getRandomness()
getRandomness in class RNGpublic void setRandomness(RandomnessSource random)
setRandomness in class StatefulRNGpublic double getRawLatest()
public EditRNG copy()
copy in interface RandomnessSourcecopy in interface StatefulRandomnesscopy in class StatefulRNGpublic java.lang.String toString()
toString in class StatefulRNGpublic int nextIntHasty(int bound)
nextIntHasty in class RNGbound - the upper bound (exclusive); behavior is undefined if bound is negativepublic java.io.Serializable toSerializable()
IRNG's methods can be called.toSerializable in interface IRNGtoSerializable in class StatefulRNGSerializable view of this EditRNG; always thisCopyright © Eben Howard 2012–2022. All rights reserved.