Sum of roll of N dice
|
05-04-2018, 06:35 PM
Post: #29
|
|||
|
|||
RE: Sum of roll of N dice
Interesting question!
Not sure how to do it quickly for N dice, but you can do it for 2 by using a lookup table for the 36 possible rolls of 2 6 sided dice, i.e. you generate a number between 0 and 35, do a look-up and you are down. The code might look something like this (the line numbers are important): Code:
The "shape" of the lookup table is very regular, so maybe there is an easy way to calculate the distribution directly from the random number. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 11 Guest(s)