Number Guessing Game

selim
edited December 2022 in MicroBlocks Support

The number guessing game project allows the Picobricks to find a number that you keep in the range of 1-128 by directing the Picobricks with the help of an IR sensor and remote control.

After pressing the button, Picobricks makes the first guess and waits for the player to direct by using the "up", "down" and "ok" keys of the controller.

Project Algorithm

  • Start when button is pressed.
  • Divide the max prediction value by 2.
  • If the player presses the up key, that is, if Picobricks’ prediction is less than the player’s number, divide the guess interval by 2 again and add it to the current Picobricks’ prediction.
  • If the player presses the down key, that is, if Picobricks’ prediction is greater than the player’s number, divide the guess interval by 2 again and subtract it from the current Picobricks’ prediction.
  • If the player presses “ok” button, end the game and congratulate Picobricks.
  • Repeat the 2nd, 3rd and 4th steps until the “ok” button is pressed.
  • Return the 1st step.

Project Pin Diagram

Project Images

MicroBlocks Codes of The Project


Comments

  • PicoBricks found the number I kept on his fourth try😄

    Creative, but can improve🧐

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!