SARSA
Learns Q values from the action the agent actually takes next (on-policy).
The idea
Named after the tuple (State, Action, Reward, State′, Action′). It updates Q(s, a) toward r + γ·Q(s′, a′), where a′ is the action the current policy really picks. It therefore learns the value of the exploratory policy itself, which makes it more cautious near dangers than Q-learning.
Q(s,a) ← Q(s,a) + α [r + γ Q(s′,a′) − Q(s,a)]
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
- best action
- agent
SARSA: update Q(s,a) toward reward + γ·Q(next state, the action we will actually take).
- episode:
- 1
The agent explores with some randomness while learning which action is best in each cell.
Step by step
- 1Choose a from s with the policy (ε-greedy).
- 2Take it; observe r and s′.
- 3Choose the next action a′ from s′ with the same policy.
- 4Update Q(s, a) toward r + γ·Q(s′, a′).
- 5Move to s′ and a′ and repeat.
Where it is used
Problems where safe behaviour during learning matters.
Watch out for
Learns the exploratory policy, not the optimal one, unless ε decays.