5.1.1 · D1Reinforcement Learning Foundations

Foundations — Agent, environment, state, action, reward

2,354 words11 min readBack to topic

This page builds every symbol the parent note uses, starting from a reader who has never seen an equation. We go one brick at a time. Nothing is used before it is drawn.


1. The loop itself (before any symbol)

Picture two boxes joined by two arrows.

Figure — Agent, environment, state, action, reward

Look at the figure. The left box is the agent (the decider). The right box is the environment (the world). One arrow goes agent → environment: the agent sends an action. Two arrows come back environment → agent: a new situation and a score.

Why we need this split. Learning only makes sense if there is a "me" that acts and a "not-me" that reacts. Without the boundary there is no notion of a choice having a consequence. This split is the seed of the whole topic.


2. Time steps and the little subscript

The loop happens over and over. We label each turn with a time step.

Picture: a filmstrip. Each frame is one value of . Frame , frame , frame … The subscript just tells you which frame you are looking at.

Why the topic needs it. The agent's whole job is to connect what it does now to what happens later. "Later" only has meaning if we can number the turns. is that numbering.


3. State — a complete description of the situation

Picture: in the grid world below, the state is simply which cell the robot stands on. That single fact — the coordinates — is enough to describe the whole situation.

Figure — Agent, environment, state, action, reward

Why "complete" matters. If the snapshot leaves something out that affects the future, the agent is guessing blind. When the snapshot is complete we call the world fully observable. When the agent only sees part of it (poker, a robot with weak sensors), we are in partial observability.

Recall Environment state vs. observation

What is the difference between the true state and the observation ? ::: is the world's real complete situation; is only what the agent actually perceives, which may be partial or noisy.


4. Action — the agent's one lever

Picture: in the grid figure, the four arrows out of the robot — North, South, East, West — are the possible actions. The agent picks one arrow.

Actions come in flavours:

  • Discrete — a finite menu: .
  • Continuous — a dial that slides: heater power anywhere in .

Why actions are "first-class". The agent cannot reach into the world and set the state or hand itself a reward. It can only choose ; everything else emerges as a consequence. This is why RL is called learning by trial and error.


5. Reward — the single score

Picture: in the grid figure, stepping onto the goal flag prints ; every ordinary step prints ; bumping a wall prints . One number per step.

Why a single number. To compare two behaviours the agent needs one score to rank them. A vector of scores gives no clear "better". Collapsing everything to one scalar is what makes "maximize" meaningful.


6. Reading the symbol — "is drawn from"

The parent note writes things like . We must earn that wiggle.

Picture: a spinner. says "spin it and take whatever it lands on." says "we're using the spinner for situation ."

Why the topic needs randomness. Worlds are often unpredictable: the same action in the same state can lead to different next states. lets us say "the next state is sampled, not fixed."


7. Policy — the agent's strategy

Picture: a lookup card. On the left, the situation; on the right, the arrow to take (or a set of odds over arrows). The policy is that card.

Why and not just "brain". All of learning is really "find a better card." Naming the card lets us later say "find the best policy " — see Policy and Value Functions.


8. Transition probability — the world's physics

Picture: from a cell in the grid, an action fans out into arrows to possible next cells, each labelled with a probability. In a clean grid one arrow has probability ; on ice, action "North" might land North and sideways each.

Why we write it as a probability. It gathers deterministic worlds (one arrow, probability ) and stochastic worlds (many arrows) under one notation. Whether the agent knows or not splits Model-Free vs Model-Based RL.


9. The Markov property — "the present is enough"

Picture: a chess board. To choose your next move you only need the current arrangement of pieces — not the order they arrived in. The present board is a sufficient summary of the past.

Why it is the whole reason states matter. If we designed the state well, we may throw away the entire history and still decide optimally. This assumption turns the loop into a Markov Decision Process (MDP).


10. Trajectory — the record of one run

Chain the symbols in loop order and you get the story of one episode:

Why name the whole sequence. The agent is judged not on any single step but on the whole run. Naming it lets us talk about the total score of a run — which is exactly the next symbol.


11. Return and discount — the total score

Why not just the immediate reward ? Because good moves can hurt now to help later (sacrifice a chess piece for checkmate). The agent must aim at the sum, not the flash. This is the single most common beginner error — see Policy and Value Functions and the parent's "Mistake 1".

Picture: a row of coins fading to grey as they go into the distance. The coin now is full-colour (); the coin steps away is worth a fraction of its face value.

Figure — Agent, environment, state, action, reward

Reading the . The stretched-S means "add up." The little underneath and on top say "let run from upward forever, adding one term each time." Each term is reward steps ahead, faded by .

Why keeps the sum finite. If every reward is at most in size, then

using the fact that a shrinking geometric sum settles down to . A finite total is what makes "maximize the return" a sensible goal. This trade-off — grab now vs. wait for more — is the heart of Exploration vs Exploitation and, in the simplest one-state case, Multi-Armed Bandits.


12. Expectation — averaging over randomness

Picture: roll a die many times and take the mean of the numbers — that long-run mean is the expectation.

Why the topic needs it. Because both the policy and the world can be random, the return of a single run is luck. The agent wants the policy whose average return is highest: .


Prerequisite map

Time step t

State s_t

Action a_t

Reward r_t

Policy pi

Transition P

Markov property

MDP

Trajectory tau

Return G_t

Discount gamma

Expectation E

Optimal policy

Read it upward: the humble time step feeds state/action/reward; those feed the policy and the world's physics; physics plus the Markov property give the MDP; the trajectory plus discounting give the return; averaging returns gives the goal.


Equipment checklist

Cover the right-hand side and see if you can answer each before revealing.

What does the agent control directly, and only that?
Its action — nothing else; state and reward emerge as consequences.
What does a subscript mean, as in ?
"The value of this quantity at turn of the loop" —
What makes a state a good state (the Markov property)?
Knowing the current state and action is enough to predict the next state and reward — the past can be discarded.
Read aloud: .
"Action is drawn from the policy's probability distribution over actions, given the current state ."
Read aloud: .
"The probability of moving to next-state given current state and action ."
Why maximize the return instead of the reward ?
Because short-term pain can buy long-term gain; only the discounted total captures that.
What does do, and why must it be below 1?
It fades far-off rewards by ; keeping makes the infinite sum finite ().
What does compute?
The average total discounted reward earned by following policy , over all the random runs it can produce.
State the recursive form of the return.
.
Value of for ?
.