Shortcut or shelter?
The policy boundary in a noisy maze
An exposed route is shorter. A protected route is slower. I solve for the reliability at which the preference changes, then test whether Q-learning, SARSA, and Expected SARSA recover the boundary implied by the objective they learn.
THE WORLD
One fork, two routes.
I chose a small environment because its states, transitions, and rewards can be enumerated, and its optimal policy can be computed before training begins.
The agent starts at a fork. EAST enters a short corridor with hazards on both sides. SOUTH begins a longer route protected by a wall and the edge of the grid. The same actuator noise applies everywhere; the southern route is safer because of its geometry, not because its controls are more reliable.
Research question. How reliable must the world be before the shortcut is worth taking?
The purpose is not to rank the algorithms. It is to locate a policy change, explain why it occurs, and test whether finite training recovers the predicted boundary.
Figure 1. EAST enters the exposed corridor; SOUTH begins the protected route. Intended actions execute with probability p.
The central corridor reaches the goal in eight eastward moves. The southern route is four moves longer under perfect control. Every movement costs , reaching the goal adds , and future rewards are discounted by .
I keep the geometry fixed and change the consequence law. A recoverable hazard adds and the episode continues. A lethal hazard adds , ends the episode, and removes the chance to reach the goal.
THE VALUE
The quantity being learned.
A policy maps a state to a distribution over actions. Its return from time is the discounted sum of future rewards:
The action value is the expected return after one action and the policy that follows:
THE BOUNDARY
A boundary in reliability.
Let be the start. Define the start-state action gap
Positive values favor the corridor; negative values favor the shelter. The policy boundary is the zero crossing.
Because the transition and reward model are known, the optimal values satisfy the Bellman equation and can be solved directly:
EXACT-MODEL CALCULATION · NOT A LEARNED RESULT
| Hazard law | Continuation policy | Boundary |
|---|---|---|
| Recoverable | Greedy | ≈ 0.806Corridor above the boundary |
| Recoverable | ε = 0.10 soft | ≈ 0.848Continued exploration moves the boundary |
| Lethal | Greedy | ≈ 0.989A narrow transition near perfect execution |
| Lethal | ε = 0.10 soft | No crossingShelter remains preferred through p = 1 |
Value iteration stops at a Bellman residual of 10−10. The displayed boundaries are numerical zero crossings, rounded to three decimal places.
The lethal boundary is compressed close to perfect execution because the corridor is not a single gamble. It requires repeated exposed decisions. In a simplified passage requiring clean movements, a clean run scales as . The full maze is solved exactly rather than reduced to that expression, but the compounding mechanism remains.
TWO RANDOMNESSES
World noise is not agent exploration.
Reliability belongs to the environment. An intended action executes correctly with probability ; otherwise it slips left or right with probability each.
Exploration belongs to the behavior policy. Here,
Lowering changes the dynamics. Raising changes the continuation policy being valued. The distinction survives even at : perfect actuation cannot prevent an exploratory policy from selecting a bad action.
In the lethal maze, persistent exploration is costly enough that the exact epsilon-soft solution prefers the shelter even under perfect actuation. Frozen-greedy deployment and continued online exploration are different decision problems.
THE BACKUPS
Three rules, two continuation objectives.
All three methods update an action value by
They differ in the target . Here is one only for a true terminal transition; the continuation value is then zero.
OFF-POLICY
Q-learning
Bootstraps toward the best next action. Its control target is greedy.
ON-POLICY
SARSA
Uses the next action actually selected, including the consequences of continued exploration.
ON-POLICY · EXPECTED
Expected SARSA
Integrates over the next-action distribution. At the same state, transition, Q-table, and behavior policy, its conditional expected target matches SARSA's while removing next-action sampling noise.
Under persistent exploration, Q-learning should approach the greedy boundary, while SARSA and Expected SARSA should approach the epsilon-soft boundary. The difference is the continuation value inside the update.
THE PROTOCOL
The training unit is an interaction.
Shelter-taking policies produce longer episodes. Equal episode counts would give them more transitions and more updates, so every primary trial receives the same 100,000-interaction budget.
Episodes are capped at 250 steps. Time-limit truncation resets the rollout but does not suppress the bootstrap; true termination does. The exact-model reference is the corresponding discounted infinite-horizon MDP, so truncation frequency is one of the empirical checks rather than an unspoken equivalence.
Numerical reference solutions determined where the reliability grids required resolution. Small pilot runs then calibrated coverage, learning rate, and budget. The full configurations were fixed after that calibration. This is a prespecified full-run design, not a claim of preregistration.
- Training budget
- 100,000 transitions
- Learning rate
- α = 0.05
- Discount
- γ = 0.98
- Exploration
- ε = 0.10
- Initial values
- Q(s, a) = 8
- Independent units
- 20 seeds per condition
- Checkpoints
- Every 2,500 transitions
- Held-out evaluation
- 25 greedy + 25 behavior episodes
Uniform optimistic initialization is a declared coverage device. The primary learned estimand is the fraction of independent seeds whose final greedy start action is EAST. A tie, NORTH, or WEST remains classified as other; it is not silently converted into one of the expected routes.
Training seeds carry the uncertainty. Evaluation episodes within one trained policy are repeated measurements, not additional replicates.
PREDICTIONS
Predictions before analysis.
- Q-learning should place its finite-budget route transition near the greedy model boundary.
- SARSA and Expected SARSA should place theirs nearer the persistent-epsilon model boundary.
- At a common Q-table, state, transition, and behavior policy, SARSA and Expected SARSA targets agree in conditional expectation; Expected SARSA removes the next-action component of target variance.
- When exploration anneals to zero, all three methods should move toward the same greedy route where the two exact objectives disagree.
The fourth prediction is the important check. If the methods do not converge toward the common greedy route, the continuation-objective explanation is incomplete. Insufficient optimization, poor coverage, constant-step-size behavior, or the training budget would still need to be considered.
EMPIRICAL RESULTS
FULL RUNS · 1,920 INDEPENDENT POLICIES
The learned boundary depends on the backup.
In the recoverable maze, the corridor crossed 50% of seeds at p = 0.823 for Q-learning, 0.848 for SARSA, and 0.853 for Expected SARSA. In the lethal maze, Q-learning crossed only at p = 0.999; neither on-policy method crossed at all.
Each point below is the fraction of 20 independently trained policies whose final greedy start action was EAST. The line is not one policy mixing routes; it records disagreement across seeds after the same 100,000-interaction budget. The stationary ordering matches the continuation objective in the update; it is not a general ordering of the algorithms.
In the recoverable maze, the seed-paired median boundary shift relative to Q-learning was +0.026 for SARSA (95% interval [0.015, 0.0395]) and +0.0305 for Expected SARSA ([0.015, 0.0397]). The lethal on-policy boundaries were right-censored, so no numerical shift is imputed there.
MODEL TARGETS AND FINITE-BUDGET ESTIMATES
| Hazard | Method | Exact target | Learned p50 boundary | Reading |
|---|---|---|---|---|
| Recoverable | Q-learning | Greedy · 0.806 | 0.823 [0.815, 0.829] | 0.017 above the greedy reference |
| Recoverable | SARSA | ε-soft · 0.848 | 0.848 [0.840, 0.859] | Aligned with the ε-soft reference |
| Recoverable | Expected SARSA | ε-soft · 0.848 | 0.853 [0.840, 0.857] | 0.005 above the ε-soft reference |
| Lethal | Q-learning | Greedy · 0.989 | 0.9988 [0.9983, 0.9989] | 0.010 above the greedy reference |
| Lethal | SARSA | ε-soft · no crossing | No crossing | Right-censored; shelter through the grid |
| Lethal | Expected SARSA | ε-soft · no crossing | No crossing | Right-censored; shelter through the grid |
Intervals resample training seeds as the independent unit. “No crossing” means the observed corridor-selection rate did not reach 50% on the declared grid; it is not extrapolated beyond the data.
MECHANISM CHECKS
One mechanism survived its check. One did not.
These checks separate two claims. Expected SARSA should remove next-action sampling variance at a matched backup. Annealing ε to zero should make the trained policies approach the same greedy route. Only the first held here.
Mixed
Q-learning and the greedy reference
Q-learning was the first method to cross toward the corridor in both hazard laws, as predicted. Its learned boundaries remained 0.017 and 0.010 above the exact greedy references, so the objective ordering was right but exact recovery was not.
Supported in ordering
On-policy methods and the ε-soft reference
Recoverable-hazard boundaries landed at 0.848 and 0.853 against an exact ε-soft boundary of 0.848. Under lethal hazards, both methods remained below 50% corridor selection, as the no-crossing reference predicted.
Supported
Expected backup and target variance
At the declared comparison points, variance fell from 0.0154 to 0.0088 in the recoverable maze and from 0.0382 to zero in the lethal maze. The reduction is exactly the next-action sampling component; it is not a sample-efficiency claim.
Not supported
Annealing and the common objective
Removing exploration did not erase the learned separation after 100,000 interactions. At recoverable p = 0.825, corridor choice was 1/12 for Q-learning, 2/12 for SARSA, and 2/12 for Expected SARSA; at lethal p = 1, it was 12/12, 0/12, and 11/12. The exact common greedy optimum remains; this annealing procedure did not recover it reliably.
LIMITS
A narrow result in a known world.
At constant ε = 0.10, methods that valued different continuation policies learned different route boundaries. The ordering followed the exact model; the finite-budget locations did not always coincide with it. That is the result. It does not establish that SARSA is generally safer, that Q-learning is inherently reckless, or that one method is superior.
The failed annealing prediction matters. Turning exploration down did not guarantee recovery of the common greedy route after 100,000 interactions. Coverage, constant-step-size behavior, and the path taken through training remain plausible explanations; this experiment does not separate them.
Every estimate is conditional on this topology, reward law, discount, exploration schedule, initialization, reliability grid, and training budget. The EAST/SOUTH summary is restricted to the plotted high-reliability domain. The single learned WEST action is retained rather than folded into either route.
REPRODUCIBILITY
Code, configurations, and run identifiers.
The full runs were produced from clean Git commit:
3b53a22323ae44ef776c931648d9f13fa2346a66
Environment, agents, exact solvers, protocol, versioned configurations, and the generated analysis notebook are public. The analysis record includes source-run hashes, settings, software versions, the post-collection amendment, and hashes for every derived artifact. Raw Protocol-v2 runs remain local due to size; the compact boundary table and publication figures are available here.
Boundary estimates (CSV)Analysis record (JSON)
Open the repositoryFull run identifiers
shortcut_or_shelter_recoverable-dea8b3bb98-20260818T165653.284759Zshortcut_or_shelter_lethal-c224eb9e19-20260818T184221.884416Zshortcut_or_shelter_annealed-7a6ceda8a8-20260818T200356.410162Z