You can already train an image model for hand gestures. Today in Scratch you will load that model into a rock, paper, scissors game and play against the computer.
Before you build, think: what might go wrong if the model is only slightly sure about a gesture? Open the project space you saved earlier and get ready to build step by step: predict, run, investigate, modify, then make it your own.
Keep this short. Devices on Stretch3, students logged in, cameras free. Optional predict before anyone runs code: ask what might go wrong if the model is only slightly sure about a gesture, and park one or two answers to revisit later. Frame prior knowledge as what they can already do (train a gesture model), not as a dated previous lesson. Pairs at machines; you model the first moves on the board.
In this lesson, you will create a fun Rock, Paper, Scissors game using Scratch and Google Teachable Machine.
You will learn how to use your Teachable Machine Image model with rock, paper, and scissors hand gestures to play against the computer.
If you don't have a Teachable Machine Image model, don't worry! You can use the provided model.
Read the aim aloud: rock, paper, scissors driven by their image model, or the provided fallback if a pair has no URL. Stress that the model link is the bridge between training and this game. No code walkthrough here; move straight into setup.
Go to https://stretch3.github.io/ and start a new Scratch project and delete the Cat sprite.
Then, add the TM2Scratch extension by clicking on the Extensions button at the bottom left corner of the screen and selecting TM2Scratch. This extension allows you to use Google Teachable Machine Image models in your Scratch projects.
When you add this extension, it will automatically try and use your computer's camera. If necessary, click on 'Allow' to give it permission to use your camera. You should see what the camera is showing in the stage area.
Model on the board: open stretch3.github.io, new project, delete the cat, add TM2Scratch from Extensions. Watch for camera permission prompts; circulate and help anyone stuck on Allow. Common bug: extension added but video still off or camera denied, so the stage preview is blank.
Add a new sprite to the project that will represent the computer's choice in the game. You can choose any sprite you like, but for this example, we'll use the 'Gobo' sprite.
Students add a sprite for the computer side (Gobo is fine). Differentiation: quicker pairs can pick a themed costume; slower pairs just need any visible sprite. Key question: which sprite will show the computer's side of the game?
Create three new variables:
playerChoice - to store the player's choice.computerChoice - to store the computer's choice.result - to store the result of the game.Create the three variables together: playerChoice, computerChoice, result. Watch for spelling slips and for variables made as sprite-only when the class expects them visible. Ask why the program needs somewhere to store each choice before it can compare them.
You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.