# Thread: Probability for Dice Game

1. ## Probability for Dice Game

Hi,
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?

2. ## Re: Probability for Dice Game

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.

3. ## Re: Probability for Dice Game

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.

4. ## Re: Probability for Dice Game

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.

5. ## Re: Probability for Dice Game

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)

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

6. ## Re: Probability for Dice Game

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.

7. ## Re: Probability for Dice Game

@BGM
the first one. Given a enemy card / symbol sequnce i want to determine the probabilty to match it with 9 dice.

8. ## Re: Probability for Dice Game

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

Let the numbers represent the faces

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

on the dice respectively.

Let be the number of times that the number appear among the dices. Assuming , the maximum number of symbols that the enemy card may contain. Then

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

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

https://en.wikipedia.org/wiki/Stars_...(combinatorics)

In general there are types dice results. For it correspond to cases. For each case the probability is

So you can first compute all these multinomial coefficients, and sum all of them for the cases that match the constraint, and divide by . This is a brute force way to do it, may not be efficient when 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

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.

9. ## The Following User Says Thank You to BGM For This Useful Post:

Sakati (03-07-2016)

10. ## Re: Probability for Dice Game

hi,
any reason not to simulate one million games and estimate the probanilities?

11. ## Re: Probability for Dice Game

@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.

12. ## Re: Probability for Dice Game

I may be missing something, but why not just simulate a draw of both parties and record the result?

 Tweet

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts