Guess It in Chipmunk BASIC
1 ' ************************************************
2 ' *     Guess what number for ChipMunkBasic      *
3 ' *      E.K.virtanen. 2007, public domain       *
4 ' * Made for http::/www.ascii-world.com/guess-it *
5 ' ************************************************

10 ' CONST VARIABLES
11 lowest% = 1
12 highest% = 99
13 false% = 0
14 true% = 1
15 ' / CONST VARIABLES

100 ' MAIN PROGRAM
101 canexit% = false%
102 cls
103 randomize timer
104 randomed% = rnd(highest%) + lowest%
105 rounds% = 0
106 print "Guess the number im thinking?"
107 print "E.K.Virtanen 2007, public domain."
108 print "www.ascii-world.com"
109 print ""
110 print "Ok, i think random number between "; lowest%; " to "; highest% + lowest%; "."
111 print "Your job is to guess what it is in as minimal tries as possible."
112 print ""
113 print "After your every guess, ill give you hint is my number higher or lower than your guess."
114 print "You can exit by 'guessing' 0."
115 input "Press any key to start game.", temp$

120 ' * LOOP OF GAME
121 rounds% = 0
122 exitgame% = false%
123 cls
124 rounds% = (rounds% + 1)
125 print ""
126 print ""
127 print "This is round number: "; rounds%; "."
128 input "Give your guess: "; plrguess%
129 REM now we check the user input
130 REM if player wants to quit we change falses to trues
131 if plrguess% = 0 then goto 200
132 REM if it's higher...
133 if plrguess% > randomed% THEN Print "My number is smaller..."
134 REM if it's lower
135 if plrguess% < randomed% THEN Print "My number is higher..."
136 REM and finally, if it was correct guess we end loop
137 if plrguess% = randomed% then exitgame% = true%
138 if exitgame% <> true% and canexit% <> true% then goto 124

140 REM if only correct answer and no full exit we print out result of rounds.
141 if canexit% <> false% then goto 200
142 print "You got it!!!"
143 print "It took "; rounds%; " rounds to guess right number."
144 print ""
145 input "Press 'y' to play again. Any other key to quit."; temp$
146 if ucase$(temp$) = "Y" then goto 10
200 print "Thank you for playing."
210 quit
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.