public class IsaacRNG extends java.lang.Object implements RandomnessSource
Constructor and Description |
---|
IsaacRNG()
Constructs an IsaacRNG with no seed; this will produce one sequence of numbers as if the seed were 0
(which it essentially is, though passing 0 to the constructor that takes a long will produce a different
sequence) instead of what the other RandomnessSources do (initialize with a low-quality random number
from Math.random()).
|
IsaacRNG(long seed)
Constructs an IsaacRNG with its state filled by the value of seed, run through the LightRNG algorithm.
|
IsaacRNG(long[] seed)
Constructs an IsaacRNG with the given seed, which should be a rather large array of long values.
|
IsaacRNG(java.lang.String seed)
Constructs an IsaacRNG with its state filled by repeated hashing of seed.
|
Modifier and Type | Method and Description |
---|---|
IsaacRNG |
copy()
Produces another RandomnessSource, but the new one will not produce the same data as this one.
|
boolean |
equals(java.lang.Object o) |
void |
fillBlock(long[] data)
Generates enough pseudo-random long values to fill
data and assigns them to it. |
void |
init(boolean flag)
Initializes this IsaacRNG; typically used from the constructor but can be called externally.
|
void |
init(long seed)
Can be used to re-initialize this IsaacRNG as if using the single-long constructor.
|
void |
init(long[] seed)
Can be used to re-initialize this IsaacRNG as if using the long-array constructor.
|
void |
init(java.lang.String seed)
Can be used to re-initialize this IsaacRNG as if using the single-String constructor.
|
int |
next(int bits)
Using this method, any algorithm that might use the built-in Java Random
can interface with this randomness source.
|
long[] |
nextBlock()
Generates and returns a block of 256 pseudo-random long values.
|
long |
nextLong()
Using this method, any algorithm that needs to efficiently generate more
than 32 bits of random data can interface with this randomness source.
|
void |
regen()
Generates 256 results to be used by later calls to next() or nextLong().
|
java.lang.String |
toString() |
public IsaacRNG()
public IsaacRNG(long[] seed)
seed
- an array of longs to use as a seed; ideally it should be 256 individual longspublic IsaacRNG(long seed)
seed
- any long; will have equal influence on all bits of statepublic IsaacRNG(java.lang.String seed)
seed
- a String that should be exceptionally long to get the best results.public final void regen()
public void init(long[] seed)
seed
- an array of longs to use as a seed; ideally it should be 256 individual longspublic void init(long seed)
seed
- any long; will have equal influence on all bits of statepublic final void init(java.lang.String seed)
seed
- a String; if non-null, its contents will be used as a seedpublic final void init(boolean flag)
flag
- if true, use data from seed; if false, initializes this to unseeded random statepublic final long nextLong()
RandomnessSource
nextLong
in interface RandomnessSource
public final long[] nextBlock()
public final void fillBlock(long[] data)
data
and assigns them to it.public final int next(int bits)
RandomnessSource
next
in interface RandomnessSource
bits
- the number of bits to be returnedpublic final IsaacRNG copy()
copy
in interface RandomnessSource
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © Eben Howard 2012–2022. All rights reserved.