An exact formula for the probability of fixing 6 railings before taking damage in the Dwarf Cannon quest in OSRS

In the latest video published by OSRS Youtuber Settled, he tries to complete a quest where the player has to fix six railings, with the self-imposed restriction that he can not take any damage while doing so. He says in the video that the odds of succeeding in this are insanely difficult to calculate, so he had a friend do a simulation to estimate the odds.

Insanely difficult, you say? Hold my beer.

Let $p$ be the probability of fixing the railing. Mod Ash says on Twitter that \(p = 24\%\) at Crafting level 1 and \(p = 59\%\) at crafting level 99. Moreover, if the fixing fails, the player takes damage with probability \(1/2\), so we have three possible outcomes:

  • Fix the railing with probability \(p\).
  • Fail to fix the railing but take no damage with probability \((1-p)/2\).
  • Take damage with probability \((1-p)/2\).

Let \(P(n)\) be the probability of fixing \(n\) or more railings. We have \(P(0) = 1\) and the probability to fix all 6 railings is given by \(P(6)\). We have a recursive formula for \(P(n)\): the probability of fixing the \(n\)-th railing is equal to the probability of fixing the \((n-1)\)-th railing times the probability of fixing a single railing after 0, 1, 2, 3… non-lethal failures:

\(P(n) = P(n-1)\left((\frac{1-p}{2})^0 p + (\frac{1-p}{2})^1 p + (\frac{1-p}{2})^2 p + (\frac{1-p}{2})^3 p \ldots \right) \)

Factoring \(p\) out and applying the geometric series limit formula \(\sum_{i=0}^\infty r^i = 1 / (1-r)\) with \(r = \frac{1-p}{2}\) gives us \(P(n) = P(n-1) \frac{2p}{p+1}\). We can now apply this formula \(n\) times starting from $n = 0$ to obtain \(P(n) = P(0) (\frac{2p}{p+1})^n\) and plugging in \(P(0) = 1\) and \(n = 6\) gives us the formula \(P(6) = (\frac{2p}{p+1})^6 \). With crafting level 1, this evaluates to \((\frac{2 \cdot 0.24}{0.24+1})^6 = 0.003364475\). The simulation in Settled’s video gave a probability of 0.33%, so it checks out!