# Dice Roller

Next time you play a game involving dice, give our JavaScript Dice Roller a try! Just tell it how many dice to use, how many sides are on each die, and it'll give you the total for the number of dice you "rolled"! Slick!

The JavaScript Source: Games: Dice Roller
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as NotePad or SimpleText) and save (Control-s or Apple-s). The script is yours! |

## Leave a Response

(3 comments)The math in this method is flawed; the lowest number on the die is half as likely to occur as the rest of the numbers. Here's an alternative: replace Math.round(Math.random() * die) % die + 1 with Math.ceil(Math.random() * die) and every number will have near as makes no difference the same probability of occurrence. ...If you're curious, I discovered the flaw by running a test wherein I "rolled" 1000 times using both methods, substituting incrementing thousandths (0.001, 0.002, etc) for Math.random().

Your question is beyond the scope of these comments. You will need to post it over on [a href="http://www.webdeveloper.com/forum/forumdisplay.php?f=3"]the JavaScript forum[/a]. Thanks!

I am trying to get the dice roller results to show up in the chat room provided for other gamers to see. We all have run into "not so ethical gamers" and want the dice rolls to show up for all to see as a text entry in the chat room. Could you please provide assistance?[br /][br /]Sincerely,[br /][br /]Melissa Bunker[br /]Cameron Gamers