Guess It in Runbasic
' Guess what number for RunBASIC www.runbasic.com
' E.K.virtanen. 2007, public domain
' asciiworld@gmail.com www.ascii-world.com
' Made because of this; http://www.ascii-world.com/guess-it
' min & max variable values
constMin = 1
constMax = 100
' main loop of program
[program]
rounds = 1
randomed = int(rnd(1)*constMax) + constMin
cls
print
print
print "Ok, i think a random number between "; constMin; " and "; constMax; "."
print "Your job is to guess what it is, in as minimal tries as possible."
print
print "After your every guess, ill give you hint is my number higher or lower than your guess."
Print "You can exit by 'guessing' 0."
[game]
' From here starts the gaming loop itself. This is looped until guess it right one.
print "This is round number:"; rounds
input "OK. What is your guess?"; guess
cls
let rounds = rounds + 1
' if player wants to quit
if guess = 0 then goto [yesno]
' error check
if guess < constMin or guess > constMax + constMin then
print "Error input: No rounds counted."
let rounds = rounds - 1
end if
' check if guess was correct, lower, higher or does player want to end game
if guess = randomed then goto [correct]
if guess < randomed then print "My number is higher."
if guess > randomed then print "My number is lower."
goto [game]
[yesno]
' If player wants to quit, we confirm it with this "sub"
input "Want to quit? Press '0' to confirm."; guess
if guess = 0 then end
goto [game]
[correct]
' Player got correct number. We celebrate it a bit.
print "You got it!!!"
print "It took "; rounds; " rounds to guess right number."
print ""
input "Press 'y' to play again. Any other key to quit."; playmore$
if instr("yY", playmore$) > 0 then goto [program]
end