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:

- You start with 2 coins.
- 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.}

## Best Answer

## Answers

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

## 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. Astateis the number of coins you have currently. So if you have 2 coins, you're instate 2, whereas if you have 3 coins, you are instate 3.The probability of rolling

underany 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\$ chanceThe reverse is true. To roll

at leastany number on a d6, it is "1 - Probability(rolling under that number)"; so to roll at least a 2, the probability is equal tonotrolling 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

undera certain number, is equal to the probability of rolling 2d6 and rolling both withat leastthat 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 xtostate x+1is the same as the probability of rolling 2d6 with at least one underx; put another way, the probability is the same as not rolling a leastxtwice.## 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 matrixwhich 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 2back tostate 2is 0.6944, while the probability of it going tostate 4is 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

anystatetostate 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 fromstate itostate 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}

## Answer

The problem is now reduced to a system of equations. Solving these, you get:

\begin{align} h(2,6) &= 7.52631 \\ h(3,6) &= 4.25833 \\ h(4,6) &= 2.45833 \\ h(5,6) &= 1.125 \\ h(6,6) &= 0 \end{align}