Scratch
Beginner
51 mins
Teacher/Student led
+180 XP

Code a Game That Uses Your Model

Part 2 of 2: students load the machine-learning model they trained earlier into Scratch and build a Rock, Paper, Scissors game played against the computer, then tune the confidence threshold to see how certainty affects recognition.

Teacher Class Feed

Load previous activity

    1 - Start: What We're Building ~5 mins

    Quick recap: you can already train and export a machine-learning model. Today we put that model to work inside a game. We are building a Rock, Paper, Scissors game in Scratch that you play against the computer using your own hand gestures.

    Open the project you saved earlier and have the model you trained ready to load. We will predict first, then build, run and fix as we go.

    2 - Predict Before You Run ~10 mins

    Before anyone clicks the green flag, look at what we are about to build and commit to a prediction. When the program runs, what do you think will happen first? Will the computer or the player choose first, and how will the game know which gesture you are showing the camera?

    3 - Introduction ~2 mins

    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.


    4 - Setup Scratch and Tm2scratch ~2 mins

    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.



    5 - Add a Sprite ~2 mins

    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.


    123learn · Online learning platform

    Unlock the full learning experience

    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.

    Hundreds of curriculum-aligned lessons
    Interactive activities in every lesson
    Printable resources & progress tracking
    Copyright Notice
    This lesson is copyright of Coding Ireland 2017 - 2025. Unauthorised use, copying or distribution is not allowed.

    Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at https://scratch.mit.edu
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more