public class RNG
extends java.util.Random
Constructor and Description |
---|
RNG()
Creates a new RNG and seeds it using the default seeding strategy.
|
RNG(byte[] seed)
Creates an RNG and seeds it with the specified seed data.
|
RNG(long seed)
Ignores the seed parameter.
|
Modifier and Type | Method and Description |
---|---|
double |
between(double min,
double max)
Returns a value from a even distribution from min (inclusive) to max
(exclusive).
|
int |
between(int min,
int max)
Returns a value between min and max inclusive.
|
int |
betweenWeighted(int min,
int max,
int samples)
Returns the average of a number of randomly selected numbers from the
provided range.
|
static int |
convertBytesToInt(byte[] bytes,
int offset)
Take four bytes from the specified position in the specified block and
convert them into a 32-bit int, using the big-endian convention.
|
static int[] |
convertBytesToInts(byte[] bytes)
Convert an array of bytes into an array of ints.
|
byte[] |
getSeed() |
protected int |
next(int bits) |
void |
setSeed(long seed) |
public RNG()
public RNG(long seed)
seed
- public RNG(byte[] seed)
seed
- The seed data used to initialize the RNG.public static int convertBytesToInt(byte[] bytes, int offset)
bytes
- The data to read from.offset
- The position to start reading the 4-byte int from.public static int[] convertBytesToInts(byte[] bytes)
bytes
- The data to read from.public byte[] getSeed()
public void setSeed(long seed)
setSeed
in class java.util.Random
protected final int next(int bits)
next
in class java.util.Random
public double between(double min, double max)
min
- max
- public int between(int min, int max)
min
- max
- public int betweenWeighted(int min, int max, int samples)
min
- max
- samples
-