Fast Dice Statistics...

In Java!



After a good long time of the above applet not working, it should but up and rolling. The small text entry fields at the top provide a place to enter the number of die, the numbers of sides on each die, and the number you are attempting to hit. The All button will generate statistics for the complete range of numbers that can be rolled, from number to number times sides. The single button will generate statistics only for the target number specified. Each time the Single button is hit, the target field increments by one.

The Verbose check box simplifies the output to the ways to hit field only. I hope one can cut/paste from the big text field into a spread sheet if Verbose is disabled.

The percent numbers with Verbose check provide the exact chance of rolling the target number, and the chance of rolling that number or lower.

There are range checks on all the numbers entered. No more than 15 dice are allowed, or 15 sides per dice. I experimented with 20 20 sided die briefly, and saw overflow errors in 64 bit math. Yes, folk, we are talking big numbers here. Hopefully, 15 and 15 will prove sufficient for your needs. If you enter an out of range number, an error message will be put in the display field, and a valid in range number will be substituted.

If you are rolling a half dozen dice with a half dozen sides, you should not have problems with overflow or delay. If you start rolling 10 or more dice, you may have to be patient, and you could easily overflow the integer math used.

The above code is not as shown in the listing. I found the code loads cleaner with a single class, rather than two. Thus, I'm using the recursive version of the code. This saves memory, but slows things down considerably if you are rolling a large number of dice. If things start running slow, click off the verbose option.

This is an early experiment with Java. As of April 24, 2003, I have seen it work on my Mac using AOL for OS X, Explorer for OS X, and the Safari beta. I'll be trying it on various other browsers and platforms. Please drop me a line if the applet isn't working on your platform.

Bob Butler

Dice Teaser Page - Recursive - Three Loop - Statistics Code - Applet Code

Jump Map Bar

Warp Nine Flying False Colors!

Jump Bar 2