Value-Based Methods in RL
Score every move by its predicted future payoff, then take the max. The policy falls out for free, no separate actor required.
Why Does This Exist?
Judging actions by immediate reward is short-sighted: a now can strand you three steps later. Learning a policy directly from full episodes works but needs complete trajectories before any update, which means crippling variance on long horizons.
Value-based methods change the question from "what should I do?" to "how much future reward does each move promise?" Learn an action-value function , then act greedily: . No actor network, no trajectory waits. One transition updates one estimate through bootstrapping, which is why Q-learning, SARSA, and deep Q-networks all sit on this foundation.
The one idea you need first
A Markov decision process frames the world as states, actions, rewards, and a discount that prices the future. Value methods live inside that frame: is the expected discounted return from doing in and behaving well after. Skim the MDP page for the tuple; this page is what you build on top of it.
Think of It Like This
A chess coach who scores positions, not moves
A bad chess coach hands you a book of memorized openings: play this exact sequence here. It works until move twelve, then you are on your own. A good coach teaches you to score any position: queen centered plus king safe is worth a lot, a hanging rook subtracts a lot.
With scoring learned, moves need no book. Look at every legal move, score the resulting position, take the max. The score compresses thousands of future lines into one number, and the greedy rule reads it back out. That is plus argmax.
Where the analogy stops: a coach's scores come from deep search that is actually correct. Learned Q-values bootstrap off each other, so early scores are guesses training guesses, and the max operator amplifies the loudest guess. The pitfall below is that amplification biting.
How It Actually Works
The optimal values satisfy the Bellman optimality equation: the value of is the immediate reward plus the discounted best value onward.
Here is expected immediate reward, the transition model, and the discount. Model-free agents never see ; from each transition they build a sampled target and nudge the estimate toward it:
The bracketed term is the TD error . During training, pure argmax never tries anything new, so behavior is usually -greedy: random move with probability , greedy otherwise.
Worked example
State , two actions, , . Current estimates: , . The agent explores , gets , lands in where and .
Next-state max: . Target: . TD error: . Update: .
One transition flipped the greedy choice at : , so now wins. That is bootstrapping in one line, an estimate trained on another estimate, and Q-learning and SARSA are the two classic ways to run this loop.
Code
This snippet replays the worked update on a tiny Q-table. Only the standard library and numpy are used.
from typing import Dictimport numpy as np
def q_update(q: Dict[str, np.ndarray], s: str, a: int, r: float, s_next: str, gamma: float = 0.9, alpha: float = 0.4) -> float: """One Bellman optimality backup. Returns the TD error.""" target = r + gamma * float(np.max(q[s_next])) td_error = target - float(q[s][a]) q[s][a] += alpha * td_error return td_error
q: Dict[str, np.ndarray] = {"S0": np.array([3.0, 2.5]), "S1": np.array([5.0, 4.0])}print(round(q_update(q, "S0", 1, 1.0, "S1"), 2)) # -> 3.0print(q["S0"].tolist()) # -> [3.0, 3.7]print(int(np.argmax(q["S0"])) + 1) # -> 2The TD error of 3.0 lifts from 2.5 to 3.7, so argmax now returns action 2.
Watch Out For
Believing the max of noisy estimates
grabs the loudest estimate, and noise has a loud side: . With several similar-valued actions plus approximation noise, the target keeps sampling positive spikes and values inflate across dead-end states. Symptom: Q-values climb far past any return the agent ever observes, then the policy chases ghosts.
Split selection from evaluation as in double Q-learning: pick with the online net, score it with the target net. If your values exceed plausible returns, suspect the max before the reward.
Decaying epsilon before values mean anything
Teams anneal to near zero in the first thousand steps to "lock in" learning, but early Q-values are initialization noise, so greed locks onto whichever action started highest. Symptom: the policy converges fast to something mediocre and never recovers, while a longer-exploring run passes it.
Keep high until TD errors stabilize, then decay slowly. Fast convergence to a bad policy is not convergence working; it is exploration ending early.
The Quick Version
- Value-based methods learn , the expected discounted return of each move, and act by argmax with no actor network.
- The Bellman optimality target turns one transition into one update via the TD error.
- Bootstrapping makes learning off-policy and sample-efficient: estimates train on estimates.
- The max operator overestimates under noise, so split action selection from evaluation with double Q-learning.
- Epsilon-greedy must stay open long enough for values to earn their greed, or the policy locks onto noise.