B2 · How Artificial Intelligence Works: Data and Learning

Reinforcement Learning

Reinforcement learning is machine learning by trial and error. An agent takes actions in an environment and receives rewards for good outcomes and penalties for bad ones. Over many tries it learns which actions lead to the most reward.

8 min Beginner Jump to the activity

What you need: Nothing. This page starts from the beginning, with no programming and no formulas.

Definition

How do you teach a dog a new trick without explaining it in words?

Reinforcement learning is machine learning by trial and error. An agent takes actions in an environment and receives rewards for good outcomes and penalties for bad ones. Over many tries it learns which actions lead to the most reward.

In simple words

Give a dog a treat when it sits, and nothing when it doesn't. Soon it sits on command. Nobody showed it the right answer; it found out from rewards. In the maze activity, the robot gets points for reaching the trophy and loses points for traps and wasted steps. After enough practice, it finds the best route.

Why it matters

Reinforcement learning taught computers to play games such as Go and chess better than any person, and helps robots learn to walk and grab objects. It is also part of how chatbots are trained to give more helpful answers.

How it works

PartIn the maze
AgentThe robot
EnvironmentThe grid of squares
ActionsMove up, down, left or right
Reward+10 for the trophy
Penalty−10 for a trap, −1 for each step

Try it yourself

Guide a robot through a maze with rewards

Watch the robot wander randomly first. Then let it practise and see its route and score improve.

Common mistakes

  • Thinking the robot is told the route. It learns only from rewards and penalties.
  • Mixing it up with supervised learning. There are no labelled answers, only rewards.
  • Thinking a few tries are enough. It usually needs a great deal of practice.

Check yourself

Question 1

1. What does an agent learn from in reinforcement learning?

Question 2

2. Which is a famous use of reinforcement learning?

Question 3

3. Why does each step cost −1 in the maze?

Summary

  • Reinforcement learning is learning by trial and error with rewards.
  • An agent acts, gets rewards or penalties, and improves.
  • It powers game-playing AI and robots that learn to move.

Finished reading?

Sources: AI4K12: Five Big Ideas in AI