Reinforcement learning is the part of machine learning where a program learns by doing. Instead of studying labelled examples, it takes actions, sees what happens and receives a score that says whether things went well. Over many attempts it learns which choices lead to higher scores. This idea sits behind game-playing programs, some robots and one of the training steps that make modern AI assistants more helpful.
This guide explains reinforcement learning in plain words. You will see the basic loop, the vocabulary, how it differs from other kinds of learning, how exploration and reward work, where the method succeeds, where it breaks and how it connects to the assistants you use today. No mathematics is required, though a small code sketch shows the shape of a real algorithm.
The core loop of reinforcement learning
Picture a robot vacuum learning a new flat. It cannot be given a perfect map and a list of correct moves. It has to try, bump into things and notice that some choices work better. Reinforcement learning describes this with five ideas that repeat in a loop.
- Agent: the learner that makes decisions, such as the robot or a game-playing program.
- Environment: everything the agent interacts with, such as the flat, the game board or a simulated factory.
- State: what the agent can observe right now, such as its position and the sensor readings.
- Action: a choice the agent can make, such as turning left or moving forward.
- Reward: a number that says how good the outcome was, such as plus one for cleaning a tile and minus ten for falling down the stairs.
At each step the agent looks at the state, picks an action, and the environment returns a new state and a reward. The agent’s aim is not the next reward but the total reward over time. That difference matters: a chess move that sacrifices a piece may look bad now and win the game later. The method is described in more detail in the overview of reinforcement learning and in the standard textbook by Sutton and Barto.
How it differs from other kinds of learning
Machine learning is usually divided into three families, and reinforcement learning is the one where the data does not exist before learning starts. The agent creates its own data by acting. Our article on pretraining describes the large-scale supervised and self-supervised side, which is how language models first learn.
| Type | What the learner receives | Typical goal | Example |
|---|---|---|---|
| Supervised learning | Inputs paired with correct answers | Predict the right label or value | Spotting spam e-mails |
| Unsupervised learning | Inputs only, no answers | Find structure or groups | Grouping customers by behaviour |
| Self-supervised learning | Inputs where part of the data is hidden and must be predicted | Learn general patterns | Predicting the next word in a sentence |
| Reinforcement learning | Rewards after actions in an environment | Choose actions that maximise long-term reward | A program learning to play a board game |
The key difference is feedback. Supervised learning is told the right answer for every example. Reinforcement learning is told only how well it did, often late and sometimes only at the very end. It must work out which of its many earlier actions deserve credit or blame, a problem known as credit assignment.
Exploration and exploitation
Imagine a restaurant that you like. Do you go there again, or try the new place next door? Going back is safe, but you may miss something better. Trying the new one is a gamble, but you may find a favourite. Reinforcement learning faces this trade-off at every step, and it has names for the two sides: exploitation means using what you already know works, and exploration means trying something new to learn more.
A simple strategy is called epsilon-greedy. Most of the time the agent picks the action it believes is best, and a small fraction of the time it picks at random. Early in training the random share is high, because the agent knows little. Later it shrinks. Too little exploration traps the agent in a mediocre habit, and too much wastes time on obviously bad moves. Tuning this balance is one of the practical arts of the field.
Policies, values and the discount
Three more terms appear in every explanation, and they are easier than they sound.
- Policy: the agent’s way of choosing actions. It can be a table, a rule or a neural network that maps a state to an action or to probabilities of actions.
- Value: an estimate of how much total reward the agent can expect from a state, or from a state and action together, if it follows its policy.
- Discount: a number between zero and one that makes future rewards count a little less than immediate ones. It reflects that distant outcomes are uncertain, and it keeps the totals finite.
Learning methods fall into two big groups. Value-based methods such as Q-learning learn how good each action is in each state and then pick the best one. Policy-based methods such as policy gradients adjust the policy directly so that actions leading to high reward become more likely. Many modern methods combine both ideas. When a neural network represents the policy or the value, the approach is called deep reinforcement learning.
A tiny example in code
The idea of Q-learning fits in a few lines. The agent keeps a table of scores for each state and action, and after each step it nudges the score toward what it just observed.
q = {} # (state, action) -> estimated value
alpha, gamma, epsilon = 0.1, 0.9, 0.1
def choose(state, actions):
if random.random() < epsilon:
return random.choice(actions) # explore
return max(actions, key=lambda a: q.get((state, a), 0.0)) # exploit
def learn(state, action, reward, next_state, actions):
best_next = max(q.get((next_state, a), 0.0) for a in actions)
old = q.get((state, action), 0.0)
q[(state, action)] = old + alpha * (reward + gamma * best_next - old)
Here alpha is the learning rate, gamma is the discount and epsilon controls exploration. In a small grid world this table is enough. For problems with enormous numbers of states, such as video frames, the table is replaced by a neural network. If you want to experiment, libraries such as Gymnasium provide ready-made environments to practise on.
Where reinforcement learning works
The method shines when there is a clear goal, a way to try actions many times and a reward that can be measured. Games are the classic case, because the rules are fixed, simulation is cheap and winning is an unambiguous score. Programs trained this way reached and passed top human players in board games and many video games. Control problems are another fit, such as balancing, walking or manipulating objects in a simulator, and some resource allocation and scheduling tasks.
In practice, the most successful uses share features: a good simulator, a well-defined reward, safe failure during training and plenty of computing time. Outside such conditions, supervised learning or simpler optimisation often does the job with less effort. Be sceptical of claims that reinforcement learning will solve a messy business problem without a clear reward and a safe place to practise.
Where it breaks: reward design and reward hacking
An agent optimises the reward you give, not the goal you had in mind. When the two differ, the agent finds the gap. This is called reward hacking, or specification gaming, and many documented cases exist. In a well-known boat-racing experiment, the agent learned to circle through bonus targets to collect points instead of finishing the race, because points were what it was rewarded for.
- Sparse rewards. If the only reward comes at the end of a long task, the agent may never stumble on success and learn nothing.
- Shortcuts. If a metric can be gamed, it will be, and the behaviour may look absurd to a human.
- Sample inefficiency. Agents often need millions of attempts, which is fine in a simulator and impossible with a real factory.
- The simulation gap. A policy that works in a simulator can fail in the real world because of small differences in physics or sensors.
- Safety during learning. Exploration means trying bad actions. That is harmless in a game and dangerous in a hospital or on the road.
The lesson is to treat the reward as a specification that needs testing, with human review of what the agent actually does. Our article on AI guardrails discusses limits that sit around a system, and the one on AI sycophancy shows how rewarding approval can distort an assistant’s behaviour.
Reinforcement learning inside AI assistants
You meet this method indirectly every time you use an assistant. After a language model is pretrained on text, it can complete sentences, but it does not yet behave like a helpful assistant. One common step is to collect human judgements about which answers are better, train a reward model on those judgements and then use reinforcement learning to adjust the language model so that it produces answers that score higher. Our guide to RLHF walks through that process.
A related approach rewards models for outcomes that can be checked automatically, such as a maths answer or whether code passes tests, and it is one of the ideas behind the reasoning-style models described in our article on AI reasoning models. These methods improve behaviour but do not remove errors, which is why the advice in AI hallucinations explained still applies. A model trained to please a reward can learn to sound confident, so keep checking what matters.
How to learn more
If you want to go beyond an overview, a good path is gentle. Read the first chapters of the free textbook Reinforcement Learning: An Introduction, then implement the tiny Q-learning loop above in a grid world, and then move to a standard environment from a library. Watch what the agent does, not only the score, because odd behaviour reveals reward problems early.
An assistant can be a good study partner here. Ask it to explain a term with a new analogy, to walk through one update step with numbers, to review your code or to suggest experiments, such as changing the discount and observing the effect. Always run the code yourself, because an assistant can describe an algorithm convincingly and still make an indexing mistake. The guide to learning to code with AI describes a routine that works for this kind of practice.
Using Mio to study reinforcement learning
Mio is one assistant with Chat, Write, Research, Code and Design modes, and you never pick a model: Mio routes each request to one suited to the task. In Chat mode you can ask for explanations at your level, from a child-friendly analogy to a precise definition. Code mode, available on the Coding and Business plans, helps you write and debug small experiments, though training runs happen on your own computer. Research mode on paid plans searches the web and cites sources, which helps when you want to read the original papers.
Projects and memory let you keep a study project with your notes, the glossary you are building and the code you are testing, so each session continues where the last one ended. Your chats and files remain yours, they are not used to train models and you can export or delete them at any time.
Frequently Asked Questions
What is reinforcement learning in simple terms?
It is learning by trial and error with a score. A program, called an agent, takes actions in an environment and receives rewards. Over many attempts it learns which actions lead to the highest total reward. Unlike supervised learning, nobody gives it the correct answer for each step, only feedback on how well it did.
Is reinforcement learning used in modern AI assistants?
Reinforcement learning is one step in how many assistants are tuned. After pretraining on text, models are often adjusted using human feedback so that helpful, safe answers score higher. It is only part of the process, and the main knowledge still comes from pretraining. The exact methods differ between products and are not always published.
What is the difference between reinforcement learning and supervised learning?
Supervised learning learns from examples with correct answers, such as images labelled cat or dog. Reinforcement learning learns from rewards after actions, often delayed, with no list of correct moves. Supervised learning needs a labelled dataset, while reinforcement learning needs an environment where the agent can try actions and receive a score.
What is reward hacking?
Reward hacking happens when an agent finds a way to earn a high reward without achieving the goal the designer intended. It optimises exactly what was measured, including loopholes. The remedy is careful reward design, testing of actual behaviour, human review and, where possible, several measures of success instead of a single score.
Can I try reinforcement learning without a powerful computer?
Yes. Simple problems, such as a grid world or a balancing task, train in minutes on an ordinary laptop with a standard library. Large problems, such as complex video games, need far more computing power. Start small, learn the loop and the vocabulary and scale up only when you understand what the agent is doing.
The Bottom Line
Reinforcement learning explained in one sentence: an agent learns to choose actions that earn the most reward over time, by trying things and keeping score. It is powerful where goals are clear and practice is cheap, fragile where rewards are vague, and a quiet ingredient in how assistants are tuned. To explore it with a patient study partner, start on the free plan and compare options on the Ask Mio pricing page.
