tarchon said:Didn't anybody think of searching the net for this?
That's like cheating.
It's not the wheel that's interesting, it's how it was invented. For some of us, anyway.
tarchon said:Didn't anybody think of searching the net for this?
Yeah, with large dice sets the factorial functions start to give you problems.
My code was not recursive, and did not use factorials, it simply summed the probability of generating a result, one dice at a time.Don't you end up with the "recursive" codes generated above in this thread? They have the advantage of allowing different die types, but aren't as mathematically cool to play with.
Unther the unready said:
My code was not recursive, and did not use factorials, it simply summed the probability of generating a result, one dice at a time.
It can be seen here
Riveneye said:I got the idea to write a script that would spit out the % chance of getting a certain roll with certain dice in my IRC game (just to feed our curiosity at times), but am stumped on how to write such a script when large amounts of dice are used. As soon as more than 2 dice are introduced, the amount of manual work that I need to do to calculate the probabilities is enormous. Does anyone know of a formula I could use?
LazarusLong42 said:All right, I've done some figuring, and about the best I can come up with is the following:
![]()
where n and d are the number and size of each set of dice; R is the result desired; and N is the total dice. So, for 3d6 + 2d4:
n1 = 3
d1 = 6
n2 = 2
d2 = 4
N = 5
Given this equation and the one above, I think the math-minded people in this thread can easily extrapolate for three or more types of dice. The only problem is how many iterations the algorithm goes for... that is, the definition of m1 and m2 in this equation.
The problem is that there are three criteria:
m1 <= n1;
m2 <= n2;
i*d1 + j*d2 <= R - N
If one defines m1 as in the original equation, one then must find an expression for m2, in terms of n1, n2, d1, d2, R, N, and i. If anyone can find an expression for that, let me know.
Nathan said:Note that the binomial coefficient (n over s) is per definition zero, if s is an integer greater than n (and n positive). Therefore, you don't need the constraints m1 <= n1 and m2 <= n2.