0
Chapter 3: Robots That Think 81
Make_Simple_Robots_interior_FIN.indd 81Make_Simple_Robots_interior_FIN.indd 81 4/26/22 1:55 PM4/26/22 1:55 PM
Drag the “if-then-else” stack of blocks inside the “forever” block so
it keeps repeating
(Figure
P
)
.
10. You’re done! Test your program by pretending to be the person using it.
Answer the questions and see if the conversation makes sense. Change
anything that needs fixing.
P
82
Making Simple Robots, 2nd Edition
Make_Simple_Robots_interior_FIN.indd 82Make_Simple_Robots_interior_FIN.indd 82 4/26/22 1:55 PM4/26/22 1:55 PM
TROUBLESHOOTING TIPS
The best way to prevent bugs (that’s computer-speak for problems with
the programming) is to try to break your own program. In fact, video game
companies hire QA (quality assurance) testers to do everything wrong they
can think of to see what happens. Here’s how to uncover possible bugs in
your chatbot program:
Try out your program with unexpected answers. If the chatbot doesn’t
respond in a way that makes sense, give it more answers to watch
for and more things to say. Use blocks like “and” or “join” from the
Operator menu (green) to add to the possibilities.
The best way to improve a program designed for other people to use
is to get other people to test it for you! They will also give you ideas for
other fun things to add.
GO BEYOND
Make your chatbot talk out loud!
If your computer has a microphone, open the Sounds tab and record
yourself reading the chatbots answers. Your spoken answers
will become sound files that you can play instead of using written
speech.
Put the person’s answers in a Text-to-Speech block and hear your
chatbot repeat the answers out loud. To find these blocks, click on
the extension symbol at the bottom of the Block Palette column
(bottom left of the screen). Choose the Text-to-Speech extension
and the blocks will be added to the column.
Make your chatbot smarter. The Scratch Wiki contains instructions for a
chatbot that analyzes each word in a person’s answer separately. Check
it out at en.scratch-wiki.info/wiki/Creating_a_Chat_Bot.
Try a Scratch-based AI activity to see how machines learn! The website
Machine Learning for Kids has some simple exercises to test out:
machinelearningforkids.co.uk.
Chapter 3: Robots That Think 83
Make_Simple_Robots_interior_FIN.indd 83Make_Simple_Robots_interior_FIN.indd 83 4/26/22 1:55 PM4/26/22 1:55 PM
Project: Code a Color-Sensing Pick
and Place Robot in Scratch
WRITE A PROGRAM FOR AN ANIMATED ROBOT THAT USES
SENSORS – JUST LIKE A REAL ROBOT!
One famous saying about robots is that they’re good for doing jobs that are
“dull, dirty, or dangerous.” That’s why you find a lot of robots in factories.
They can lift and move heavy objects, like car frames, handle tools like
super-hot plasma cutters that can be risky around humans, and do
repetitive tasks like sorting items from a moving conveyor belt that are
boring (and cause injuries from overuse of hands and arms).
Most pick-and-place robots that work on assembly lines consist of just an
arm with some kind of gripper at the end, such as the fin gripper in Chapter
1. But these robots still need sensors and programming to help them figure
out which items to grab, and where to put them.
84
Making Simple Robots, 2nd Edition
Make_Simple_Robots_interior_FIN.indd 84Make_Simple_Robots_interior_FIN.indd 84 4/26/22 1:55 PM4/26/22 1:55 PM
Scratch Paint Editor Basics
The Paint Editor works the same for both backdrops and sprites.
You can draw your own design from scratch (no pun intended),
or choose a design from the Scratch library and use these same
techniques to change the color, shape, or even “ungroup” and pull
the separate pieces apart. You can also upload your own images and
add to them.
A project can have more than one backdrop and more than one
sprite. (And each sprite can have several costumes.) To duplicate a
backdrop or sprite, just right click on the column on the left when
Paint Editor is open. To duplicate a costume, you can also right click
on it. Then you can create a different version of it.
HERE’S HOW THE PAINT EDITOR WORKS:
1. When you open the Paint Editor, check the button below the
workspace to make sure it’s in Vector mode, not Bitmap. (Vector
computer graphics work with shapes that are easy to resize and
move around.)
2. The icons to the left of the workspace let you choose different
paint tools:
Use the Fill box to choose a color. Move the sliders back and
forth to get different tones.
In this activity, you’ll use the color-sensing blocks that come with Scratch
to program a virtual robot that can sort items into different areas. Follow
the instructions below to make the example project: a robot arm that works
on an assembly line in a color cube factory. Whenever the robot detects a
green cube going by on the conveyor belt, it picks it up and tosses it into the
green cube area. Once you understand how the program works, you can
design your own type of sorting robot!
Chapter 3: Robots That Think 85
Make_Simple_Robots_interior_FIN.indd 85Make_Simple_Robots_interior_FIN.indd 85 4/26/22 1:55 PM4/26/22 1:55 PM
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset