Task

Write a game (computer program) that follows the following rules:

 The computer chooses a number between given set limits.
 The player is asked for repeated guesses until the the target number is guessed correctly
 At each guess, the computer responds with whether the guess is:
 higher than the target,
 equal to the target, 
 less than the target,   or
 the input was inappropriate. 


Related task

   Guess the number/With Feedback (Player)


import Nanoquery.Util
 
random = new(Random)
inclusive_range = {1, 100}
 
print format("Guess my target number that is between %d and %d (inclusive).\n",\
             inclusive_range[0], inclusive_range[1])
target = random.getInt(inclusive_range[1]) + inclusive_range[0]
answer = 0
i = 0
while answer != target
	i += 1
	print format("Your guess(%d): ", i)
	txt = input()
 
	valid = true
	try
		answer = int(txt)
	catch
		println format("  I don't understand you input of '%s' ?", txt)
		value = false
	end
 
	if valid
		if (answer < inclusive_range[0]) or (answer > inclusive_range[1])
			println "  Out of range!"
		else if answer = target
			println "  Ye-Haw!!"
		else if answer < target
			println "  Too low."
		else if answer > target
			println "  Too high."
		end
	end
end
 
println "\nThanks for playing."