Reinforcement Learning Basics: Agents, Rewards, and Returns

3 minute read

Published:

TL;DR: Reinforcement learning studies how an agent chooses actions to improve its expected accumulated reward. Actions change the situations the agent encounters next. Start with the interaction loop, then learn how states, values, exploration, and policy updates fit together.

Decisions change the next training example

Intuition first. A robot navigating a corridor chooses whether to turn left or right. That choice changes its next camera image and the decisions that follow. It may only discover several steps later that one route reaches the goal.

The agent needs a rule for choosing actions, called a policy. The environment supplies the consequences: a new observation and a numerical reward. An episode is one run of a task, ending at a terminal condition such as reaching the destination.

Rewards are feedback about outcomes. They do not normally provide the correct action for every observation. The reward definition is part of the problem design: rewarding forward movement alone may encourage driving past a destination.

One step in the interaction loopThe new observation feeds the next decision. Rewards can arrive long after the action that made them possible. ObserveChoose an actionReceive feedback
The new observation feeds the next decision. Rewards can arrive long after the action that made them possible.

Reward is one outcome; return includes the future

We write \(R_{t+1}\) for the reward received after action \(A_t\). For an episode ending at time \(T\), the discounted return is

\[ G_t=\sum_{k=0}^{T-t-1}\gamma^kR_{t+k+1}, \qquad 0\leq\gamma\leq1. \]

The discount factor \(\gamma\) sets the weight of later rewards. For an infinite discounted sum with bounded rewards, using \(\gamma<1\) makes the return finite. The learning objective is an expectation over possible runs, rather than the outcome of one lucky run. Core RL definitions.

Worked example: accepting a short-term cost

Suppose a three-step route receives rewards \(-1,-1,+10\). With \(\gamma=0.9\),

\[ G_0=-1+0.9(-1)+0.9^2(10)=6.2. \]

An alternative that ends immediately with reward \(+2\) has return 2. The first route is preferable under this objective despite its negative initial reward. With \(\gamma=0\), only the first reward counts, and the preference reverses.

This does not mean one discount factor is universally correct. It means discounting is part of what “good behaviour” means in the mathematical problem.

Three objects that recur throughout the book

ObjectQuestion it answersExample
PolicyWhat action should I take?A distribution over left and right
Value functionHow much return should I expect?Expected return from this junction
Dynamics modelWhat happens after an action?Distribution of the next location

An agent may use several of these together. A learned value is not itself a reward, and a model of the next observation is not automatically a good action selector.

Read the foundations in order

  1. MDPs: states, observations, actions, and transitions.
  2. Bellman equations: relate present value to future value.
  3. Exploration: gather information while acting.
  4. Temporal-difference learning: learn values from sampled transitions.
  5. Policies and actor–critics: turn estimates into policy updates.

Then follow the paper chapters on IQL, GAE, TD3, and hindsight replay.

Key Insight: RL connects a choice now to rewards later. The first task is to define the interaction and objective clearly enough that an algorithm can learn the behaviour you intended.

References

  1. OpenAI. Spinning Up: Key Concepts in RL.
  2. Silver, D. Reinforcement Learning course, introduction and MDP lectures.