Probability for Dice Game

i´m programming a little dice game (Android&Windows). As you can see on the screenshot i have 9 dice (right). The objective of the game is to match the symbols on the enemy cards (middle) to defeat them. To balance the game i want to calculate the probability for matching an enemy card with the dice. I think the probability for 1 roll would be enough but a variable row count would be even better (the dice can be saved between rounds). The dice have 6 faces: light attack, light shield, light magic, dark attack, dark shield and dark magic. The enemy symbols can include all of this faces (p=1/6) and light, dark (p=1/2), attack, shield and magic (p=1/3). I´m planning to include pairs later on.
I´ve searched for hours to solve this problem. Does anyone know how to solve it or can point me in the right direction?
Your description of what you’re after is distinctly lacking in usable detail. The enemy cards in the middle appear to have a variable number of “capacities”: Top left has three, top right has five, bottom left has seven, and bottom right has five. Is this always the case? If not, what is the allowable range of the number of enemy capacities for each enemy? How many capacities are necessarily populated, if any?

What is the meaning of the capacities that are blank? What is the meaning of different colours for blank capacities?

Are the capacities randomly assigned to the enemy cards? Or do they depend on the capacities of the challenger?

Does a single roll need to defeat any one of the four enemy cards? Or does it need to defeat all four simultaneously?

Is a “defeat” an exact match, i.e. if one of the enemies has two dark attacks and one light magic, must a winning throw include exactly two dark attacks and one light magic, or can it be two or more dark attacks and one or more light magics?

Do the enemy capacities change between one roll and the next? If so, how? In either case, how many rolls does the challenger get?

However the rules of the game may be, if there is much complexity, your best bet would be to run a Monte Carlo simulation once the rules are properly quantified.
Thank you very much for your answer! I will try to clarify:
The Enemy Cards (18 in total) have capacity between 2-8.
The capacities are not blank. Colored sides mean: red = attack, blue = defense, yellow = magic, white = light, black = dark.
The capacities are more or less random. The idea is to generate 1000+ sequences at random and use a difficulty metric to select some of them by a difficulty rating.
The player has some health. After every round a timer on the cards is decreased by one (left side). When the timer hits zero the player loses a small amount (right side on the card) of health and the timer is reseted. So the player can roll his dices till he is dead. After all symbols on a enemy card are matched the dice are released and can be used again on the next roll.
But for simpicity reasons i'm only intrested in the probabilty of matching all symbols of one card by rolling 9 dice one time (or a fixed amount of rolls).
The capacities stay the same between rounds and the dices that are matched in one round stay on the card till all dice are matched to the card. The dice are matched by the player by dragging them on the card symbols. This means he can decided if he wants to use a dark attack to match an dark attack, attack or dark symbol.

I used a monte carlo simulation in a similar game. The problem is the complexity of determinig if a given set of dice match. Since you can use 1 dice to match multiple symbols (e.g. dark or attack) i have to observe all possibilities & combinations. This worked ok for 5 dice but isn't usable for 8.

I hope i could answer your questions.


TS Contributor
It will be better, besides stating the rules explicitly and describing the model, you also provide some relevant examples to illustrate different possible scenarios, like your second last paragraph.

I would also like to clarify several things if I missed:

1. What are the faces of the dice? Are all 9 dice have the same faces? And now you are rolling them independently?

2. You want to calculate the probability of matching an enemy card with the dice. So I assume you mean 1 enemy card is selected already, and how many dice here in concern? Would you mind to clarify again how to match? (the rules, etc). You really need to clarify this to define the event which you are interested to calculate the probability.

3. As asked by Con-Tester, so do we already know all the information of the selected enemy card - those colors, attributes as you said? So the probability will be in terms of these parameters. Please also provides the possible combinations of these parameters.
:wave: Since this matter is a bit complicated i build you guys a WebGL-Demo of the game: WebGL Demo link (it will probabliy take some time to load) :wave:

1. yes - all the same faces & yes - all rolled independently.
2. For simplicity i would like to assume that only one card has to be matched. (To clarify this: i don´t need to calculate all probabilities regarding the game. I just need some metric to describe the difficulty of the cards - e.g.: i have 2 cards: the first has one symbol: "light attack" and the second has 2 symbols "dark magic" & "dark defense". Now i need some numbers to express their difficulty. The difficulty obviously depends on the number of dice that can be used to match these symbols)

Matching rules:
-there are 6 faces on each dice: "light attack", "dark attack", "light defense", "dark defense", "light magic", "dark magic".
-there are 11 possible symbols to match: "light attack", "dark attack", "light defense", "dark defense", "light magic", "dark magic", "dark" (dark square - matches "dark attack", "dark defense", "dark magic"), "light" (white square - matches "light attack", "light defense", "light magic"), "attack" (red square - matches: "light attack", "dark attack"), "defense" (blue square - matches: "light defense", "dark defense"), "magic" (yellowsquare - matches: "light magic", "dark magic").

