A pseudo-random number generator.
jade.util.Dice.Dice |
( |
int |
seed | ) |
|
Constructs a new
and initializes it with the given seed.
- Parameters
-
seed | the seed of the pseudo-random number generator |
Constructs a new
and initializes it with a seed based on the current clock.
final boolean jade.util.Dice.chance |
( |
int |
odds, |
|
|
int |
total |
|
) |
| |
Returns true with a probability of odds / total. Odds must be non-negative and less than or equal to total.
- Parameters
-
odds | the probability of true |
total | the total amount of probability |
- Returns
- true with probability odds / total
final boolean jade.util.Dice.chance |
( |
int |
percent | ) |
|
Returns true with a probability of percent / 100.
- Parameters
-
percent | the probability of true |
- Returns
- true with probability percent / 100
final boolean jade.util.Dice.chance |
( |
| ) |
|
Returns true with a probability of 1/2.
- Returns
- true with probability 1/2
int jade.util.Dice.nextInt |
( |
| ) |
|
Returns a random non-negative integer.
- Returns
- a random non-negative integer
final int jade.util.Dice.nextInt |
( |
int |
max | ) |
|
Returns a random non-negative integer strictly less than the max. Note that max must be a non-negative integer.
- Parameters
-
max | the upper bound (exclusive) of the generated integer |
- Returns
- a random non-negative integer
final int jade.util.Dice.nextInt |
( |
int |
min, |
|
|
int |
max |
|
) |
| |
Returns a random non-negative integer between min and max (inclusive). Note that min must be less than max.
- Parameters
-
min | the lower bound (inclusive) of the generated integer |
max | the upper bound (inclusive) of the generated integer |
- Returns
- a random non-negative integer
void jade.util.Dice.reseed |
( |
int |
seed | ) |
|
Reseeds the pseudo-random number generator with the given seed. The sequence of numbers generated after being given any particular seed is unique. In other words, after each call to
with the same seed, the results of the generator will be identical.
- Parameters
-
seed | the new seed of the pseudo-random number generator |
final void jade.util.Dice.reseed |
( |
| ) |
|
Reseeds the pseudo-random number generator with a seed chosen based on the current clock time.
final Dice jade.util.Dice.global = new Dice() |
|
static |
The global instance of
. This instance is to be used when a unique instance is not needed, and as a default value for any call requiring
. It is recommended, but not enforced, that reseed NOT be called on this instance, as this might reduce randomness in other parts of a Jade system.
The documentation for this class was generated from the following file: