Puzzle 2 – create an AI bot to guess a number

The Algorithm

Here's my Scratch program showing a way of coding a linear search algorithm so that the computer guesses a number that you're thinking of.

This is a very simple form of Artificial Intelligence (AI) I suppose. The computer's going to be doing the hard work this time.

This isn't too tricky. You should be able to figure out how it works.

Scratch program image

We can convert this program into Python, which is a much more powerful programming language.

It's pretty much one line of Python to a single Scratch block, although there are a couple of things we need to do a little bit differently in Python.

We'll divide the Scratch program into 3 blocks to make it easier to handle.