10 REM ********************************
15 REM *                              *
20 REM *         CODEBREAKER          *
25 REM *                              *
30 REM * ADAPTED FROM A T.I. PROGRAM  *
35 REM *                              *
40 REM *MODIFIED BY RICK & LINDA BURNS*
41 REM *           12/6/82            *
42 REM ********************************
50 CLS
80 PRINT "    HI! WELCOME TO CODEBREAKER!"
81 PRINT
82 PRINT "THIS GAME WILL BOGGLE YOUR MIND":PRINT "SO BE PREPARED TO THINK!":PRINT "YOU'LL HAVE TO USE LOGIC TO GUESS":PRINT "THE NUMBER I'M THINKING OF,"
83 PRINT "BUT I'LL SUPPLY YOU WITH CLUES.":PRINT "WHEN YOU TYPE IN A FOUR DIGIT NUMBER,":PRINT "I'LL TELL YOU HOW MANY OF THE DIGITS"
84 PRINT "ARE IN MY NUMBER AND HOW MANY  OF THEM":PRINT "ARE IN THE RIGHT PLACES.":PRINT "USING A DIGIT MORE THAN ONCE IS A NO-NO"
85 PRINT "ZEROS MEAN NOTHING TO THIS GAME":PRINT "(LINDA'S ATTEMPT AT HUMOR).":PRINT "IN OTHER WORDS USE NUMBERS 1 THROUGH 9."
86 LOCATE 21,6:PRINT "PRESS ANY KEY TO BEGIN."
87 F$=INKEY$ : IF F$="" THEN 87
90 CLS
106 RANDOMIZE TIMER
110 DIM N(4)
120 FOR I=1 TO 4
130 N(I) = INT(9*RND) + 1
140 IF I=1 THEN 180
150 FOR J=1 TO I-1
160 IF N(I)=N(J) THEN 130
170 NEXT J
180 NEXT I
190 TRIES=0
200 INPUT "ENTER GUESS ";GUESS
210 SCORE=0
215 DEC=0
220 TRIES=TRIES + 1
230 FOR K=4 TO 1 STEP -1
240 DIGIT=CINT((GUESS/10-INT(GUESS/10))*10)
250 IF DIGIT<>N(K) THEN 280
260 SCORE=SCORE+1
270 GOTO 330
280 FOR L=1 TO 4
290 IF N(L)<>DIGIT THEN 320
300 SCORE=SCORE+.1
305 DEC=DEC + 1
310 GOTO 330
320 NEXT L
330 GUESS=INT(GUESS/10)
340 NEXT K
350 IF CINT(SCORE)<>SCORE THEN 380
360 PRINT STR$(SCORE);" IN THE RIGHT SPOT, 0 OUT OF ORDER"
370 GOTO 420
380 IF SCORE>1 THEN 411
390 PRINT " 0 IN THE RIGHT SPOT,";STR$(DEC)" OUT OF ORDER"
400 GOTO 420
411 PRINT STR$(CINT(SCORE));" IN THE RIGHT SPOT,";STR$(DEC);" OUT OF ORDER"
420 IF SCORE <> 4 THEN 200
421 IF TRIES =1 THEN PRINT " **YOU LUCKY SUCKER**" ELSE 423:PRINT "YOU GOT IT RIGHT ON YOUR FIRST TRY":PRINT "I'LL GET YOU NEXT TIME":GOTO 450
423 IF TRIES >15 THEN PRINT "YOU BUM! ";
424 IF TRIES <5 THEN PRINT "VERY GOOD! ";
430 PRINT "YOU TOOK ";STR$(TRIES);" TRIES TO GUESS"
440 PRINT "THE CODE NUMBER."
450 PRINT "WOULD YOU LIKE TO PLAY AGAIN?"
460 ERASE N
470 PRINT "ENTER Y OR N "
480 INPUT A$
485 RAND = GUESS
490 IF A$="Y" OR A$="y" THEN  104
492 CLS :LOCATE 10,1
495 PRINT "WELL, IT'S BEEN FUN"
497 PRINT "BUT IF YOU HAVE TO GO, I"
499 PRINT "WON'T HOLD YOU BACK. SEE YA LATER!!!"
500 END
