Adventure at Umalu  22nd March, 2013
Rogue-like Dungeon Crawler, written in Java
 All Classes Functions Variables Pages
Public Member Functions | Static Public Attributes | List of all members
jade.util.Dice Class Reference

Public Member Functions

 Dice (int seed)
 
 Dice ()
 
void reseed (int seed)
 
final void reseed ()
 
int nextInt ()
 
final int nextInt (int max)
 
final int nextInt (int min, int max)
 
final boolean chance (int odds, int total)
 
final boolean chance (int percent)
 
final boolean chance ()
 

Static Public Attributes

static final Dice global = new Dice()
 

Detailed Description

A pseudo-random number generator.

Constructor & Destructor Documentation

jade.util.Dice.Dice ( int  seed)

Constructs a new

and initializes it with the given seed.

Parameters
seedthe seed of the pseudo-random number generator
jade.util.Dice.Dice ( )

Constructs a new

and initializes it with a seed based on the current clock.

Member Function Documentation

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
oddsthe probability of true
totalthe 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
percentthe 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
maxthe 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
minthe lower bound (inclusive) of the generated integer
maxthe 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
seedthe 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.

Member Data Documentation

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: