Skip to content
AI360XpertBeta
Core ML

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.

One chosen action reveals a reward while the alternative remains unobserved.
One chosen action reveals a reward while the alternative remains unobserved.

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

The agent sends an action and receives a new state and reward.
The agent sends an action and receives a new state and reward.

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

A half-step moves Q from zero to 1.4 toward the target 2.8.
A half-step moves Q from zero to 1.4 toward the target 2.8.

Q-learning estimates the return from taking an action and then acting optimally. With old estimate Q(s,a)=0Q(s,a)=0, observed reward r=1r=1, discount γ=0.9\gamma=0.9 and next-state maximum estimate 2, the sampled target is 1+0.9(2)=2.81+0.9(2)=2.8. A learning rate α=0.5\alpha=0.5 moves halfway along the shared number line:

Q(s,a)←Q(s,a)+α[r+γmax⁡a′Q(s′,a′)−Q(s,a)]=1.4.Q(s,a)\leftarrow Q(s,a)+\alpha[r+\gamma\max_{a'}Q(s',a')-Q(s,a)]=1.4.

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

A two-step route can beat an immediate reward despite its initial cost.
A two-step route can beat an immediate reward despite its initial cost.

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 γ=0.9\gamma=0.9, A returns 2 and B returns −1+0.9(10)=8-1+0.9(10)=8. Route lengths are schematic; reward labels define the calculation.

Account for discounting

Discounting the later ten gives nine and a total return of eight.
Discounting the later ten gives nine and a total return of eight.

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, Gt=Rt+1+γRt+2+γ2Rt+3+⋯G_t=R_{t+1}+\gamma R_{t+2}+\gamma^2R_{t+3}+\cdots. The first reward has no discount; the second has one factor of γ\gamma.

Change the objective

The same rewards favor different actions when the discount changes.
The same rewards favor different actions when the discount changes.

Keep the two-door rewards fixed. At γ=0.2\gamma=0.2, B returns −1+0.2(10)=1-1+0.2(10)=1, below A's 2. At γ=0.9\gamma=0.9, 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

A rewarded collection loop can bypass the intended goal.
A rewarded collection loop can bypass the intended goal.

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

A greedy estimate can keep an untried better action hidden.
A greedy estimate can keep an untried better action hidden.

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, ϵ=0.1\epsilon=0.1 and uniform exploration over two actions, B is sampled with probability 0.1/2=0.050.1/2=0.05 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

A true terminal transition has no continuation term in its target.
A true terminal transition has no continuation term in its target.

Return to the Q-update fixture. For a true terminal transition, the target is just r=1r=1: there are no subsequent rewards. Starting from zero with α=0.5\alpha=0.5 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 same observation can hide states that require opposite actions.
The same observation can hide states that require opposite actions.

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.