­
Play Against AI – Challenge Your Coding Skills
Create and play against AI - Rock, Scissors, Paper Game
This challenge has been written by Kristina Slišurić and is part of the EU CODE WEEK CHALLENGES.
Target Audience
  1. Teachers and educators
  2. Lower Secondary School students (12 to 16 years)
Experience
  1. Intermediate
Duration
  1. 90 minutes
Purpose
  1. to understand how the machine learning cycle works.
  2. to build a machine learning model using Teachable Machine
  3. to familiarize yourself with the Pictoblox tool and import the created model into the project
  4. to set the stage and characters, create and initialize variables in Pictoblox
  5. to initialize the game, identify player movements, program random AI movements
  6. to create and test a game that involves artificial intelligence as an opponent in a game of Rock, Paper, Scissors.
Recommended Materials
  1. Teachable Machine
  2. Pictoblox
Description
We will create a model using Teachable Machine from images using three classes: Rock, Scissors and Paper. Model will be loaded into Pictoblox and used to create game which we can play against AI.
Instructions
  • Create a new image project on Teachable machine with 3 classes named Rock, Paper, and Scissor. For each class, capture via camera at least 400 pictures. Make sure to have a clear background. Train and export the model. Upload model and copy link.
  • Create a free account on Pictoblox site. Add a Machine Learning Extension and upload a model. Set the stage, variables and sprites. Initialize the game, identify player moves and the moves of AI and who wins the round.
  • Teachable Machine:
  • Train the data for the game.
  • Testing the model.
  • Pictoblox:
  • Export the model.
  • Add machine learning extension and load the model.
  • Set up the stage, variables and Sprite.
  • Initialize the game.
  • Identify Player’s Moves.
  • Set random AI Moves.
  • Broadcast random AI moves.
  • Make three blocks. Who wins the round?
  • A) Check if the player wins the round.
  • B) Check if the AI wins the round.
  • C) Check if round is a draw.
  • Program blocks.
  • Rock Paper Scissors Sprite
Share the link to your work in your Instagram Bio: tap the Edit Profile button on your Instagram and add the link to your work in the Website field. After that, create a new post, add a screenshot of your work, write “Link in Bio”, add the hashtag #EUCodeWeekChallenge and mention @CodeWeekEU.
Example
Click here to download this challenge as a word document.
SettingsRequest history78.04msRequest Duration3MBMemory Usage11.x
Laravel Version
11.44.2
PHP Version
8.3.9
Environment
test
Debug Mode
Enabled
URL
dev.codeweek.eu
Timezone
UTC
Locale
en
GET challenges/play-against-ai
status
200 OK
full_url
https://dev.codeweek.eu/challenges/play-against-ai
action_name
challenges.play-against-ai
controller_action
\Illuminate\Routing\ViewController
Theme
Open Button Position
Hide Empty Tabs
Autoshow
Reset to defaults
    status
    200 OK
    full_url
    https://dev.codeweek.eu/challenges/play-against-ai
    action_name
    challenges.play-against-ai
    controller_action
    \Illuminate\Routing\ViewController
    uri
    GET challenges/play-against-ai
    controller
    \Illuminate\Routing\ViewController
    prefix
    /challenges
    middleware
    web
    duration
    78.04ms
    peak_memory
    6MB
    response
    text/html; charset=UTF-8
    request_format
    html
    request_query
    []
    
    request_request
    []
    
    request_headers
    0 of 0
    array:15 [ "priority" => array:1 [ 0 => "u=0, i" ] "accept-encoding" => array:1 [ 0 => "gzip, deflate, br, zstd" ] "sec-fetch-dest" => array:1 [ 0 => "document" ] "sec-fetch-user" => array:1 [ 0 => "?1" ] "sec-fetch-mode" => array:1 [ 0 => "navigate" ] "sec-fetch-site" => array:1 [ 0 => "none" ] "accept" => array:1 [ 0 => "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7" ] "user-agent" => array:1 [ 0 => "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)" ] "upgrade-insecure-requests" => array:1 [ 0 => "1" ] "sec-ch-ua-platform" => array:1 [ 0 => ""Windows"" ] "sec-ch-ua-mobile" => array:1 [ 0 => "?0" ] "sec-ch-ua" => array:1 [ 0 => ""HeadlessChrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"" ] "cache-control" => array:1 [ 0 => "no-cache" ] "pragma" => array:1 [ 0 => "no-cache" ] "host" => array:1 [ 0 => "dev.codeweek.eu" ] ]
    request_cookies
    []
    
    response_headers
    0 of 0
    array:3 [ "cache-control" => array:1 [ 0 => "no-cache, private" ] "date" => array:1 [ 0 => "Sun, 06 Apr 2025 05:03:20 GMT" ] "content-type" => array:1 [ 0 => "text/html; charset=UTF-8" ] ]
    session_attributes
    0 of 0
    array:2 [ "_token" => "QuwALOhvgJUVXHDwr4mPRAbJIZ9lUmK7ow3eY5Rg" "locale" => "en" ]
    • Booting (64.67ms)time
    • Application (13.36ms)time
    • Routing (2.98ms)
    • View: 2021.challenges.play-against-aiviews
    • View: components.tailwindviews
    • View: 2021.challenges._authorviews
    • View: 2021.challenges._shareviews
    • View: 2021.challenges._downloadviews
    • View: include.licenceviews
    • View: layout.baseviews
    • View: layout.menuviews
    • View: layout.footerviews
    • View: scripts.countdownviews
    • Preparing Response (67μs)
    • 1 x Booting (82.87%)
      64.67ms
      1 x Application (17.11%)
      13.36ms
      1 x Routing (3.82%)
      2.98ms
      1 x Preparing Response (0.09%)
      67μs
      10 x View (0%)
      0μs
      10 templates were rendered
      • 2021.challenges.play-against-aiplay-against-ai.blade.php#?blade
      • components.tailwindtailwind.blade.php#?blade
      • 2021.challenges._author_author.blade.php#?blade
      • 2021.challenges._share_share.blade.php#?blade
      • 2021.challenges._download_download.blade.php#?blade
      • include.licencelicence.blade.php#?blade
      • layout.basebase.blade.php#?blade
      • layout.menumenu.blade.php#?blade
      • layout.footerfooter.blade.php#?blade
      • scripts.countdowncountdown.blade.php#?blade
      0 statements were executed0μs
            ClearShow all
            Date ↕MethodURLData
            #12025-04-06 05:03:20GET/challenges/play-against-ai10