10 PRINT TAB(25);"FLIP" 20 PRINT TAB(18);"CREATIVE COMPUTING" 30 PRINT TAB(16);"MORRISTOWN NEW JERSEY":PRINT:PRINT:PRINT 31 B1=50 32 PRINT "EXPLANATION (Y OR N)"; 34 INPUT T$ 36 IF LEFT$(T$,1) <> "Y" THEN 180 50 PRINT "ON EACH TURN, YOU GUESS YES <'Y'> OR NO <'N'>." 60 PRINT "ONLY ONE IS CORRECT, AND THE PROGRAM HAS DECIDED" 70 PRINT "WHICH ONE, BEFORE YOU MAKE YOUR GUESS. AT FIRST" 80 PRINT "YOUR ODDS ARE 50%, PURE CHANCE. BUT LATER THE" 90 PRINT "PROGRAM WILL TRY TO TAKE ADVANTAGE OF PATTERNS" 100 PRINT "IN YOUR GUESSING." 110 PRINT 120 PRINT "GAME ENDS AFTER ";B1;" TURNS; A SCORE OF "; 125 PRINT INT(B1/2-1);" OR MORE" 130 PRINT "IS GOOD. PROGRAM TELLS WHEN YOU WIN A TURN," 140 PRINT "BY TYPING AN ASTERISK ('*') AS THE FIRST" 150 PRINT "CHARACTER OF THE FOLLOWING LINE." 160 PRINT 170 REM 180 REM INIALIZE: 16 PROBABILITIES, 4 RESPONSES (X), 190 REM OLD-MEMORY FACTOR (F1), RANDOMNESS FACTOR (F2), 200 REM SCORES (S1,S2) AND RIGHT-ANSWER FLAG. 210 PRINT 220 PRINT 230 DIM P(16),X(4) 240 PRINT "BEGIN." 250 FOR I=1 TO 16 260 P(I)=.5 270 NEXT I 280 FOR I=1 TO 4 290 X(I)=0 300 IF RND(1) < .5 THEN 320 310 X(I)=1 320 NEXT I 330 F1=.8 340 F2=.3 350 S1=0 360 S2=0 370 A$=" " 380 REM 390 REM TAKE THE ESTIMATED PROBABILITY (Z1) 400 REM OF THE PERSON GUESSING YES. 410 REM USE AN ADJUSTED PROBABILITY . 420 I9=8*X(4)+4*X(3)+2*X(2)+X(1)+1 430 Z1=P(I9) 440 Z2=Z1 450 IF Z2 <> .5 THEN 480 460 Z2=RND(1) 470 GOTO 520 480 IF Z2 > .5 THEN 510 490 Z2=Z2*F2+0*(1-F2) 500 GOTO 520 510 Z2=Z2*F2+1*(1-F2) 520 Z5=0 530 IF RND(1) < Z2 THEN 560 540 Z5=1 550 REM 560 REM INTERACT WITH PERSON. GET HIS RESPONSE (Z3). 570 REM UPDATE RESPONSE HISTORY (X), APPROPRIATE PROB. (P(I9)). 580 PRINT A$; 590 Z3=0 600 INPUT H$ 610 IF LEFT$(H$,1) = "Y" THEN 650 620 IF LEFT$(H$,1) ="N" THEN 660 630 PRINT "ERROR, MUST BE Y OR N ." 640 GOTO 600 650 Z3=1 660 A$=" " 670 S2=S2+1 680 IF Z3 <> Z5 THEN 710 690 A$="*" 700 S1=S1+1 710 REM UPDATE X - THE LAST 4 CHOISES. 720 X(1)=X(3) 730 X(2)=X(4) 740 X(3)=Z3 750 X(4)=Z5 760 REM UPDATE THE PROBABILITY USING OLD 19. 770 P(I9)=F1*P(I9)*(1-F1)*X(3) 780 IF S2 < B1 THEN 380 790 PRINT A$; 800 PRINT 810 PRINT "END OF GAME." 820 PRINT "YOU GOT ";S1;" OUT OF ";S2;" CORRECT." 830 PRINT:PRINT 840 PRINT "PLAY AGAIN (Y OR N)"; 850 INPUT T$ 860 IF LEFT$(T$,1)="Y" THEN 240 870 END