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.

01

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.

exposed corridor protected route hazard cells

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 −0.06-0.06, reaching the goal adds +8+8, and future rewards are discounted by γ=0.98\gamma=0.98.

I keep the geometry fixed and change the consequence law. A recoverable hazard adds −0.50-0.50 and the episode continues. A lethal hazard adds −8-8, ends the episode, and removes the chance to reach the goal.

02

THE VALUE

The quantity being learned.

A policy π\pi maps a state to a distribution over actions. Its return from time tt is the discounted sum of future rewards:

Gt=∑k=0∞γkRt+k+1.G_t=\sum_{k=0}^{\infty}\gamma^k R_{t+k+1}.

The action value is the expected return after one action and the policy that follows:

Qπ(s,a)=Eπ ⁣[Gt∣St=s, At=a].Q^\pi(s,a)=\mathbb E_\pi\!\left[G_t\mid S_t=s,\ A_t=a\right].
03

THE BOUNDARY

A boundary in reliability.

Let s0s_0 be the start. Define the start-state action gap

Δ⋆(p)=Qp⋆(s0,EAST)−Qp⋆(s0,SOUTH).\Delta^\star(p)=Q^\star_p(s_0,\mathrm{EAST})-Q^\star_p(s_0,\mathrm{SOUTH}).

Positive values favor the corridor; negative values favor the shelter. The policy boundary p⋆p^\star is the zero crossing.

Because the transition and reward model are known, the optimal values satisfy the Bellman equation and can be solved directly:

Qp⋆(s,a)=∑s′,rPp(s′,r∣s,a)[r+γmax⁡a′Qp⋆(s′,a′)].Q^\star_p(s,a)=\sum_{s',r}P_p(s',r\mid s,a)\left[r+\gamma\max_{a'}Q^\star_p(s',a')\right].

EXACT-MODEL CALCULATION · NOT A LEARNED RESULT

Hazard lawContinuation policyBoundary
RecoverableGreedy≈ 0.806Corridor above the boundary
Recoverableε = 0.10 soft≈ 0.848Continued exploration moves the boundary
LethalGreedy≈ 0.989A narrow transition near perfect execution
Lethalε = 0.10 softNo 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 mm clean movements, a clean run scales as pmp^m. The full maze is solved exactly rather than reduced to that expression, but the compounding mechanism remains.

04

TWO RANDOMNESSES

World noise is not agent exploration.

Reliability pp belongs to the environment. An intended action executes correctly with probability pp; otherwise it slips left or right with probability (1−p)/2(1-p)/2 each.

Exploration ϵ\epsilon belongs to the behavior policy. Here,

πϵ(a∣s)=(1−ϵ)1{a=a⋆(s)}+ϵ∣A∣.\pi_\epsilon(a\mid s)=(1-\epsilon)\mathbf 1\{a=a^\star(s)\}+\frac{\epsilon}{|\mathcal A|}.

Lowering pp changes the dynamics. Raising ϵ\epsilon changes the continuation policy being valued. The distinction survives even at p=1p=1: perfect actuation cannot prevent an exploratory policy from selecting a bad action.

In the lethal maze, persistent ϵ=.10\epsilon=.10 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.

05

THE BACKUPS

Three rules, two continuation objectives.

All three methods update an action value by

Q(St,At)←Q(St,At)+α[Yt−Q(St,At)].Q(S_t,A_t)\leftarrow Q(S_t,A_t)+\alpha\left[Y_t-Q(S_t,A_t)\right].

They differ in the target YtY_t. Here dt+1d_{t+1} is one only for a true terminal transition; the continuation value is then zero.

OFF-POLICY

Q-learning

YtQ=Rt+1+γ(1−dt+1)max⁡aQ(St+1,a)Y_t^Q=R_{t+1}+\gamma(1-d_{t+1})\max_a Q(S_{t+1},a)

Bootstraps toward the best next action. Its control target is greedy.

ON-POLICY

SARSA

YtSARSA=Rt+1+γ(1−dt+1)Q(St+1,At+1)Y_t^{\mathrm{SARSA}}=R_{t+1}+\gamma(1-d_{t+1})Q(S_{t+1},A_{t+1})

Uses the next action actually selected, including the consequences of continued exploration.

ON-POLICY · EXPECTED

Expected SARSA

YtExp=Rt+1+γ(1−dt+1)∑aπϵ(a∣St+1)Q(St+1,a)Y_t^{\mathrm{Exp}}=R_{t+1}+\gamma(1-d_{t+1})\sum_a\pi_\epsilon(a\mid S_{t+1})Q(S_{t+1},a)

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.

06

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.

1,080recoverable trials
840lethal trials
72annealing checks
199.2Mtraining interactions
07

PREDICTIONS

Predictions before analysis.

  1. Q-learning should place its finite-budget route transition near the greedy model boundary.
  2. SARSA and Expected SARSA should place theirs nearer the persistent-epsilon model boundary.
  3. 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.
  4. 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.

08

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.

Corridor-selection rates across reliability for Q-learning, SARSA, and Expected SARSA in recoverable and lethal hazard conditions
Figure 2. Final route selection by reliability, with 95% Wilson intervals across 20 training seeds. Vertical references mark the exact greedy and persistent-ε boundaries. An empirical boundary is the 50% crossing of the seed-level corridor-selection curve.Figure (SVG)Boundary data (CSV)

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

HazardMethodExact targetLearned p50 boundaryReading
RecoverableQ-learningGreedy · 0.8060.823 [0.815, 0.829]0.017 above the greedy reference
RecoverableSARSAε-soft · 0.8480.848 [0.840, 0.859]Aligned with the ε-soft reference
RecoverableExpected SARSAε-soft · 0.8480.853 [0.840, 0.857]0.005 above the ε-soft reference
LethalQ-learningGreedy · 0.9890.9988 [0.9983, 0.9989]0.010 above the greedy reference
LethalSARSAε-soft · no crossingNo crossingRight-censored; shelter through the grid
LethalExpected SARSAε-soft · no crossingNo crossingRight-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.

Mechanism checks comparing backup-target variance and route selection after exploration anneals
Figure 3. Route choice at the two declared annealing points and exact backup-target variance at matched states and Q-values. Annealing did not make all three methods recover the common greedy route at this budget.Figure (SVG)Analysis record (JSON)

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.

09

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.

10

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 repository
Full run identifiers
  • shortcut_or_shelter_recoverable-dea8b3bb98-20260818T165653.284759Z
  • shortcut_or_shelter_lethal-c224eb9e19-20260818T184221.884416Z
  • shortcut_or_shelter_annealed-7a6ceda8a8-20260818T200356.410162Z

This experiment uses a small environment so the exact objective and learned behavior can be compared directly.

The next research note isolates one finite-budget mechanism left unresolved here: when a bad outcome arrives, how long does a TD learner remain changed by it?

Read the next note →