Log inStart free
LESSON 15.05 · 5 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

The agent–environment loop

An agent and an environment trade actions, observations and rewards, one timestep at a time.


Pro lesson. Stage 1 is free to watch. Pro opens all 5 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 15.05 · RL BAYSTATE CELL 3 · T 0 · π(RIGHT) 0.80
01
Stage 1 of 5 · The loop
The agent reads an observation and picks an action. The environment owns the state and sends back a reward.
Explain it simply

On the left is the agent. On the right is the environment: a corridor with a pit and a goal. The dashed line is the boundary: only an action crosses it from the left. The environment keeps the state. It sends back what the agent sees and a reward.

The agent box shows a policy: right 0.80, left 0.20. The environment box shows 7 cells with the agent in cell 3.

The policy is fixed, not trained.
observation, rewardpolicyaction, returnpenalty, slipboundary, reset, off
boundaryagentsees: cell 3policy π←0.20→0.80environmentstate: cell 3 · t 00pit −1123start456goal +1each move −0.1 · slip 1 in 10 · horizon 12actionobservationrewardboundaryagentsees: cell 3policy π←0.20→0.80environmentstate: cell 3 · t 00pit −1123start456goal +1each move −0.1 · slip 1 in 10 · horizon 12actionobservationreward
Toy: a 7-cell corridor or a 2-armed bandit
STAGE 1 / 5
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
at∼π(⋅∣ot)\sy{a}{out}{a_t} \sim \sy{pi}{param}{\pi}(\cdot \mid \sy{o}{data}{o_t})
π(R∣3)=0.80, π(L∣3)=0.20\pi(R \mid 3) = 0.80,\ \pi(L \mid 3) = 0.20

The policy gives each action a chance, given the observation.

Common mix-ups

MYTHThe agent decides which cell it moves to.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01In the bandit with a 12-step horizon, how many timesteps does one episode last?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 5
Unlock the full explainer
  • 4 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.