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)


decl int high low
set low 0
set high 100
 
out "Guess a number between " low " and " high "." endl endl console
decl int target answer i
decl ursa.util.random random
set target (int (+ 1 (+ low (random.getint (int (- high low))))))
while (not (= answer target))
	inc i
	out "Your guess(" i "): " console
	set answer (in int console)
 
	if (or (< answer low) (> answer high))
		out "  Out of range!" endl console
		continue
	end if
	if (= answer target)
		out "  Ye-Haw!!" endl console
		continue
	end if
	if (< answer target)
		out "  Too low." endl console
	end if
	if (> answer target)
		out "  Too high." endl console
	end if
end while
 
out endl "Thanks for playing." endl console