diff --git a/src/java/com/samskivert/util/RandomUtil.java b/src/java/com/samskivert/util/RandomUtil.java index 4ca99698..9765b809 100644 --- a/src/java/com/samskivert/util/RandomUtil.java +++ b/src/java/com/samskivert/util/RandomUtil.java @@ -69,9 +69,21 @@ public class RandomUtil */ public static float getFloat (float high) { - return rand.nextFloat() * high; + return getFloat(high, rand); } + /** + * Returns a pseudorandom, uniformly distributed float value between + * 0.0 (inclusive) and the specified value (exclusive). + * + * @param high the high value limiting the random number sought. + * @param r the random number generator to use + */ + public static float getFloat (float high, Random r) + { + return r.nextFloat() * high; + } + /** * Pick a random index from the array, weighted by the value of the * corresponding array element. @@ -120,6 +132,25 @@ public class RandomUtil *
| 0 | 1/8th of the time |
| 1 | never |
| 2 | 3/8th of the time |
| 3 | half of the time |