|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbluegammon.logic.Rand
Global random generator. It must be global so all methods needing random values accesses the same methods. This is because we want similar behaviour on both devices in a remote game, which is achieved by agreeing on a mutual seed.
Method Summary | |
static int |
loadSeed(java.io.DataInputStream dis)
Loads the seed into random generator. |
static int |
random()
Returns a random integer ranging from Integer.MIN_VALUE to Integer.MAX_VALUE. |
static float |
randomFloat()
Returns a random float ranging from -1.0f to 1.0f. |
static int |
saveSeed(java.io.DataOutputStream dos)
Writes the seed used by random generator. |
static void |
setRandomSeed(long seed)
Sets the seed of the random generator. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static void setRandomSeed(long seed)
seed
- The seed of the random generator.public static int random()
public static float randomFloat()
public static int loadSeed(java.io.DataInputStream dis) throws java.io.IOException
dis
- The stream to read from.
java.io.IOException
- if loading failedpublic static int saveSeed(java.io.DataOutputStream dos) throws java.io.IOException
dos
- The stream to write to,
java.io.IOException
- if saving failed
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |