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 costs0.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π ⁣[GtSt=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 pp^\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,rs,a)[r+γmaxaQp(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 (1p)/2(1-p)/2 each.

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

πϵ(as)=(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)+α[YtQ(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. Heredt+1d_{t+1} is one only for a true terminal transition; the continuation value is then zero.

OFF-POLICY

Q-learning

YtQ=Rt+1+γ(1dt+1)maxaQ(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+γ(1dt+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+γ(1dt+1)aπϵ(aSt+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

VALIDATION IN PROGRESS

Empirical figures are still withheld.

All 1,992 planned trials reached succeeded manifest states, with zero recorded failures. I am checking completeness, evaluation pairing, and late-training stability before reporting the learned boundaries.

The empirical figures remain unpublished until these checks pass:

  • artifact and manifest integrity;
  • exactly 100,000 interactions in every trial;
  • matched held-out evaluation seeds across policy modes;
  • late-training route stability at calibration endpoints;
  • the frequency of 250-step truncations;
  • explicit reporting of nonmonotone learned curves;
  • right-censoring when a 50% boundary is absent from the grid;
  • confirmation that no Quick-mode output enters the analysis.

At each reliability value, a trained greedy policy makes a discrete start-state choice. The final fraction will describe disagreement across independently trained policies; it is not a stochastic mixture used by one policy.

09

LIMITS

What the evidence can support.

The final result will be conditional on the topology, reward law, discount, exploration rule, initialization, and 100,000-transition budget. It will not establish that SARSA is universally safer, that Q-learning is inherently reckless, or that one method is generally superior.

The EAST/SOUTH summary is also restricted to the plotted high-reliability domain. At sufficiently poor control, NORTH or WEST can become exact-optimal.

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. Raw Protocol-v2 artifacts remain local while validation is underway; the published record will include curated tables, figures, manifests, provenance, and compact data sufficient to reconstruct every reported statistic.

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 experiment asks what changes when the danger itself has memory and the current regime may or may not be observable.

All experiments →