3. the enemy cards have 2-8 symbols to match. They are selected at random. I need some way to calculate the difficulty of a given symbol sequence for matching all symbols with 9 dice in one roll (or a given roll count - if this is possible).


TS Contributor
Ok it is much clearer now. The question remain is:

- Do you want to calculate the probability of match, given the complete information about the symbols of the selected enemy cards before roll?
- Or you still assign a prior distribution about those symbols to be appeared? i.e. Those symbols are random, and not known before roll.

And they are different.


TS Contributor
I think it is not very easy to generalize the cases, let me work on 1 easy example first.

Let the numbers \( \{1, 2, 3, 4, 5, 6\} \) represent the faces

"light attack", "dark attack", "light defense", "dark defense", "light magic", "dark magic"

on the dice respectively.

Let \( X_i \) be the number of times that the number \( i \) appear among the \( n \) dices. Assuming \( n \geq 8 \), the maximum number of symbols that the enemy card may contain. Then

\( (X_1, X_2, \ldots, X_6) \sim \text{Multinomial}
\left(n; \frac {1} {6}, \frac {1} {6}, \ldots, \frac {1} {6}\right) \)

Suppose the enemy card now contains "light attack" and "attack" symbols.
The probability of matching this card is

\( \Pr\{X_1 \geq 1, X_1 + X_2 \geq 1\} \)

\( = 1 - \Pr\{X_1 < 1 \cup X_1 + X_2 < 1\} \)

\( = 1 - \Pr\{X_1 = 0 \cup X_1 + X_2 = 0\} \)

\( = 1 - \Pr\{X_1 = 0\} \)

\( = 1 - \left(\frac {5} {6}\right)^n \)

In general I think you can order the computer to sum for complex cases / direct enumeration.

In general there are \( \binom {n + 5} {5} \) types dice results. For \( n = 9 \) it correspond to \( 2002 \) cases. For each case the probability is

\( \Pr\{(X_1, X_2, \ldots, X_6) = (x_1, x_2, \ldots, x_6)\}
= \frac {n!} {x_1!x_2!\ldots x_6!} \frac {1} {6^n} \)

So you can first compute all these multinomial coefficients, and sum all of them for the cases that match the constraint, and divide by \( 6^n \). This is a brute force way to do it, may not be efficient when \( n \) is large.

Another example using hand calculation:
Suppose the enemy card now contains 1 "light defense", 2 "light" and 1 "dark magic" symbols.
The probability of matching this card is

\( \Pr\{X_3 \geq 1, X_1 + X_3 + X_5 \geq 2, X_6 \geq 1\} \)

\( = 1 - \Pr\{X_3 = 0 \cup X_1 + X_3 + X_5 < 2 \cup X_6 = 0\} \)

\( = 1 - \Pr\{X_3 = 0\} - \Pr\{X_1 + X_3 + X_5 < 2\} - \Pr\{X_6 = 0\} \)
\( + \Pr\{X_3 = 0, X_1 + X_3 + X_5 < 2\} + \Pr\{X_3 = 0, X_6 = 0\}
+ \Pr\{X_1 + X_3 + X_5 < 2, X_6 = 0\} \)
\( -\Pr\{X_3 = 0, X_1 + X_3 + X_5 < 2, X_6 = 0\} \)

\( = 1 - \left(\frac {5} {6}\right)^n - \frac {n + 1} {2^n} - \left(\frac {5} {6}\right)^n
+ \left( \frac {1} {2^n} + \frac {n} {3} \frac {1} {2^{n-1}}\right) + \left(\frac {2} {3}\right)^n + \left(\frac {1} {3^n} + \frac {n} {2} \frac {1} {3^{n-1}} \right) - \frac {n + 1} {3^n}\)

\( = 1 - \frac {5^n + (n+1)3^n + 5^n - 3^n - 2n3^{n-1} - 4^n - 2^n - 3n2^{n-1} + (n+1)2^n} {6^n} \)

\( = 1 - \frac {2 \times 5^n - 4^n + n3^{n-1} - n2^{n-1}} {6^n} \)

It just show how tedious it would be if you carry on to more types, if you manage to calculate it by hand. Maybe it has a more systematic way to do this.
@BGM thank you very much for your answer! When i´m back home i will study it carefully to understand it in depth.

@rogojel since 1 side can match multiple sides (e.g. the attack symbol matches light & dark attack) i would have to consider all possible ways to match the ysmbols. I did this for another game with 5 dice. But because of the matching it gets slow quickly.