10 RANDOMIZE 20 CLS 25 print "(New version available. Type GO BIG instead of GO. New version allows you" 26 print "to select the number of colors, pegs, and turns.)" 30 PRINT "Welcome to Mastermind. I'll write the code, you guess it." 40 PRINT "Colors are K B R Y G W, for Black, Blue, Red, Yellow, Green, and White" 50 PRINT "Write your guesses like this:" 60 PRINT "Your guess? B, R, R, K" 70 RESTORE 80 FOR I=1 TO 6 90 READ C$(I) 100 NEXT I 110 C$(3)="R" 120 FOR I=1 TO 4 130 X(I)=INT(6*RND)+1 140 IF X(I)<7 THEN 160 150 X(I)=6 160 X1(I)=0 170 Y1(I)=0 180 NEXT I 190 REM Here's where each of the 10 turns begins. 200 FOR I=1 TO 10 210 B=0 220 W=0 230 FOR J=1 TO 4 240 X1(J)=0 250 Y1(J)=0 260 NEXT J 270 INPUT "Your guess"; A$(1), A$(2), A$(3), A$(4) 280 FOR J=1 TO 4 290 Y(J)=0 300 FOR K=1 TO 6 310 IF A$(J)=C$(K) THEN Y(J)=K 320 NEXT K 330 IF Y(J)>0 THEN 360 340 PRINT "Invalid entry" 350 GOTO 270 360 NEXT J 370 REM Now figure out the score: first the number of black pegs... 380 FOR J=1 TO 4 390 IF X(J)<>Y(J) THEN 430 400 B=B+1 410 X1(J)=1 420 Y1(J)=1 430 NEXT J 440 REM ... and now figure out the number of whites 450 FOR J=1 TO 4 460 IF X1(J)=1 THEN 560 470 FOR K=1 TO 4 480 IF Y1(K)=1 THEN 510 490 IF Y(K)<>X(J) THEN 510 500 GOTO 530 510 NEXT K 520 GOTO 560 530 W=W+1 540 Y1(K)=1 550 X1(J)=1 560 NEXT J 570 REM Now display the results and take another input 580 PRINT " ", " ", "That was worth ";B;" blacks and ";W;" whites" 590 IF B=4 THEN 680 600 NEXT I 610 REM That's the loop for each turn. Next line for losers: 620 PRINT "Sorry, your turns are used up. The pattern was" 630 FOR I=1 TO 4 640 PRINT C$(X(I)), 650 NEXT I 660 PRINT 670 GOTO 700 680 PRINT 690 PRINT "You got it! Congratulations! It only took you ";I;" guesses! Good job!" 700 INPUT "Want to play again? (Type y or n ) ", R$ 710 IF R$="Y" OR R$="y" THEN 20 720 SYSTEM 725 END 730 DATA "K", "B", "R", "Y", "G", "W"