What Is Reinforcement Learning? A Beginner’s Guide to Agents, Actions, and Rewards
That single distinction separates reinforcement learning from every other branch of machine learning—and it explains why these systems learn the way they…

Key topics
The reward is a score, not a lesson.
That single distinction separates reinforcement learning from every other branch of machine learning—and it explains why these systems learn the way they do. A supervised model is handed the right answer and asked to imitate it. A reinforcement learning agent is handed a number after the fact and left to figure out what it did to earn it.
The Core Idea: Learning by Trial and Error
Reinforcement learning is a branch of machine learning where an agent learns to make decisions through trial and error inside an environment. The agent tries actions, observes what happens, and gradually improves based on the consequences.
Think about learning to play a video game. On your first attempt, you press buttons randomly, lose quickly, and learn almost nothing except that you lost. But after enough attempts, you start noticing patterns: jumping over that gap works, while running into that enemy does not. Nobody handed you a manual. The game simply gave you a score at the end, and you improved by paying attention to what led where.
That is the essence of reinforcement learning. The agent is never told the correct action. It receives feedback about how things went, and it must use that feedback to make better decisions next time.
The goal is not to maximize the next reward. The goal is to maximize the total reward the agent earns over time—which is a much harder problem than it sounds.
Knowledge check
Check your understanding
Answer this question before you continue.
The Agent-Environment Loop
Every reinforcement learning system runs on the same loop. Once you see this loop clearly, all the terminology starts to feel manageable.
Here is how it works, step by step:
- The agent observes the current situation.
- The agent picks an action based on what it sees.
- The environment responds with a new situation and a reward.
- The agent uses that experience to update its understanding.
- The cycle repeats.
That last step is where learning actually happens. Receiving a reward does not automatically improve the agent. The agent has to record what happened, compare it with what it expected, and adjust its future behavior before the next decision. Different algorithms perform this update differently, but they all share the same shape: experience comes in, the agent revises its understanding, and the next action reflects that revision.
Everything else in reinforcement learning is about making this loop work better.
Now let us name the parts. The agent is the learner and decision-maker. The environment is everything outside the agent—the rules, the obstacles, anything the agent cannot directly control. The observation is what the agent currently sees or knows about the situation; in simple examples, this is the state the agent needs to make its decision. The action is the choice the agent makes. The reward is the feedback signal the environment sends back. Each single pass through the loop is called a timestep, and one complete run from start to finish is an episode—like one game or one attempt.
A classic example is CartPole, a simple simulation where a pole is balanced upright on a cart. The agent observes the pole's angle and the cart's position. It can push the cart left or right. Each moment the pole stays upright earns a small reward. If the pole falls, the episode ends. The agent's job is to keep the pole balanced for as long as possible by learning which actions work in which situations.
Keep this example in mind: observe the pole, push left or right, get a reward for staying upright, repeat until the pole falls.
Knowledge check
Check your understanding
Answer this question before you continue.
Why Rewards Are Not Instructions
Here is the confusion that trips up nearly every beginner: a reward looks like feedback, and feedback sounds like instruction. It is not.
In supervised learning, the model is shown correct input-output pairs. You give it thousands of labeled examples—this image contains a cat, this email is spam—and it learns to imitate those labels. The correct answer is right there in the training data.
Reinforcement learning has no such luxury. The agent takes an action, and the environment returns a number. That number says nothing about what the agent should have done instead. A reward of zero for letting the pole fall does not tell the agent whether it should have pushed harder, pushed sooner, or pushed in the opposite direction. It just says: that went badly. Figure it out.
Note: The video-game analogy is useful, but it has a limit. A game designer may have built the scoring system, and a dog trainer deliberately gives treats. In a formal reinforcement learning setup, the environment is not an intentional teacher. It is just the system the agent operates in, and the reward is whatever signal you chose to define. Nobody is pointing at the right move.
This creates a practical problem that makes reinforcement learning genuinely harder than supervised learning. In supervised learning, your training data exists before you start. In reinforcement learning, the agent generates its own training data by interacting with the environment. If the agent makes poor choices early on, it collects poor data. Poor data leads to poor learning. Poor learning leads to more poor choices. This vicious circle is one reason reinforcement learning agents can be frustrating to train—and one reason they often need careful reward design and lots of experience before they improve.
Knowledge check
Check your understanding
Answer this question before you continue.
Delayed Consequences: The Hard Part
If every action produced an immediate reward, reinforcement learning would be simple. The agent would just try things, keep what works, and drop what does not.
Real tasks are rarely that cooperative. Many good actions produce no immediate reward, and some bad actions look perfectly fine in the moment.
Consider chess. A move that sacrifices a queen looks terrible right now—you just lost your most powerful piece. But if that sacrifice sets up a checkmate three moves later, it was the best move on the board. The immediate feedback says "bad," while the long-term outcome says "brilliant." An agent that only chased immediate rewards would never learn to sacrifice anything.
The same pattern appears in CartPole, though more subtly. A small push that looks harmless in the moment might set the pole on a path toward falling several seconds later. The agent cannot judge each action by its immediate reward alone. It has to learn which actions lead to good outcomes eventually.
This is why reinforcement learning agents aim to maximize the return—the total accumulated reward from a point onward—rather than the next single reward. And this is also why reinforcement learning algorithms rely on value functions, which estimate the long-term worth of being in a particular situation. You will meet value functions properly in a later article. For now, hold the idea: the agent must learn to judge actions by their distant consequences, not just their immediate payoff.
Knowledge check
Check your understanding
Answer this question before you continue.
The Policy: The Agent's Strategy
So how does the agent decide what to do? It follows a policy.
A policy is simply the agent's rule for choosing an action given what it observes. It is the agent's strategy for behaving.
Before the formal name, you already know what a policy looks like. In CartPole, a simple policy might be: "If the pole leans left, push left. If the pole leans right, push right." That rule is a policy. It maps observations to actions.
Learning in reinforcement learning is really about improving the policy. Early policies are often near-random—the agent pushes left or right without any real strategy. As the agent gathers experience, it adjusts the policy to favor actions that lead to better outcomes. The policy sits right in the middle of the loop, between observation and action. It is the thing that decides what happens next.
Where Reinforcement Learning Fits in Machine Learning
Reinforcement learning is one of the three main branches of machine learning, alongside supervised and unsupervised learning. Each answers a different kind of question.
| Branch | Question it answers | Training signal |
|---|---|---|
| Supervised learning | Given labeled examples, can you predict the label for new data? | Correct answers provided in advance |
| Unsupervised learning | Given unlabeled data, can you find structure or patterns? | No labels; patterns in the data itself |
| Reinforcement learning | Given an environment and a reward signal, can you learn a sequence of decisions that maximizes reward over time? | Rewards earned through interaction |
The kind of problem determines the right tool. Reinforcement learning is the natural fit when a task involves a sequence of decisions with delayed consequences and no ready-made correct answers. Game playing fits this pattern. So does robotics control, where a robot must decide how to move based on sensor readings. So do sequential decision problems like trading, where each decision affects the options available later.
Reinforcement learning is a poor fit when you have plenty of labeled data and need to make a single prediction. If you want to classify emails as spam or not spam, supervised learning is simpler, faster, and more reliable. Do not reach for reinforcement learning just because it sounds impressive. Use it when the problem genuinely requires learning from consequences across a sequence of decisions.
Your Next Step on the Learning Path
You now have the one mental model that organizes everything in reinforcement learning: observe, act, receive a reward, update your understanding, repeat—and improve the policy over time.
Hold onto these terms, because they are the shared vocabulary every reinforcement learning algorithm builds on: agent, environment, observation, action, reward, return, and policy. When you read about reinforcement learning elsewhere and feel lost, come back to the loop. Every concept you will meet later—value functions, exploration strategies, complex algorithms—exists to solve a problem inside this loop.
Here is a practice exercise you can do right now, without any code. Pick a familiar sequential task and name its parts out loud. A chess game: the agent is the player, the environment is the board and opponent, actions are moves, rewards come from winning or losing. Cooking a meal: the agent is the cook, the environment is the kitchen, actions are steps in the recipe, and the reward is a finished dish. The goal is to get comfortable mapping real situations onto the loop.
If you want to observe learning directly, run a CartPole experiment and watch the episode length across attempts. Early episodes end quickly because the agent is acting randomly. If learning is working, later episodes last longer as the agent keeps the pole balanced. One run can be noisy, so watch the trend across many episodes rather than judging from a single attempt. More interaction does not automatically mean learning—the question is whether behavior actually improves.
The natural next concept on your path is the tension between exploration and exploitation: should the agent try new actions that might lead to better rewards, or stick with actions it already knows work? That question, along with value functions, is where reinforcement learning starts to get genuinely interesting.
Reinforcement learning can feel like a wall of math when you first approach it. It is not. It is one loop, repeated thousands of times, with the agent slowly getting better at each pass. Build the loop first, and everything else will have a place to land.
Knowledge check
Final check
Finish the article by checking the ideas you just learned.
References
Research updated Sep 9, 2026


