Hi Richey,
I would setup a Hi and Lo variable, starting the Hi at 101 and the Lo at 0 then the guess is (Hi - Lo)/2 + Lo, so first guess is 101/2 + 0 = 50 (You might need INT to round down to integer guesses.)
From the feed back on the guess, raise the Lo or Lower the Hi.
So say 50 was too high, then your new Hi is 50 and your next guess is 50/2 + 0 = 25
If 50 was too low then the Lo is made 50 and (101 - 50)/2 + 50 = 75 is your next guess.
Continue in this way until the guess is correct.
You would find a word in a sorted list in the same way.
Append: This works in SmallBASIC
' Hi Lo AI.bas SmallBASIC 0.12.9 (B+=MGA) 2017-08-14
secret = int(rnd*100) + 1 ' < 1 to 100
Hi = 101 : Lo = 0 '< make these higher and lower than what the secret number can be (just tested secret = 100, oops!)
label anotherGuess
guess = int((Hi - Lo)/2) + Lo
print "Guessing: ";guess
if guess = secret then
print "Yes! The secret number was ";guess
? : input "Want to see another, y + Enter for yes ";yes
if yes = "y" then
? : secret = int(rnd*100) + 1 : Hi = 101 : Lo = 0
else
stop
fi
elif guess > secret then
Print "Too high!"
Hi = guess
else
print "Too Low!"
Lo = guess
fi
goto anotherGuess
EDIT: Hi start at 101 not 100