Operation Manual
A beginner’s guide to Scratch
29
Lesson 1.5: Artificial intelligence
LEARNING OBJECTIVE: In this exercise, you will learn how to put data into a
program and get your program to make a decision based on that data.
RESOURCES: The sprites “cat” and “bluedog”; the backgrounds “brick-wall1”,
“sydney”, “paris” and “new_ york”.
Artificial intelligence is an area of computer science where people try to make
computer programs that are smart in some way or another. The idea is to make
computers seem like they are thinking like humans. This is actually quite tricky, as
you can imagine, so here we are just going to give you a tiny taster of how you can
make your programs seem a bit intelligent.
The cat clearly thinks it’s clever, so let’s give it a chance to show us just how
intelligent it is. To do this, we will use some more inputs and outputs, together with
something called a “conditional statement”. That sounds very complicated, but it
isn’t really.
For my example, I have created two sprites: a cat and a dog. The cat is going to
ask the dog a number of questions, so we need some variables in which to store
the answers.
Create the following variables (we’ll tell you what they’re for in a minute):
age
country
holiday
name
Before we begin, you should also import the “bluedog” sprite and the backgrounds
“brick-wall1”, “sydney”, “paris” and “new_ york”. You will need them for what
comes next.
Does the dog want a holiday?
Notes:
First, we have to work out whether the dog actually wants to go on holiday. Select
the cat sprite and build the script you can see in the screenshot above to help the
cat find this out.