# What is the most STAMINA-efficient strategy to escape the well?

You are roleplaying as an adventurer under the direction of a sadistic DM who has just thrown your character down a well.

In order to escape, you have unlimited chances at a STAMINA check, difficulty level 21. Such a check entails spending some number of STAMINA reserve points (currently you have 30), and then adding that number to the result of a roll of a 20-sided die. You escape with a 21 or greater.

Your DM is showing a rare glimmer of mercy, and promises you that you'll automatically escape if you wind up spending all your STAMINA reserve points.

What is the most STAMINA-efficient strategy for escaping the well?

(Precise statement: Find the point-spending strategy P maximizing E(X_P), where E(-) is expected value in the context of fair dice rolls, and X_P is the random variable denoting STAMINA points left after escaping according to P. Note, a "strategy" doesn't have to be the same amount of points spent repeatedly; it can be any decision procedure for escape.)

• In what sense? The most efficient way to escape is obviously to spend 1 point and then get really lucky. The most efficient way to escape in the worst case scenario (the dice being rigged against you) is obviously to spend 20 points, and then your roll doesn't matter. By what metric are you comparing the solutions?
– Deusovi
Oct 12, 2021 at 3:50
• While interesting, your puzzle needs more details and clarity. For example, how would one "lose all your STAMINA reserve points"? Oct 12, 2021 at 4:36
• @Deusovi The dice are fair and you have no control over them in your strategy. As such, you want to optimize the statistical average over all possible point-spending strategies. Oct 12, 2021 at 4:55
• @Taco If you run out of STAMINA points. E.g., if you fail 30 STAMINA checks in a row, each time having elected to spend one reserve point. Oct 12, 2021 at 4:56
• The average over all possible strategies? But you're only picking one strategy, right? Do you mean the average number of points left over if you repeatedly use the same strategy?
– Deusovi
Oct 12, 2021 at 5:07

Let's start by removing the lower bound - say you can go into stamina-debt as far as you need to, and you keep playing until you escape. Then:

In this case, all strategies are the same! No matter what you do, your expected number of stamina spent is 20.

Here's why: Let $$e$$ be the expected number of stamina spent. Then if you spend $$s$$, your new expected value is $$\frac{s}{20}·s + \left(1-\frac{s}{20}\right)[???]$$. What goes in the blank? Well, you've already spent $$s$$, and then your expected amount of spending after that... should be $$e$$ again, since your position is equivalent to the start! So we have:
$$e = \frac{s}{20}s + \left(1-\frac{s}{20}\right)(s+e)$$ $$e = \frac{s^2}{20} + s - \frac{s^2}{20} + e - \frac{es}{20}$$ $$0 = s - \frac{es}{20}$$ $$1 = \frac{e}{20}$$
So in this game, all strategies are the same.

Okay, but what does this say about the actual problem?

Say you spend $$s_t$$ on turn $$t$$. In the no-bailout version, your average amount spent could be calculated as follows:
You always spend $$s_1$$... $$s_1$$ ...then you spend $$s_2$$ if you failed $$s_1$$... $$+ s_2 \left(1-\frac{s_1}{20}\right)$$ ...then you spend $$s_3$$ if you failed both $$s_1$$ and $$s_2$$... $$+ s_3\left(1-\frac{s_1}{20}\right)\left(1-\frac{s_2}{20}\right)$$ ...and so on. $$+ s_4\left(1-\frac{s_1}{20}\right)\left(1-\frac{s_2}{20}\right)\left(1-\frac{s_3}{20}\right)$$ $${}+ ...$$

If you used that same strategy in the actual game, your average spending would be the same... except once you get bailed out, you can stop adding terms. For example, if you spent 10 stamina on the first three turns, you wouldn't have an $$s_4$$ term, because you'd be bailed out by the DM.

In other words:

Getting bailed out is how you save stamina compared to the "no limit" version of the game. So the best strategy is the one that gets rescued by the DM as often as possible. It's always better to split your stamina into smaller groups to cause this to happen - and so your best option is to spend 1 stamina every turn. (If I've done the math right, this option spends about 15.7072 stamina on average.)