Dice Roller | JavaScriptSource

Dice Roller

Michael Hensley Sep 9, 2000
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!

What dice type? How many dice to roll?

3 Sided

4 Sided

5 Sided

6 Sided

8 Sided

10 Sided

12 Sided

20 Sided

30 Sided

100 Sided

1

2

3

4

5

6

7

8

9

10


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!

    

Did you use this script?  Do you like this site?  Please link to us!

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().

Arcane Apr 26, 2012

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!

Lee Jan 16, 2009

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

Melissa Bunker Nov 30, 2008