10 REM*  FROM KRUTCH, EXPERIMENTS IN AI
100 REM SUPERVISOR
110 GOSUB 190
120 GOSUB 250
130 GOSUB 310
140 GOSUB 550
150 GOSUB 380
160 GOSUB 490
170 GOSUB 420
180 GOTO 130
190 REM INITIALIZATION
200 RANDOMIZE
210 DIM Q(1111,2)
220 LE=4
230 PRINT CHR$(26)
240 RETURN
250 REM FIRST LE INPUTS FROM PLAYER
260 FOR I=1 TO LE
265 PRINT "   TYPE IN A STRING OF FOUR USING ONLY T AND F "
270 GOSUB 310
280 MP(I)=CD
290 NEXT I
300 RETURN
310 REM INPUT
320 PRINT:PRINT "              READY FOR NEXT T OR F"
330 IP$=INKEY$:
332 IF IP$="T" THEN 340
334 IF IP$="F" THEN 340 ELSE 330
340 IF IP$="T" THEN CD=1:GOTO 360
350 IF IP$="F" THEN CD=0:GOTO 360
360 PRINT CHR$(26)
370 RETURN
380 REM  LOCATION UPDATE
390 IF CD=1 THEN Q(LO,1)=Q(LO,1)+1:GOTO 410
400 IF CD=0 THEN Q(LO,2)=Q(LO,2)+1
410 RETURN
420 REM  LOCATION CALCULATION
430 A$=""
440 FOR I=1 TO LE
450 A$=A$+MID$(STR$(MP(I)),2)
460 NEXT I
470 LO=VAL(A$)
480 RETURN
490 REM   MATCH-PATTERN UPDATE
500 FOR I=1 TO LE-1
510 MP(I)=MP(I+1)
520 NEXT I
530 MP(LE)=CD
540 RETURN
550 REM  PRINTING AND SCOREKEEPING
560 PRINT "YOU TYPED:                ";IP$
570 PRINT "COMPUTER WAS PREDICTING: ";
580 IF Q(LO,1)>Q(LO,2)THEN TF$="T":T=T+1:PRINT TF$:GOTO 630
590 IF Q(LO,2)>Q(LO,1)THEN TF$="F":F=F+1:PRINT TF$:GOTO 630
600 RAN=INT(RND*2)
605 IF RAN=0 THEN GOTO 600
610 IF RAN=1 THEN TF$="T":T=T+1:PRINT TF$
620 IF RAN=2 THEN TF$="F":F=F+1:PRINT TF$
630 IF TF$=IP$ THEN NC=NC+1
640 PRINT "TOTAL NUMBER OF ENTRIES:   ";T+F
650 PRINT "NUMBER OF CORRECT PREDICTIONS"
660 PRINT "BY THE COMPUTER:   ";NC
670 PRINT "PERCENT OF CORRECT PREDICTIONS: "
680 PRINT INT(((NC/(T+F))*100)*10+.5)/10;"%"
690 RETURN
 THE COMPUTER:   ";NC
670 PRINT "PERCENT OF CORRECT PREDICTIONS: "
680 PRINT INT(((NC/(T+F))*100