public class LongPeriodRNG extends Object implements RandomnessSource
Constructor and Description |
---|
LongPeriodRNG()
Builds a LongPeriodRNG and initializes this class' 1024 bits of state with a random seed passed into SplitMix64,
the algorithm also used by LightRNG.
|
LongPeriodRNG(long seed)
Builds a LongPeriodRNG and initializes this class' 1024 bits of state with many calls to a SplitMix64-based RNG
with a random seed influenced by Math.random() and also the time (in milliseconds to keep GWT compatibility),
mixing Math.random() calls in to alter the SplitMix64 state at uneven intervals.
|
LongPeriodRNG(long[] seed)
Builds a LongPeriodRNG and initializes this class' 1024 bits of state with the given seed as a long array, which
may or may not have 16 elements (though it is less wasteful to run this with 16 longs since that is exactly 1024
bits).
|
LongPeriodRNG(LongPeriodRNG other) |
LongPeriodRNG(String seed)
Builds a LongPeriodRNG and initializes this class' 1024 bits of state with the given seed, using a different
strategy depending on the seed.
|
Modifier and Type | Method and Description |
---|---|
RandomnessSource |
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.
|
static LongPeriodRNG[] |
createMany(int count)
Creates many LongPeriodRNG objects in an array, where each will generate a sequence of 2 to the 512 numbers that
will not overlap with other sequences in the array.
|
static LongPeriodRNG[] |
createMany(int count,
long seed)
Creates many LongPeriodRNG objects in an array, where each will generate a sequence of pow(2, 512) numbers that
will not overlap with other sequences in the array.
|
static LongPeriodRNG[] |
createMany(int count,
long[] seed)
Creates many LongPeriodRNG objects in an array, where each will generate a sequence of pow(2, 512) numbers that
will not overlap with other sequences in the array.
|
static LongPeriodRNG[] |
createMany(int count,
String seed)
Creates many LongPeriodRNG objects in an array, where each will generate a sequence of pow(2, 512) numbers that
will not overlap with other sequences in the array.
|
void |
jump()
This is the jump function for the generator.
|
int |
next(int bits)
Using this method, any algorithm that might use the built-in Java Random
can interface with this randomness source.
|
long |
nextLong()
Can return any long, positive or negative, of any size permissible in a 64-bit signed integer.
|
void |
reseed() |
void |
reseed(long seed)
Reinitializes this class' 1024 bits of state with the given seed passed into SplitMix64, the algorithm also used by
LightRNG.
|
void |
reseed(long[] seed)
Reinitializes this class' 1024 bits of state with the given seed as a long array, which may or may not have 16
elements (though it is less wasteful to run this with 16 longs since that is exactly 1024 bits).
|
void |
reseed(String seed)
Reinitializes this class' 1024 bits of state with the given seed, using a different strategy depending on the seed.
|
String |
toString() |
public LongPeriodRNG()
public LongPeriodRNG(long seed)
seed
- a 64-bit seed; can be any value.public LongPeriodRNG(String seed)
seed
- a String seed; can be any value, but produces the best results if it at least 16 characters longpublic LongPeriodRNG(long[] seed)
seed
- a long array seed; can have any number of elements, though 16 is idealpublic LongPeriodRNG(LongPeriodRNG other)
public void reseed()
public void reseed(long seed)
seed
- a 64-bit seed; can be any value.public void reseed(String seed)
seed
- a String seed; can be any value, but produces the best results if it at least 16 characters longpublic void reseed(long[] seed)
seed
- a long array seed; can have any number of elements, though 16 is idealpublic int next(int bits)
RandomnessSource
next
in interface RandomnessSource
bits
- the number of bits to be returnedpublic long nextLong()
nextLong
in interface RandomnessSource
public RandomnessSource copy()
copy
in interface RandomnessSource
public void jump()
public static LongPeriodRNG[] createMany(int count)
count
- the number of LongPeriodRNG objects to generate in the array.public static LongPeriodRNG[] createMany(int count, long seed)
count
- the number of LongPeriodRNG objects to generate in the array.seed
- the RNG seed that will determine the different sequences the returned LongPeriodRNG objects producepublic static LongPeriodRNG[] createMany(int count, String seed)
count
- the number of LongPeriodRNG objects to generate in the array.seed
- the RNG seed that will determine the different sequences the returned LongPeriodRNG objects producepublic static LongPeriodRNG[] createMany(int count, long[] seed)
count
- the number of LongPeriodRNG objects to generate in the array.seed
- the RNG seed that will determine the different sequences the returned LongPeriodRNG objects produceCopyright © 2012–2016. All rights reserved.