Compucolor.org – Virtual Media

Listing of file='FLIP.BAS;01' on disk='vmedia/chip_24-sector.ccvf'

10 PLOT 6,2,29,12,14:PRINT TAB( 27)"F L I P"
11 REM  BY J.S. JAMES
12 REM  CREATIVE COMPUTING
13 REM  VOL 3, NO 2, MARCH/APRIL, 1977, P.126
14 REM
15 REM  ADAPTED FOR COMPUCOLOR DISK BASIC 8001 V6.78
16 REM  BY D.B. SUITS
17 REM  NOVEMBER, 10 A.L.
18 REM  
20 PRINT :INPUT "DO YOU WISH INSTRUCTIONS? ";T$
35 PLOT 15
40 IF LEFT$ (T$,1)= "N"THEN 180
50 PRINT
55 PRINT "ON EACH TURN, YOU MUST GUESS EITHER YES OR NO.  (JUST TYPE IN"
57 PRINT "Y OR N.)"
58 PRINT
60 PRINT "ONLY ONE IS CORRECT, AND I HAVE DECIDED IN ADVANCE WHICH ONE"
70 PRINT "WILL BE CORRECT."
75 PRINT
80 PRINT "AT FIRST YOUR CHANCES OF BEING CORRECT ARE 50%.  BUT AS THE"
90 PRINT "GAME PROGRESSES, I SHALL BE ABLE TO TAKE ADVANTAGE OF PATTERNS"
95 PRINT "I FIND IN YOUR GUESSES IN ORDER TO REDUCE YOUR CHANCES OF BEING"
97 PRINT "CORRECT."
110 PRINT
120 PRINT "EACH GAME CONSISTS OF 50 TURNS."
125 PRINT :PRINT "I CONSIDER 24 OR MORE CORRECT GUESSES IN A GAME TO BE A PRETTY"
127 PRINT "GOOD SCORE."
130 PRINT
170 REM  
180 REM   INITIALIZE.  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
235 CLEAR 250
237 DIM G(20)
238 T= 0
240 DIM P(16),X(4),A$(60)
250 PRINT :PRINT "            BEGIN GAME #"T+ 1".":PRINT
255 FOR I= 1TO 16
260 P(I)= .5
270 NEXT I
280 FOR I= 1TO 4
290 X(I)= 0
300 IF RND (1)< .5THEN 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 PLAYER'S GUESSING 'YES'.
410 REM   USE AN ADJUSTED PROBABILITY (Z2).
420 I9= 8* X(4)+ 4* X(3)+ 2* X(2)+ X(1)+ 1
430 Z1= P(I9)
440 Z2= Z1
450 IF Z2< > .5THEN 480
460 Z2= RND (1)
470 GOTO 520
480 IF Z2> .5THEN 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)< Z2THEN 560
540 Z5= 1
550 REM 
560 REM   INTERACT WITH PLAYER; GET HIS RESPONSE (Z3).
570 REM   UPDATE RESPONSE HISTORY (X), AND APPROPRIATE PROB. (P(I9).
580 REM
590 Z3= 0
600 PLOT 23:PRINT S2+ 1;TAB( 5)"GUESS> ";:GOSUB 1000:PLOT 32
610 IF H$= "Y"THEN 650
620 IF H$= "N"THEN 660
630 PRINT "-- Y OR N, PLEASE.":PRINT
640 GOTO 600
650 Z3= 1
660 A$= "     "
670 S2= S2+ 1
680 IF Z3< > Z5THEN PRINT "INCORRECT":GOTO 710
690 PRINT "CORRECT"
700 S1= S1+ 1
710 REM   UPDATE X  --  THE LAST FOUR CHOICES
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 I9
770 P(I9)= F1* P(I9)+ (1- F1)* X(3)
780 IF S2< 50THEN 380
790 REM
800 PRINT
810 PRINT "            END OF GAME #"T+ 1".":PRINT
820 PRINT "YOU GOT"S1" OUT OF"S2"."
830 T= T+ 1
840 G(T)= S1
850 PRINT
860 PRINT "YOUR SCORES:"
870 PRINT "---------------"
880 FOR K= 1TO T
890 PRINT "GAME"K,"   "G(K)
900 NEXT K
910 PRINT "---------------"
920 PRINT
930 IF T< 10THEN 250
940 PRINT :PRINT :PRINT
950 PRINT "WOOF!  TEN GAMES IS MY LIMIT."
960 PRINT "HOPE THIS WILL TEACH YOU THAT COMPUTERS AREN'T SO DUMB."
970 PRINT
980 PRINT
999 END
1000 POKE 33278,0
1010 IF PEEK (33278)= 0THEN 1010
1020 H$= CHR$ (PEEK (33278))
1030 RETURN