Eligibility Traces
A fading memory of recently visited states, so each TD error updates all of them.
The idea
When a surprising reward arrives, the states and actions that led to it deserve credit. A trace records how recently and often each was visited and decays geometrically; every TD error then updates each value in proportion to its trace. It unifies TD and Monte Carlo and propagates reward backwards in one sweep.
eₜ(s) = γλ eₜ₋₁(s) + 1[s = sₜ]
Watch it run
This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.
- positive value
- negative value
- agent
TD(λ): the surprise (-0.04) is shared with every recently visited state, weighted by its eligibility trace (orange dots).
- episode:
- 1
The agent wanders randomly; we are only measuring how good each cell is.
Step by step
- 1On visiting a state, increase its trace.
- 2Compute the TD error.
- 3Update every state by α × error × its trace.
- 4Decay all traces by γλ.
Where it is used
Faster learning in TD(λ), SARSA(λ) and Q(λ).
Watch out for
Extra memory and computation for the trace vector.