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)


: high|low ( gn-g$ )
  over > [ "high" ] [ "low" ] if ;
 
: checkGuess ( gn-gf || f )
  2over = [ "You guessed correctly!\n" puts 2drop 0 ]
          [ high|low "Sorry, your guess was too %s.\nTry again.\n" puts -1 ] if ;
 
: think ( -n )
  random abs 100 mod 1+ ;
 
: guess ( - )
  "I'm thinking of a number between 1 and 100.\n" puts
  "Try to guess it!\n" puts
  think [ getToken toNumber checkGuess ] while
  "You got it!\n" puts ;
 