Training Methods Beginner

Agent & Environment

The side that decides, and the stage that reacts to it

Key points
  • Reinforcement learning splits its world in two from the start. The side that acts is the agent, and everything else that reacts to that action is the environment.
  • Three things pass between them: the state the environment shows, the action the agent picks, and the reward that comes back.
  • These three repeat every single step. An action changes the stage, and the changed stage calls for the next action — a loop.
  • The agent often can't see the whole stage. When that happens, what it sees and the actual state are two different things.
  • Where the line gets drawn between agent and environment is a choice a person makes. Only whatever can be freely changed counts as the agent — everything else is the environment.
Contents

1The analogy

Sit down across a chessboard and the world splits into two right there. On one side is the player picking up and moving pieces; on the other is the board and every piece sitting on it. All the player can do is look at the board as it stands and choose where to move one piece. They can't flip the board over by hand, and they can't decide how the opponent responds. Make a move, and the board changes; the opponent responds, and it changes again. Then, looking at the newly changed board, the next move gets picked. The board never explains why a move worked — it only shows what's different now. Whatever skill improves lives in the player, not the board. These two sides are the agent and the environment in reinforcement learning. In this technical sense, an "agent" is nothing more than the decision-making half of this loop — a different thing entirely from an AI agent that carries out multi-step tasks for you.

2In detail

The side that chooses, and the side that responds

The agent is the side making the decision. All it has is the board as it currently looks and a list of moves it's allowed to make, and all it does is pick one and put it forward. The environment is the side that takes that move, processes it according to the rules, and hands back a changed board and a score. The rules of the game, the opponent's response, the laws of physics, even the day's luck — anything that isn't the agent belongs to the environment.

The reason for this split is to make clear exactly where the learning happens. The only thing that can be corrected is the way the agent chooses. How the environment reacts can't be changed — it can only be learned through experience. Drawing the line between what's your hand and what's the board is the first step in solving the problem.

A loop that turns once every step

One step has three beats. First, the environment shows the current board — this is called the state. The agent looks at that state and picks one action. The environment takes the action, changes the board, and hands back a new state along with a score. Then it loops back to the start and the same three beats repeat.

As this loop turns tens of thousands, hundreds of thousands of times, the agent gradually builds up a sense of which action, in which state, tended to score well. A standing rule for what to do in each situation gets refined out of everything that's piled up this way. That rule is called a policy.

What's seen and the real board can differ

In chess, the whole board is visible, but the real world isn't always like that. In a game with fog of war, part of the opponent's territory stays hidden; a robot working off a single forward-facing camera has no idea what's happening behind it. In cases like these, what the agent receives isn't the board's true state — it's a cropped slice of it.

Deciding based on that slice alone can trip things up when the same view actually hides completely different situations. That's why several recent frames sometimes get bundled together, or a running summary of everything seen so far gets carried along instead. The less of the board that's visible, the harder the problem gets.

Where the line gets drawn changes the problem

Take a robotic arm picking up an object. Treat turning each individual joint as the action, and the arm's motors fall on the environment side — the problem gets sliced very fine. Treat a broad instruction like "pick up the object on the left" as the action instead, and the whole arm's movement falls inside the environment, and the number of decisions drops sharply.

Neither way is fixed as the correct one. But there's a common rule of thumb: only put what the agent can actually change at will inside the agent. Things it can't help, like how fast a battery drains or how much friction the floor has, count as environment even when they're physically attached to its own body.

When one round ends, it starts over

Once a chess game ends, the pieces get reset and a new game begins. Reinforcement learning handles problems with a clear start and end the same way, breaking them into rounds one at a time. One such round is called an episode. A score is left behind at the end of every episode, and skill builds up over thousands of them.

Some problems have no end at all. Continuously adjusting factory equipment, or continuously balancing server load, has no final move. For problems like these, instead of cutting things into rounds, the total gets handled by shaving down and adding up far-future scores as the whole thing keeps running.

3More precisely

The interaction between agent and environment is usually written down using a framework called a Markov Decision Process: a bundle of five things — state, action, the probability of a state changing, reward, and a discount rate. Built into this is the assumption that knowing the current state is enough to determine what comes next. When something is hidden and that assumption breaks, it gets handled separately as a partially observed problem, and what the agent receives in that case is called an observation rather than a state.

The analogy breaks down in a few places. A chess opponent is a thinking being working toward its own goal, but the environment in reinforcement learning is treated as something that simply reacts according to fixed rules, with no goal of its own at all. Even in games against an opponent, it's standard to fold the opponent's moves into the environment as well, opponent included. And chess is turn-based, with two players patiently alternating, but in many reinforcement learning problems the environment doesn't wait its turn — time just keeps running whether the agent has decided yet or not.

4Try it yourself

5Common misconceptions

  • It's easy to think the agent refers to a robot's or a program's entire body, but actually only the decision-making part is the agent — a motor or a battery, anything that can't be freely changed, is environment.

  • It's easy to think the environment is a visible stage, like a game screen, but actually it covers everything that isn't the agent, rules and opponents and luck included.

  • It's easy to think the agent knows the environment's full state, but actually it's far more common for it to receive only a cropped slice of the picture.

7One-line summary

In shortThe agent is the side that looks at the board and picks the next move, the environment is the side that takes that move and hands back a new board and a score, and reinforcement learning is the work of turning the loop between them.

Spotted an error or have a better analogy? Suggest an edit · Last updated2026-09-02