Optimal Stopping on a Die Game with Square Traps
Statistics & ExperimentsModel answerLast updated
Evaluate optimal stopping strategies and dynamic programming formulations for a die-rolling game where landing on perfect squares results in total loss.
Imagine playing a continuous dice game starting at a cumulative score of $S = 0$ using a balanced six-sided die numbered $1$ through $6$.
During every round:
- You roll the die and add the rolled number to your total $S$.
- Bust Rule: If your updated sum $S$ is a strictly positive perfect square (i.e., $S \in {1, 4, 9, 16, 25, \dots}$), your score collapses to $0$, and the game terminates with zero payout.
- Cash-Out Option: If $S$ is not a perfect square, you face a choice: either stop playing to lock in $S$ as your final cash reward, or roll again.
Key Requirements
1. Bellman Equation & Expected Value Bounds
- Formulate the state value function $V(s)$, defined as the maximum expected payout starting from any valid, non-busting state $s$.
- Write out the explicit Bellman optimality equation for $V(s)$.
- Determine whether the absolute maximum expected score achievable from $S=0$ is finite or infinite. Prove your intuition by analyzing the survival probability when attempting to navigate past high-valued consecutive squares $k^2$ and $(k+1)^2$ as $k \to \infty$.
2. Small State Strategy Analysis
- After taking the initial roll from $S = 0$, you land on $S \in {2, 3, 5, 6}$ with probability $4/6$ (since $1$ and $4$ cause an instant bust).
- Perform a one-step lookahead calculation for these small non-busting scores ($s = 2, 3, 5, 6$). Is it ever optimal to roll again from any of these positions, or should a rational player cash out immediately?
3. Asymptotics & Variant Scenarios
- Analyze the asymptotic policy behavior when $S$ lies in the middle of a massive non-square region between $k^2$ and $(k+1)^2$ for very large $k$. How does the choice to roll change near the midpoint versus when drawing close to $(k+1)^2$?
- Evaluate how the optimal strategy shifts under two structural modifications:
- Partial Penalty: Busting does not end the game with zero payout, but instead imposes a fixed numerical deduction $C$ before letting the player decide whether to continue or stop.
- Zero-Indexed Die: The die faces are modified to ${0, 1, 2, 3, 4, 5}$.
Hints
Hint 1
Think about the gap between consecutive squares k^2 and (k+1)^2, which equals 2k + 1. For large k, how many safe steps can you take without any risk of hitting (k+1)^2?
Hint 2
Calculate the expected outcome of taking one additional roll at state s. What is the probability of hitting a square from s?
Hint 3
Consider whether V(s) can grow indefinitely. Does the ability to cash out early place a lower bound on your decision?
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Dynamic Programming & Value Function Formulation
Value Function & Bellman Equation
Let $V(s)$ represent the optimal expected value achievable when the player is currently at score $s$.
- If $s$ is a positive perfect square ($s \in {1, 4, 9, 16, \dots}$), $V(s) = 0$ (terminal bust state).
- For non-square states $s$, the player chooses between cashing out for payout $s$ or rolling the die:
$$V(s) = \max \left( s, ; \frac{1}{6} \sum_{d=1}^{6} V(s + d) \right)$$
Finiteness of Maximum Expected Value
The optimal expected score starting from $S=0$ is finite.
Proof / Bound: Consider the gap between consecutive squares $k^2$ and $(k+1)^2$, which has length $(k+1)^2 - k^2 = 2k + 1$. To move from below $k^2$ to past $(k+1)^2$, the sum $S$ must enter the interval $(k^2, (k+1)^2)$ and eventually jump over $(k+1)^2$.
Because the maximum die step is $6$, as $S$ moves through the interval $[(k+1)^2 - 6, (k+1)^2 - 1]$, any single roll has a positive probability of landing exactly on $(k+1)^2$. Specifically, for any position $s \in [(k+1)^2 - 6, (k+1)^2 - 1]$, at least one face $d \in {1, \dots, 6}$ yields $s + d = (k+1)^2$, meaning the bust probability per attempt to pass $(k+1)^2$ is at least $1/6$.
Thus, the probability of successfully clearing the $k$-th square obstacle without landing on $(k+1)^2$ is bounded above by $5/6$. To reach an arbitrarily large score requiring crossing $N$ consecutive squares, the survival probability decays exponentially as $(5/6)^N \to 0$. Since the probability of surviving long paths vanishes exponentially while the linear reward grows only as $O(k^2)$, the expected overall payout remains bounded.
2. Early-State Evaluation ($S \in {2, 3, 5, 6}$)
Let's compute the one-step lookahead expected value from a non-square state $s$. Cashing out yields $s$. Rolling one more time yields an expectation of:
$$E[\text{roll} \mid s] = \frac{1}{6} \sum_{d=1}^{6} V(s + d) \ge \frac{1}{6} \sum_{d=1}^{6} \max(s + d, 0) \cdot \mathbb{I}(s + d \notin \text{Squares})$$
Let us test a one-step lookahead where we assume we cash out on the next turn if we don't bust:
-
State $s = 6$:
- Next possible scores: $7, 8, 9 \text{ (bust)}, 10, 11, 12$.
- Squares hit: $9$.
- Expected 1-step roll return: $\frac{1}{6}(7 + 8 + 0 + 10 + 11 + 12) = \frac{48}{6} = 8$.
- Compare to cash out: $8 > 6$.
- Decision: Roll. (The risk of landing on 9 is worth taking because the non-busting outcomes average to 8).
-
State $s = 5$:
- Next scores: $6, 7, 8, 9 \text{ (bust)}, 10, 11$.
- Expected 1-step roll return: $\frac{1}{6}(6 + 7 + 8 + 0 + 10 + 11) = \frac{42}{6} = 7$.
- Compare to cash out: $7 > 5$.
- Decision: Roll.
-
State $s = 3$:
- Next scores: $4 \text{ (bust)}, 5, 6, 7, 8, 9 \text{ (bust)}$.
- Squares hit: $4$ and $9$.
- Expected 1-step roll return: $\frac{1}{6}(0 + 5 + 6 + 7 + 8 + 0) = \frac{26}{6} \approx 4.33$.
- Compare to cash out: $4.33 > 3$.
- Decision: Roll.
-
State $s = 2$:
- Next scores: $3, 4 \text{ (bust)}, 5, 6, 7, 8$.
- Squares hit: $4$.
- Expected 1-step roll return: $\frac{1}{6}(3 + 0 + 5 + 6 + 7 + 8) = \frac{29}{6} \approx 4.83$.
- Compare to cash out: $4.83 > 2$.
- Decision: Roll.
Conclusion: For all safe initial states $s \in {2, 3, 5, 6}$, the one-step lookahead expected value strictly exceeds $s$. Therefore, it is optimal to continue rolling from all of these states.
3. Asymptotics & Variant Scenarios
Policy Behavior Between Large Squares
For large $k$, the distance between $k^2$ and $(k+1)^2$ is $2k+1$.
-
Middle of the Interval ($s \approx k^2 + k$): When $s$ is far from both $k^2$ and $(k+1)^2$ (distance $> 6$), the probability of hitting a square on the next few rolls is exactly $0$.
- Gain from rolling: $+3.5$ expected score per roll.
- Danger of busting: $0$ for the immediate roll.
- Policy: Roll aggressively. In the middle of large non-square regions, rolling has zero immediate risk and positive expected gain.
-
Approaching the Upper Boundary ($s \in [(k+1)^2 - 6, (k+1)^2 - 1]$): As $s$ gets within 6 units of $(k+1)^2$, rolling introduces a $1/6$ chance of instant ruin (losing a large accumulated bankroll $\approx k^2$).
- Expected loss from busting: $\frac{1}{6} \times k^2$.
- Expected gain from surviving: $\le 3.5$.
- For $k \ge 3$, $\frac{1}{6} k^2 > 3.5$.
- Policy: Cash out. As soon as the player enters the danger zone near $(k+1)^2$, the high variance and huge penalty of losing $s \approx k^2$ far outweigh the modest gain of $+3.5$.
Structural Variants
-
Fixed Penalty $C$ instead of Total Loss:
- Instead of $V(\text{square}) = 0$, a bust transitions the state to $s \to \max(0, s - C)$ without forced termination.
- Effect: The downside of hitting a square is capped at $C$ rather than growing with $s$. As $s \to \infty$, the expected cost of a bust is at most $\frac{1}{6} C$, while the benefit of rolling remains $3.5$.
- Result: If $C < 21$ (since $\frac{1}{6} \times 21 = 3.5$), the player will never stop in the interior of large intervals, and overall expected payout becomes infinite.
-
Die Faces ${0, 1, 2, 3, 4, 5}$:
- Rolling a $0$ changes nothing ($s \to s$), effectively adding a self-loop with probability $1/6$.
- The Bellman equation becomes: $$V(s) = \max \left( s, ; \frac{1}{6}V(s) + \frac{1}{6}\sum_{d=1}^{5} V(s+d) \right)$$ Re-arranging for the roll option: $$V_{\text{roll}}(s) = \frac{1}{5} \sum_{d=1}^{5} V(s+d)$$
- Effect: Rolling a 0 simply wastes a turn without changing state or risking a bust. The game is equivalent to rolling a fair 5-sided die with faces ${1, 2, 3, 4, 5}$. The optimal policy structure remains identical, though numerical threshold points shift slightly.