Visual explainer
Reinforcement Learning Foundations
An agent learns from actions and rewards. Follow a checked Q update, discounted choices, exploration, terminal states and two ways the setup can fail.
Reinforcement learning improves decisions using the consequences of actions. A reward evaluates what happened; it usually does not label the best action. In this synthetic example, choosing A reveals +1. The dashed B route remains unobserved, so this sample alone cannot establish which action is better. RL can also use demonstrations or known models; trial and error is not its only possible information source.
Action and feedback
A policy chooses an action from the current state. The world returns a reward and a next state. An MDP assumes the state contains the information needed to determine the next-state and reward distribution given the action. The loop's arrows carry different things: the agent chooses the action, while the environment determines its consequence.
Move an estimate
Q-learning estimates the return from taking an action and then acting optimally. With old estimate , observed reward , discount and next-state maximum estimate 2, the sampled target is . A learning rate moves halfway along the shared number line:
This is an estimate update, not a reward payment or a guarantee of stable neural-network training. The original Q-learning analysis gives tabular convergence conditions, including repeated state-action sampling and appropriate learning rates.
Look beyond one reward
In this separate deterministic two-door environment, A ends the episode with +2. B first costs -1, then pays +10 and ends; double rings mark terminal states. At , A returns 2 and B returns . Route lengths are schematic; reward labels define the calculation.
Account for discounting
The three signed bars use 40 drawing units per return unit. Now contributes -1, the next transition contributes discounted +9, and their sum is +8. In general, . The first reward has no discount; the second has one factor of .
Change the objective
Keep the two-door rewards fixed. At , B returns , below A's 2. At , B returns 8. All four bars share 40 units per return unit. Changing the discount changes the objective and can change the optimal policy; a larger discount is not automatically better.
Reward the intended task
This synthetic collection/reset environment pays +1 per collection, even when resetting makes the same item collectible again. A loop accumulates reward without taking the dashed exit toward the goal. Specification gaming concerns this gap between the literal reward and the intended outcome. Better optimization alone cannot repair a misspecified objective. For a related setting, see Robot Learning.
Try an alternative
Switch to a one-step deterministic bandit: A pays 1, B pays 2. The agent's estimates are 1 and 0 because B is untried. Always maximizing the estimate repeats A. The lower bars show true rewards known to us, not to the agent. With epsilon-greedy selection, and uniform exploration over two actions, B is sampled with probability on each decision while A is the unique greedy action. Exploration has a short-term cost and does not by itself establish convergence.
Stop at terminal states
Return to the Q-update fixture. For a true terminal transition, the target is just : there are no subsequent rewards. Starting from zero with gives 0.5. The crossed segment removes the earlier 1.8 continuation estimate. A time-limit truncation is different: if the underlying task continues, bootstrapping may still be appropriate.
Where It Breaks
The two histories end at the same observation O, but one underlying state requires L and the other R. A memoryless policy receiving only O must use the same action distribution for both; it cannot always choose correctly in both states. History, memory or a better state representation can distinguish them. This is a failure of the chosen observation-as-state assumption, separate from the reward-loop failure.
The Quick Version
- A chosen action reveals a consequence, not the best alternative.
- Policies send actions; environments return rewards and next states.
- The checked Q update moves zero to 1.4.
- Delayed rewards can justify an initial cost.
- Discounted contributions sum to return eight in this example.
- Discount changes can reverse the preferred action.
- Proxy rewards can favor loops over the intended goal.
- Exploration can uncover an underestimated action.
- True terminal targets omit continuation value.
- Identical observations can conceal states requiring different actions.