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


mini=0
maxi=100
 
print "Think of a number between ";mini;" and ";maxi
print "Each time I guess a number you must state whether my"
print "guess was too high, too low, or equal to your number."
print 
 
while response$<>"="
   if not(mini<=maxi) then 
		print "Error"
		exit while
	end if
	guess=int((maxi-mini)/2)+mini
	print "My guess is ";guess;". Type L for low, H for high, = for correct."
	input response$
	response$=upper$(response$)
	select case response$
		case "L"
			mini=guess+1
		case "H"
         maxi=guess-1
		case "="
			print guess;" is correct."
			exit while
		case else
			print "Your response was not helpful."
	end select
 wend
print "Thanks for playing." 