10 GOSUB 5010:REM ** CLEAR AND HOME SCREEN **
20 PRINT "========================================================================"
30 PRINT " TRAP"
40 PRINT " CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
50 PRINT " Optimized for CDP1802 based COSMAC Elf systems using RC/BASIC-L2"
60 PRINT " Supports VT100 terminals"
70 PRINT "========================================================================"
80 REM ** TRAP - BY: STEVE ULLMAN, 8-1-72 **
85 REM ** UPDATED BY: DAVE RUNKLE, 11-29-2015 **
90 PRINT
95 LET G=6
100 LET N=100
105 LET W=0
110 LET P=0
120 INPUT "INSTRUCTIONS";Z$
130 LET A$=LEFT$(Z$,1)
140 IF A$<>"Y" GOTO 245
145 PRINT
150 PRINT "I am thinking of a number between 1 and ";N;". Try to guess my number."
160 PRINT "On each guess, you are to enter two numbers. trying to trap my number"
170 PRINT "between the two numbers. I will tell you if you have trapped my number,"
180 PRINT "if my number is larger than your two numbers, or if my number is"
190 PRINT "smaller than your two numbers. If you want to guess one single number,"
200 PRINT "type your guess for both your trap numbers. You get ";G;" guesses to"
210 PRINT "get my number."
220 PRINT "========================================================================"
230 INPUT "Hit enter to begin";Z$
240 GOSUB 5010:REM ** CLEAR AND HOME SCREEN **
245 PRINT "Games played: ";P;" Games won: ";W;" Games Lost:";P-W;" WIN ratio: ";(W*100)/P;"%"
250 LET X=RND(N)+1
255 OUT 4,X
260 FOR Q=1 TO G
270 PRINT:PRINT "Guess #";Q;
280 INPUT A,B
290 IF A = B IF X = A GOTO 470
300 IF A <= B GOTO 320
310 GOSUB 430
320 IF A <= X IF X <= B GOTO 380
330 IF X < A GOTO 360
340 PRINT "My number is LARGER than your trap numbers."
350 GOTO 390
360 PRINT "My number is SMALLER than your trap numbers."
370 GOTO 390
380 PRINT "You have trapped my number."
390 NEXT Q
400 PRINT:PRINT "Sorry, that's ";G;" guesses. The number was ";X
410 PRINT
420 GOTO 490
430 LET R=A
440 LET A=B
450 LET B=R
460 RETURN
470 PRINT "YOU GOT IT!!!":PRINT
480 LET W=W+1
490 LET P=P+1
500 INPUT "Try again";Z$
510 LET A$=LEFT$(Z$,1)
520 IF A$="Y" GOTO 240
530 PRINT "Here are your status:"
530 PRINT
540 PRINT "Games played: ";P
550 PRINT "Games won: ";W
560 PRINT "Games Lost:";P-W
570 PRINT "WIN ratio: ";(W*100)/P;"%"
580 PRINT
590 PRINT "Thanks for playing. Later!"
600 END
5000 REM ** VT100 CONTROL ROUTINES **
5010 REM ** CLEAR SCREEN AND HOME
5020 GOSUB 5050
5030 GOSUB 5080
5040 RETURN
5050 REM ** HOME SCREEN **
5060 PRINT CHR$(27);"[H";
5070 RETURN
5080 REM ** CLEAR SCREEN **
5090 PRINT CHR$(27);"[2J";
5100 RETURN