Listing of file='MASTER.BAS;01' on disk='vmedia/ncc_7-sector.ccvf'
10 REM ** MASTERMIND - COPYRIGHT (C) 1979 BY TREVOR TAYLOR ** 11 REM 12 REM ** WITH TIMER AND SCORING FEATURES ADDED 5/15/1980 ** 13 REM CODE LETTERS FOR COLORS SUBSTITUTED FOR "X" 5/17/80 15 REM BY W. BRYANT WOOSLEY, JR. 16 REM 20 REM 30 REM THIS PROGRAM IS A VARIATION ON THE POPULAR 40 REM MASTERMIND GAME. IT ALLOWS A NUMBER OF DIFFERENT 50 REM GAMES CAN BE PLAYED - SEE THE INSTRUCTIONS. 60 REM 70 REM NOTE: THE COLORS ARE ENTERED AS THE LETTERS 'P' THRU 80 REM 'W' WITHOUT HOLDING DOWN THE CONTROL KEY. 90 REM NO. OF COLORS IN SEQUENCE MEANS NO. OF PEGS. 100 DIM A(5),C(5),G(5),M(5),T(5) 105 DIM Q(120) 106 IF PEEK (33210)> 40THEN POKE 33210,0 110 X= PEEK (33209) 120 FOR I= 1TO X:J= RND (X):NEXT I 140 PLOT 30,16,29,18,12,14 150 PRINT :PRINT " "; 160 PRINT "MASTERMIND" 170 PRINT :INPUT "DO YOU WANT INSTRUCTIONS ? (Y/N) ";R$ 180 IF R$ = "Y" GOTO 940 190 LV= 1:DU= 0 195 PLOT 12 196 REM 197 REM ** THE USER MAY CHOOSE THE NUMBER OF PEGS HE WANTS 198 REM TO GUESS THE COLORS OF. ALL 8 COLORS ARE USED IN 199 REM THE RANDOM SELECTION. ** 200 INPUT "HOW MANY COLORS IN THE SEQUENCE (2-5) ? ";HM 202 IF HM> 5GOTO 200 204 IF HM< 2GOTO 200 205 REM 206 REM ** DUPLICATE COLORS MAKE IT MUCH HARDER TO SOLVE. 207 REM SELECTING THIS OPTION DOES NOT GUARANTEE THAT 208 REM THERE WILL BE DUPLICATES, BUT THERE OFTEN ARE. ** 209 REM 210 INPUT "WILL YOU ALLOW DUPLICATE COLORS (Y/N) ? ";R$ 211 IF R$= "Y"THEN DU= 1 212 REM ** COLORS IN THE RIGHT POSITION CAN BE MARKED WITH 'X' ** 213 PRINT "DO YOU WANT COLORS IN THE CORRECT POSITION" 214 PRINT "TO BE MARKED WITH ITS CODE LETTER (Y/N) "; 215 INPUT "? ";R$ 216 IF R$= "Y"THEN LV= 0 220 PLOT 12 225 G9= G9+ 1 226 IF INT (G9/ 2)< > G9/ 2THEN A3$= A1$ 227 IF INT (G9/ 2)= G9/ 2THEN A3$= A2$ 230 PRINT :PRINT " "; 240 PRINT "MASTERMIND" 241 IF AS$< > "Y"THEN 250 244 PLOT 15,29,17 245 PRINT A3$;"'S TURN" 247 PRINT :PRINT A1$;"'S SCORE: ";S1 248 PRINT A2$;"'S SCORE: ";S2 249 PRINT :PLOT 14,29,18 250 PLOT 3,28,0 260 PRINT " GUESSES NO. RIGHT" 270 PLOT 3,26,4 280 PRINT " 1 2 3 4 5 1 2 3 4 5" 281 BS= PEEK (33209) 282 BM= PEEK (33210) 290 PLOT 30,16,29,18 294 REM 295 REM ** SELECT THE COLORS RANDOMLY ** 296 REM 300 FOR I= 0TO HM- 1 310 C(I)= INT (RND (X)* 9) 320 IF C(I)= 0GOTO 310 324 REM 325 REM ** THROW AWAY DUPLICATES IF NOT ALLOWED ** 326 REM 330 IF DU< > 0GOTO 380 340 IF I= 0GOTO 380 350 FOR J= 0TO I- 1 360 IF C(J)= C(I)+ 15GOTO 310 370 NEXT J 380 C(I)= C(I)+ 15 390 NEXT I 394 REM 396 REM 400 N= 1 404 REM 405 REM ********* MAIN LOOP ******** 406 REM 410 PLOT 29,18,3,0,10 420 PRINT "GUESSES LEFT = ";11- N 430 PLOT 31:PRINT "GUESS: "; 440 PLOT 15,14,29,23:INPUT "";G$ 450 PLOT 28,28:PRINT SPC( 17);" ":PRINT SPC( 17);" " 454 REM 455 REM ** IF NO GUESS, USER GIVES UP ** 456 REM 460 IF G$= "0"GOTO 1280 464 REM 465 REM ** EXTRACT THE COLORS AND CHECK FOR VALIDITY ** 466 REM 470 IF LEN (G$) < > HM GOTO 850 480 FOR I= 0TO HM- 1 490 T(I)= ASC (MID$ (G$,I+ 1,1))- 64 500 IF T(I) < 16 GOTO 880 510 IF T(I) > 23 GOTO 880 520 NEXT I 530 REM 540 REM ** CHECK FOR THE NUMBER CORRECT. THIS IS QUITE A 550 REM TRICKY ALGORITHM, BECAUSE IT HAS TO AVOID COUNTING 560 REM ANY OF THE COLORS TWICE. ** 570 REM 580 REM 590 REM 600 BL= 0:WH= 0 610 FOR I= 0TO HM- 1:M(I)= 0:NEXT I 620 FOR I= 0TO HM- 1 630 IF T(I)< > C(I)GOTO 635 631 M(I)= 1 632 BL= BL+ 1 635 NEXT I 637 FOR I= 0TO HM- 1 638 IF M(I)> 0GOTO 680 640 FOR J= 0TO HM- 1 650 IF M(J)< > 0GOTO 670 660 IF T(I)< > C(J)GOTO 670 662 WH= WH+ 1 663 M(J)= - 1 665 GOTO 680 670 NEXT J 680 NEXT I 685 PRINT "RIGHT:";BL 690 REM 700 REM ** SHOW THE USER HOW MANY HE GOT RIGHT ** 709 PLOT 29,17,3,23,2* N+ 4:PRINT N; 710 REM 711 PLOT 29,23,3,25,2* N+ 4 712 PRINT "["; 713 FOR I= 0TO HM- 1 714 PLOT 30,T(I),32,32,32 715 IF LV< > 0GOTO 717 716 IF M(I)> 0THEN PLOT 26,26,29,39- T(I),64+ T(I),32 717 NEXT I 718 PLOT 29,23,30,16 719 PRINT "]" 720 PLOT 3,45,2* N+ 4 730 PRINT "["; 740 PLOT 30,16 750 IF BL< = 0GOTO 770 760 FOR I= 1TO BL:PLOT 32,32,32:NEXT I 770 IF WH< = 0GOTO 800 780 PLOT 30,23 790 FOR I= 1TO WH:PLOT 32,32,32:NEXT I 800 PLOT 30,16:PRINT "]" 810 IF BL= HMGOTO 1190 820 N= N+ 1 830 IF N< 11GOTO 410 840 GOTO 1280 844 REM 845 REM ** ERROR MESSAGES ** 846 REM 850 PRINT :PRINT "CHEATING!!!" 870 GOTO 900 880 PRINT :PRINT "INVALID COLOR" 900 PLOT 29,18 910 FOR I= 1 TO 500:NEXT I 920 PLOT 28:PRINT SPC( 15) 930 GOTO 410 934 REM 935 REM ** INSTRUCTIONS - READ THESE WELL ** 936 REM 940 PLOT 12 950 PRINT "THE OBJECT OF THE GAME IS TO GUESS THE SEQUENCE OF" 960 PRINT "COLORS CHOSEN AT RANDOM BY THE COMPUTER. YOU CAN TRY" 961 PRINT "TO GUESS THE COLORS OF A SET OF 2,3,4 OR 5 PEGS, AND" 962 PRINT "YOU HAVE THE OPTION OF ALLOWING REPEATED COLORS" 963 PRINT "(WHICH IS MUCH HARDER!)." 966 PRINT "THE COLORS ARE PICKED FROM THE 8 AVAILABLE ON THE KEYBOARD." 980 PRINT " P = BLACK" 990 PRINT " Q = RED" 1000 PRINT " R = GREEN" 1010 PRINT " S = YELLOW" 1020 PRINT " T = BLUE" 1030 PRINT " U = MAGENTA" 1040 PRINT " V = CYAN" 1050 PRINT " W = WHITE" 1055 PRINT "(THESE KEYS ARE COLORED, SO YOU DON'T HAVE TO REMEMBER THEM.)" 1060 INPUT "TYPE <RETURN> TO CONTINUE";R$ 1070 PLOT 12 1080 PRINT "YOU HAVE 10 GUESSES WHICH YOU MAKE BY SIMPLY" 1082 PRINT "USING THE COLORED KEYS 'P' THRU 'V', FOLLOWED" 1084 PRINT "BY <RETURN>. THE COMPUTER WILL THEN DISPLAY" 1086 PRINT "THE COLORED CODE PEGS YOU HAVE CHOSEN." 1100 PRINT "IT WILL ALSO TELL YOU HOW MANY ARE RIGHT AND HOW" 1110 PRINT "MANY ARE IN THE CORRECT POSITIONS." 1120 PRINT "A KEY WILL BE DISPLAYED SHOWING A NUMBER OF" 1130 PRINT "BLACK AND WHITE PEGS, WITH:" 1140 PRINT " BLACK = CORRECT COLOR AND POSITION" 1150 PRINT " WHITE = CORRECT COLOR ONLY" 1160 PRINT "(THE BLACK PEGS ARE NOT PLACED IN THE POSITIONS" 1162 PRINT "THEY CORRESPOND TO HOWEVER.)" 1164 PRINT "THESE KEY AND CODE PEGS REMAIN ON THE SCREEN ONCE PLAYED" 1168 PRINT "IF YOU WANT TO GIVE UP, JUST TYPE <RETURN> AS YOUR GUESS." 1170 INPUT "TYPE <RETURN> TO CONTINUE";R$ 1180 GOTO 2999 1184 REM 1185 REM ** END OF GAME MESSAGES ** 1186 REM 1190 PLOT 3,0,16:PRINT "YOU WIN":PLOT 14 1200 ON NGOTO 1210,1210,1210,1230,1230,1230,1250,1250,1250,1270 1210 PRINT "LUCKY BREAK!!!" 1220 GOTO 1280 1230 PRINT "WELL PLAYED" 1240 GOTO 1280 1250 PRINT "AVERAGE" 1260 GOTO 1280 1270 PRINT "JUST MADE IT!" 1274 REM 1275 REM ** COME HERE IF USER GIVES UP OR LOSES ** 1276 REM 1280 PLOT 3,0,20 1285 PLOT 29,23,30,16 1290 PRINT "THE ANSWER IS:":PRINT "["; 1300 FOR I= 0TO HM- 1 1310 PLOT 30,C(I),32,32,32 1320 NEXT I 1330 PLOT 30,16 1340 PRINT "]" 1350 IF G$= "0"THEN 2000 1400 ES= PEEK (33209) 1405 EM= PEEK (33210) 1410 SC= ES- BS 1415 MN= EM- BM 1420 IF SC< 0THEN SC= SC+ 60:MN= MN- 1 1421 IF MN< 0THEN MN= MN+ 60 1422 M$= RIGHT$ (STR$ (MN+ 100),2) 1423 S$= RIGHT$ (STR$ (SC+ 100),2) 1424 PLOT 3,0,26,29,17,30,23 1425 PRINT "YOUR TIME WAS ";M$;":";S$ 1430 FOR X= 4TO 10 1432 READ T2(X) 1434 NEXT X 1436 DATA 800,600,500,400,300,200,100 1440 FOR X= 30TO 120STEP 5 1442 READ Q(X) 1444 NEXT X 1446 DATA 2.5,2,1.8,1.6,1.4,1.2,1,.9,.8,.7,.6,.5,.45,.42,.36,.33,.25,.18,.1 1455 RESTORE 1460 IF N< 4THEN N= 4 1465 Q= MN* 60+ SC 1470 IF Q< 30THEN Q= 30 1475 IF Q/ 5= INT (Q/ 5)THEN 1477 1476 Q= (INT (Q/ 5)+ 1)* 5 1477 IF Q> 120THEN Q= 120 1480 S9= T2(N)* Q(Q) 1485 PLOT 3,0,10 1486 PLOT 29,17,30,20 1488 S9$= RIGHT$ (STR$ (S9),4) 1489 S8= LEN (S9$) 1490 PRINT SPC( S8+ 13);"" 1492 PRINT " SCORE:";S9$;"!!!!! " 1495 PRINT SPC( S8+ 13);"" 1500 PLOT 3,0,26 1505 PLOT 29,19,30,16 1600 PLOT 29,18,30,16 1700 IF INT (G9/ 2)= G9/ 2THEN S2= S2+ S9 1710 IF INT (G9/ 2)< > G9/ 2THEN S1= S1+ S9 2000 PRINT :INPUT "PLAY AGAIN (Y/N) ? ";R$ 2002 IF R$= "N"THEN 4000 2003 IF AS$= "Y"THEN 220 2004 INPUT "SAME PARAMETERS AS LAST GAME (Y/N) ? ";A$ 2006 IF A$< > "N"THEN 220 2008 GOTO 190 2010 IF R$= "Y"GOTO 190 2020 LOAD "MENU":RUN 2999 PLOT 12 3000 PRINT "THE MACHINE WILL KEEP SCORE FOR YOU IF THERE ARE 3011 PRINT "TWO PLAYERS. YOU HAVE THE OPTION OF THREE GAMES: 3012 PRINT " (A) 5 COLORS, DUPLICATES ALLOWED, CORRECT GUESSES 3013 PRINT " MARKED WITH THE CODE LETTER. 3014 PRINT " (B) 3 COLORS, DUPLICATES ALLOWED, NO MARKINGS. 3015 PRINT " (C) TWO COLORS, DUPLICATES ALLOWED, NO MARKINGS. 3016 PRINT :PRINT "DO YOU WANT TO PLAY ONE OF THESE GAMES, AND 3017 PRINT "HAVE THE MACHINE KEEP SCORE FOR YOU"; 3020 INPUT AS$ 3030 IF AS$< > "Y"THEN 190 3031 INPUT "WHICH GAME? ";AG$ 3032 IF AG$= "A"THEN GOSUB 5000 3033 IF AG$= "B"THEN GOSUB 5010 3034 IF AG$= "C"THEN GOSUB 5020 3035 PRINT :PRINT 3036 DU= 1 3040 INPUT "PLEASE ENTER FIRST PLAYER'S NAME ";A1$ 3050 INPUT "PLEASE ENTER SECOND PLAYER'S NAME ";A2$ 3060 PLOT 12 3070 GOTO 220 4000 IF AS$< > "Y"THEN 2020 4001 INPUT "DO YOU WANT A FINAL SCORE (Y/N)? ";R$ 4002 N2= LEN (A2$) 4003 N1= LEN (A1$) 4005 PLOT 12 4010 IF R$< > "Y"THEN 2020 4031 S1$= RIGHT$ (STR$ (S1),5) 4032 S2$= RIGHT$ (STR$ (S2),5) 4034 PLOT 30,20 4035 FOR X= 1TO 31 4036 PRINT SPC( 32) 4037 NEXT X 4040 PLOT 3,15,10,6,29 4050 PRINT SPC( 10- N1);A1$;"'S SCORE: ";S1$;SPC( 4);"" 4055 PLOT 3,15,12 4060 PRINT SPC( 10- N2);A2$;"'S SCORE: ";S2$;SPC( 4);"" 4070 FOR X= 1TO 3000:NEXT 4080 GOTO 2020 5000 HM= 5:LV= 0 5005 RETURN 5010 HM= 3:LV= 1 5015 RETURN 5020 HM= 2:LV= 1 5025 RETURN