# [RPG] How many rolls does it take to get to six coins

anydicegame-designstatistics

I'm designing a microRPG and need some help calculating probabilities so I can make an informed decision about how many coins to start with (controlling session duration and early-game frustration).

Here's the dice mechanic, simplified to just the situation I'm concerned about:

• To resolve an action, roll 2d6.
• If at least one die comes up UNDER your number of coins, you WIN and gain one coin.

How many rolls on average will it take to get 6 coins?

How does that change if the player starts with 3 coins instead of 2?

I assume Anydice is the default tool for this, but any answer that provides similar graphs/calculations would be equally appreciated.

Below are the expected number of steps/rolls to get to 6 coins:

• Steps To Go From 2 Coins to 6 Coins = 7.52631
• Steps To Go From 3 Coins to 6 Coins = 4.25833
• Steps To Go From 4 Coins to 6 Coins = 2.45833
• Steps To Go From 5 Coins to 6 Coins = 1.125

## Solution

The best way to solve this problem in general is not Anydice, but with a tool called Markov chains. But let's start with the basic probabilities.

• First, let's define your state. A state is the number of coins you have currently. So if you have 2 coins, you're in state 2, whereas if you have 3 coins, you are in state 3.

• The probability of rolling under any number of a d6 is given by the following: \$\frac {x-1}{6}\$; for example, to roll under a 2, you need to roll a 1, which is a \$\frac 1 6\$ chance, or an \$\frac{x-1}{6} = \frac{2-1}{6} = \frac 1 6\$ chance

• The reverse is true. To roll at least any number on a d6, it is "1 - Probability(rolling under that number)"; so to roll at least a 2, the probability is equal to not rolling under a 2. The formula is \$1-\frac{x-1}{6} = \frac{7-x}{6}\$

• The probability to roll 2d6 and get at least one under a certain number, is equal to the probability of rolling 2d6 and rolling both with at least that number twice. That is, the only way to "fail" your roll is if both d6's are at least that target number. The math for this is "not Pr(roll at least that number) twice", and the formula is "1 - Pr(roll at least that number)2" which is equal to: \$1 - \left(\frac{7-x}{6}\right)^2\$

• The probability to move from state x to state x+1 is the same as the probability of rolling 2d6 with at least one under x; put another way, the probability is the same as not rolling a least x twice.

## Solution

Hence you have the Markov chain:

Arrows going from one circle to another represent the probability for jumping to the next state. The arrows from a circle going back to itself represent the probabilities for staying in the same state.

And since there are five states (2 through 6, there is no way to fall back to a previous state), this is the full chain:

Now, from this chain, construct what is called a transition matrix which describes all the state change probabilities in mathematical form.

You can read up more about transition matrices online. Roughly, it charts the probability of going from a state on the left to the state on top. So going from state 2 back to state 2 is 0.6944, while the probability of it going to state 4 is 0, since you can only jump to one state at a time.

Here, we do some math to find the expected number of steps from any state to state 6. We do this by solving the equations that arise from the transition matrix. I won't explain them in much detail, I'll just show the final equations.

Let \$h(i,j)\$ be the expected number of steps from state i to state j.

\begin{align} h(2,6) &= 1 + (0.694) \times h(2,6) + (0.306) \times h(3,6) \\ h(3,6) &= 1 + (0.444) \times h(3,6) + (0.556) \times h(4,6) \\ h(4,6) &= 1 + (0.25) \times h(4,6) + (0.75) \times h(5,6) \\ h(5,6) &= 1 + (0.111) \times h(5,6) + (0.889) \times h(6,6) \\ h(6,6) &= 0 \end{align}