**USING RANDOM NUMBER & MATH FUNCTIONS IN VASSAL**

If you use Beanshell expressions (the expressions displayed in { } or in the Expression field of a Calculated Property), then all of the Java math functions are available to you.

**RANDOM NUMBERS:**

**Random(6)** will return a random number between 1 and 6.

**Random(min, max)** will return a number between “min” and “max”.

**IsRandom()** will return true 50% of the time.

**IsRandom(pct)** will return trure pct% of the time.

**MATH FUNCTIONS:**

IMPORTANT: Vassal properties must be defined as numerical so that Java sees them as such!!!

So for example: **Math.abs(MaybeNegative)** returns the absolute value of the property MaybeNegative.

**Math.max(OneValue, OtherValue)** returns the larger of OneValue and OtherValue.

**Math.min(OneValue, OtherValue)** returns the smaller of OneValue and OtherValue.

A complete list of the Math class methods can be found at e.g. Oracle Java Docs and the useful ones are included in the Beanshell Expression Builder.