Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Student activity guide

STEP 1: PREVIEW YOUR MISSION


In today’s activity, you will build a virtual pet program in Scratch that uses AI-powered extensions
to interact with us in ways that feel natural.

PROJECT PREVIEW Mission Checklist


Click the button below to open up a preview of ❏ I added multiple costumes for my
what you’ll be creating today. Virtual Pet sprite.
❏ I made my virtual pet sit or stand on my
shoulder wherever I go.
❏ My virtual pet reacts appropriately and
naturally when the AI detects smiling,
sadness, anger, and surprise.

STEP 2: READY, SET…Go!


Build a virtual pet program in Scratch that uses AI-powered extensions to interact with us in ways
that feel natural.

A — Remix the Starter Template


1. Go to bit.ly/CSE2_1-9_Template. If you are having trouble accessing the link, try the link in
the Appendix.
2. Name your project and save it to your computer or cloud drive. Don’t forget to save your
project while you work!
2 Student Activity Guide

B — add sprite costumes


First, pick out your virtual pet by adding costumes from the Sprite Library. We'll add them in
through the Costumes pane instead of adding a new sprite so we don't have to click-and-drag the
code blocks into the new sprite.

3. Click on the template sprite to select it.


4. Click on the tab above the Blocks Palette that is labeled
“Costumes”.
5. Hover over the sprite icon and click the magnifying glass from
the menu that pops up.
6. Browse through the costumes in the Sprite Library and click on
one that you want to use.
7. Repeat steps 5–6 until all the costumes you want to add are
added.

C — choose a voice
8. Test out different voice types by selecting them from the dropdown in the speak block
and then clicking on the script to hear how the voice sounds when saying, "Hi, friend!"
9. Choose one of the voice types by making sure it is selected from the dropdown.

D — follow the leader


10. From the Body Sensing blocks, drag in go to block and drop it in so it sits as the first block
in the forever loop.
11. Select one of your shoulders from the dropdown.
12. Click the green flag to test out your work and see where the sprite is located.
13. Drag in change x by and/or change y by blocks and place them underneath the go to
block.
14. Adjust the values in these blocks until the sprite is located where you want it to be.
a. To move up, use a positive number in change y by.
b. To move down, use a negative number in change y by.
c. To move right, use a positive number in change x by.
d. To move left, use a negative number in change x by.

E — add neutral response


15. Add a switch costume to block and place it above the first if-then block.
16. Then, select a neutral costume.
17. Add in any other blocks you need.

LESSON 1.9 | REAL-WORLD AI: chatbots


3 Student Activity Guide

F — add smile detection and react to smiling


18. Drag the expressing block into the empty
condition spot of the first if-then block.
19. Add a switch costume to block inside of the
empty slot of the first if-then block and
select a costume.
20. Add a say block underneath the previous
block and type in what the sprite will speak
aloud.
21. Add a speak block from the Text to Speech
extension underneath the say block and
type in what the sprite will speak aloud.

G — Test it out
22. Click the green flag to start your program, if needed.
23. Then, smile in view of the webcam.
24. Observe how the sprite reacts when you alternate between smiling and not smiling.

H — add more conditions


25. From the Face Sensing blocks category, find the feeling block and insert it inside of the
empty condition spot of the 2nd if-then block.
26. Select "sad" from the dropdown.
27. Drag in another feeling block and place it inside the empty condition spot of the 3rd
if-then block.
28. Select "anger" from the dropdown.
29. From the Operators category, find the greater than block and add it to the empty
condition spot of the 4th if-then block.
30. From the Face Sensing category, find the level of block and place it inside the 1st empty
spot of the greater than block.
31. Type "0" into the 2nd empty spot of the greater than block.
32. Add a switch costume to block inside of the empty slot of each remaining if-then block
and select costumes.
33. Add say blocks underneath the previous blocks and type in what the sprite will speak
aloud.
34. Add speak blocks underneath the say blocks and type in what the sprite will speak aloud.
35. If you wish for the sprite to respond in any other way, add these blocks in before moving
on to the next steps.

I — test it out
36. Click the green flag to start your program, if needed.
37. Then, alternate between making each of the expressions or emotions and not making any
of them.
38. Observe if the AI is perceiving any of the emotions too often and make adjustments
wherever it is necessary.

LESSON 1.9 | REAL-WORLD AI: chatbots


4 Student Activity Guide

If anything else doesn't work how you want it to, check your code, try a fix, and then test your
program again. You might also want to experiment with your program and see what else you can
make it do.

J — review your checklist


❏ I added multiple costumes for my Virtual Pet sprite.
❏ I made my virtual pet sit or stand on my shoulder wherever I go.
❏ My virtual pet reacts appropriately and naturally when the AI detects smiling, sadness,
anger, and surprise.

If you need help while working on your activity, you


Need Help? can watch the video walkthrough by clicking the
button here. Pause the video at any time and
return to your activity to try out each step for
yourself!

Appendix: VOCABULARY
Find this lesson's vocabulary below.

Natural interaction (n):


The ability for an AI to respond or behave in a way that the user would expect or find intuitive.
Turing Test (n):
A test of artificial intelligence and natural interaction, measured by the ability for a chatbot
to convince a person that it is human.
chatbot (n):
A program that holds a conversation with a human.

Appendix: Helpful Links


Use the links in this section if you are stuck or simply want to know more about a concept.

Project Links Additional Links


● PS AI Scratch Home ● Events blocks
● Project Template ● Motion blocks
● Sample Project ● Looks blocks
● Coding Activity Walkthrough Video

LESSON 1.9 | REAL-WORLD AI: chatbots

You might also like