5 PRINT TAB(28);"MAGIC SQUARE" 10 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN NEW JERSEY" 12 DIM A(9),B(9) 15 PRINT 16 PRINT 17 PRINT 20 PRINT "GAME OF MAGIC SQUARE" 21 PRINT 25 PRINT "PLAYERS ALTERNATLEY CHOOSE AN INTEGER (1 TO 9)" 30 PRINT "THAT HAS NOT BEEN PREVIOUSLY USED AND PLACE IT" 35 PRINT "IN ANY UNFILLED CELL OF A TIC-TAC-TOE BOARD." 40 PRINT "THE GOAL IS TO MAKE THE SUM OF EACH ROW, COLUMN," 45 PRINT "AND DIAGONAL EQUAL TO 15." 47 PRINT 50 PRINT "THAT PLAYER LOSES WHO FIRST MAKES THE SUM OF THE" 55 PRINT "THREE FIGURES IN ANY ROW, COLUMN, OR DIAGONAL" 60 PRINT "SOMETHING OTHER THAN 15." 62 PRINT 65 PRINT "A TIE GAME DRAWS A MAGIC SQUARE!!" 67 PRINT 70 PRINT "THE COMPUTER WILL ASK YOU ON EACH MOVE WHICH" 75 PRINT "CELL YOU WISH TO OCCUPY, AND THE NUMBER YOU WISH" 80 PRINT "LIKE '3,7' IF YOU WISHED TO PUT A 7 IN CELL 3." 85 PRINT 90 PRINT "HERE ARE THE CELL NUMBERS:" 92 PRINT 93 PRINT "1 2 3" 94 PRINT "4 5 6" 95 PRINT "7 8 9" 96 FOR I = 1 TO 9 97 A(I)=0 98 B(I)=0 99 NEXT I 100 M=0:W=0 103 PRINT 104 PRINT "INPUT YOUR MOVE -- CELL AND NUMBER"; 105 INPUT I,N 110 IF I<1 OR I > 9 OR N < 1 OR N > 9 THEN 130 120 IF A(I)=0 AND B(N)=0 THEN 150 130 PRINT "ILLEGAL MOVE ... AGAIN" 135 GOTO 103 150 A(I)=N:B(N)=1:M=M+1 170 GOSUB 960 180 GOSUB 800 200 IF W=0 THEN 230 210 PRINT "SORRY, YOU LOSE -- NICE TRY." 211 GOTO 560 230 IF M < 5 THEN 400 240 PRINT "A TIE GAME -- BUT WE'VE DRAWN A MAGIC SQUARE!" 250 GOTO 560 400 FOR Q=1 TO 9 410 IF A(Q)> 0 THEN 480 420 FOR R=1 TO 9 430 IF B(R)>0 THEN 470 435 A(Q)=R 440 GOSUB 800 450 IF W=0 THEN 500 460 Q1=Q:R1=R:W=0:A(Q)=0 470 NEXT R 480 NEXT Q 490 W=1:R=R1:Q=Q1:A(Q)=R 500 B(R)=1 520 PRINT "I MOVE TO CELL ";Q;" WITH A ";R 530 GOSUB 960 540 IF W=0 THEN 103 550 PRINT "I LOSE -- YOU WIN!!" 560 PRINT 561 FOR I=1 TO 15 562 PRINT CHR\$(7); 564 NEXT I 570 PRINT "LET'S PLAY AGAIN. . ." 575 GOTO 96 800 FOR X=1 TO 8 810 ON X GOTO 820,830,840,850,860,870,880,890 820 J=1:K=2:L=3:GOTO 900 830 K=4:L=7:GOTO 900 840 K=5:L=9:GOTO 900 850 J=4:L=6:GOTO 900 860 J=2:L=8:GOTO 900 870 J=3:L=7:GOTO 900 880 J=7:L=9:GOTO 900 890 J=7:K=8 900 IF A(J)=0 OR A(K)=0 OR A(L)=0 THEN 930 920 IF A(J)+A(K)+A(L) <> 15 THEN 940 930 NEXT X 935 GOTO 950 940 W=1 950 RETURN 960 PRINT 965 PRINT A(1),A(2),A(3) 970 PRINT A(4),A(5),A(6) 975 PRINT A(7),A(8),A(9) 980 PRINT 990 RETURN 999 END