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)


to guess [:max 100]
  local "number
  make "number random :max
  local "guesses
  make "guesses 0
 
  local "guess
  forever [
    (type [Guess my number! \(range 1 -\ ] :max "\):\ )
    make "guess first readlist
    ifelse (or (not numberp :guess) (lessp :guess 1) (greaterp :guess :max)) [
      print sentence [Guess must be a number between 1 and] (word :max ".)
    ] [
      make "guesses (:guesses + 1)
      ifelse lessp :guess :number [
        print [Too low!]
      ] [ifelse equalp :guess :number [
        (print [You got it in] :guesses "guesses!)
        stop
      ] [
        print [Too high!]
      ]]
    ]
  ]
end
 