title: Simple High-Low game in Ruby
body: <p>I'm trying to write a simple  high-low program that will output  like this:</p>
  
  <pre>$ ./highlow.rb 
  Please tell me the max value of the random number: 100
  Ok. The random number is generated between 1 and 100.  
  Make your guess: 50
  That's too low.  Guess again: 75
  That's too high.  Guess again: 63
  That's too low.  Guess again: 68
  Correct!  You guessed the answer in 4 tries!
  Would you like to play again? no
  OK. Goodbye.
  $</pre>
  
  <p>This is the code I have, but I'm going wrong somewhere. It appears to work sometimes:
  <pre><code>
  count=0
  play = true
  while play = true </p>
  
  <pre><code>print "Please tell me the max value of the random number: "
      max= gets.to_i
      num= rand(max)
  puts "Ok. The random number is generated between 1 and " + max.to_s + 
  "."
  print "Make your guess: "
      guess=gets.to_i
  
      while guess != num &amp;&amp; play != false 
          if guess &gt; num
              print "That's too high. Guess again: "
              guess=gets.to_i
              count+=1
          end
  
          if guess &lt; num
              print "That's too low. Guess again: "
              guess=gets.to_i
              count+=1
          else
              break
          end
  end
  </code></pre>
  
  <p>puts "Correct!  You guessed the answer in " + count.to_s + " tries!"
  print "Would you like to play again? "</p>
  
  <p>answer=gets.chomp!
      if answer  == 'n'
          play = false
          break
      end</p>
  
  <pre><code>if 
      answer == 'y'
      play = true
  end 
  </code></pre>
  
  <p>end
  puts "OK. Goodbye"
  </pre></code></p>
  
  <p>Any suggestions? Where am I going wrong?</p>