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


min=0
max=100
 
If OpenConsole()
  PrintN("Think of a number between "+Str(min)+" and "+Str(max)+".")
  PrintN("On every guess of mine you should state whether my guess was")
  PrintN("too high, too low, or equal to your number by typing 'h', 'l', Or '='")
  Repeat
    If max<=min
      PrintN("I think somthing is strange here...")
      Break
    EndIf
    Guess=(max-min)/2+min
    Print("My guess is "+Str(Guess)+",is this correct? "): Respons.s=UCase(Input())
    If Respons="H":     max=Guess-1
    ElseIf Respons="L": min=Guess+1
    ElseIf Respons="="
      PrintN("I did it!")
      Break
    Else
      PrintN("I do not understand that...")
    EndIf
  ForEver
EndIf