Anyone can help me with dice?
So basically I want a dice-rolling program to give me the odds of rolling a particular number for any amount of any-sided dice
Obviously then I need to be able to calculate the number of possible permutations the dice can use to get any number, but I'm fucking stumped. I googled the problem and got this, but I simply don't understand the equation
I get that this is a "generating" equation, but how do I use it? What is the x variable used for? Do I set this equation equal to x^k, do I set it equal to anything?
The total number of possibilities is 6^2 because permutations = variables ^ slots.
An easy way to remember this if it's something you have difficulty with is to imagine a 4 digit combination lock with 0-9 for each slot. You know there are 10,000 combinations because the highest number is 9,999 and the lowest is 0. 4^10 does not give 10,000, 10^4 does.
So you know there are 36 permutations, that acts as a checksum for the next method.
List all the possible results. 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 and 12.
Now make a list of all the possible combinations for each number, you know that you have to use 2 numbers, those numbers are all between 1 and 6.
2 = 1+1
3 = 1+2, 2+1
4 = 2+2, 3+1, 1+3
and so on
The total number of data points should be 36 based on the total we worked out earlier.
So rereading your question you didn't want any of this so I won't go further but I'll re-explain the first bit.
Variables ^ slots. Always. Remember the combination lock. Variables in this case = number of sides on the dice, slots = number of dice.
Variables are what can appear in each slot, each slot is which thing can present a number.
If you're ever confused as to which is the variable and which is the slot just reduce both sets down, one to 2 and one to 3. Work out how many data points would arise from the reduced number. If the answer is 8, the one you reduced to 2 is the variable, if the answer is 9 the one you reduced to 3 is the variable.
For reference, I'm trying to make a program to help me with Warhammer
Most of what I need to roll is, yes 2d6, but 3d6, 4d6, and 4d3 also come up enough that I want a single formula to calculate all the possible permutations of those dice and the chances of them coming up.
It's written right there. Point one tells you how to find the generating function of a die, point two tells you how to get the generating function of a combination of dice by multiplying the generating functions of each single die (i.e. raising it to the power n if you roll n equal dice).
Once you have your generating function, expand the polynomial and look at the coefficient of each power: thct coefficient is the probability of the associated exponent to come up. E.g. if you had a polynomial 0.3*x+0.5*x^2+0.2*x^3, the probability distribution would be p(1)=0.3, p(2)=0.5, p(3)=0.2
This method is much faster than listing all possibilities, in fact it runs in O(r log r log n) instead of O(r^n)
Yes it does.
Create a program that adds <dice> integers between <sides>.
So you would have something that adds 14 numbers 1 + 1 + ... 1 = 14, 1 + 1 + ... 2 = 15 and so on. Then it takes all the sets that add up to 28. That gives you the permutations possible for 28. That number over the total number of permutations, in this case 4,782,969 gives you the probability of rolling 28 on any given throw.