Package megamek.common
Class MMRandom
java.lang.Object
megamek.common.MMRandom
Used by Compute to generate random numbers, usually dice rolls. The base class is abstract, having a number of
 concrete subclasses that it will give using the generate() method.
- Since:
- April 27, 2003, 11:29 PM
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptiond6()A single died6(int nDice) Simulates six-sided die rolls.d6(int nDice, int keep) static MMRandomgenerate(int type) Gives you the type asked for, defaulting to SunRandom if there are any errors.abstract floatReturns a randomfloatin the range of 0 to 1abstract intrandomInt(int maxValue) Returns a randomintin the range from 0 to one less than the supplied max value.
- 
Field Details- 
R_DEFAULTpublic static final int R_DEFAULT- See Also:
 
- 
R_SUNpublic static final int R_SUN- See Also:
 
- 
R_CRYPTOpublic static final int R_CRYPTO- See Also:
 
- 
R_POOL36public static final int R_POOL36- See Also:
 
 
- 
- 
Constructor Details- 
MMRandompublic MMRandom()
 
- 
- 
Method Details- 
generateGives you the type asked for, defaulting to SunRandom if there are any errors.
- 
d6Simulates six-sided die rolls.- Parameters:
- nDice- - the- intnumber of dice to roll. If this value is less than or equal to zero, an- IllegalArgumentExceptionwill be thrown.
- Returns:
- a Rollobject containing the roll results.
- Throws:
- IllegalArgumentException- will be thrown if the input is <= 0.
 
- 
d6
- 
d6A single die
- 
randomIntpublic abstract int randomInt(int maxValue) Returns a randomintin the range from 0 to one less than the supplied max value.- Parameters:
- maxValue- - the smallest- intvalue which will exceed any random number returned by this method.
- Returns:
- a random intfrom the value set [0, maxValue).
 
- 
randomFloatpublic abstract float randomFloat()Returns a randomfloatin the range of 0 to 1- Returns:
- a random floatfrom the value set [0, 1]
 
 
-