Task

Write a player for the game that follows the following rules:

The scorer will choose a number between set limits. The computer player will print a guess of the target number. The computer asks for a score of whether its guess is higher than, lower than, or equal to the target. The computer guesses, and the scorer scores, in turn, until the computer correctly guesses the target number.
The computer should guess intelligently based on the accumulated scores given. One way is to use a Binary search based algorithm.



Related tasks

   Guess the number/With Feedback
   Bulls and cows/Player


10 PRINT "THINK OF A NUMBER BETWEEN 1 AND";" 9, AND I'LL TRY TO GUESS IT."
20 ISVALID=0
30 GUESS=5
40 PRINT "I GUESS"GUESS"."
50 INPUT "IS THAT HIGHER THAN, LOWER THAN OR EQUAL TO YOUR NUMBER? ",ANSWER$
60 IF ANSWER$="LOWER THAN" THEN ISVALID=1:IF GUESS<9 THEN GUESS=GUESS+1
70 IF ANSWER$="HIGHER THAN" THEN ISVALID=1:IF GUESS>1 THEN GUESS=GUESS-1
80 IF ANSWER$="EQUAL TO" THEN PRINT "OH YES! I GUESSED CORRECTLY!":END
90 IF ISVALID=0 THEN PRINT "SORRY";", BUT THAT ANSWER IS INVALID."
100 GOTO 40