0010 : NUMBER SQUARE GAME 0020 : VER 4.0 - 12 NOV 79 0030 : MARC I. LEAVEY, M.D. 0040 LINE=0 0050 DIGITS=0 0060 PRINT "N U M B E R S Q U A R E S" 0070 PRINT "---------------------------" 0080 PRINT 0090 PRINT "WELCOME TO THE WORLD OF" 0100 PRINT "CONFUSION. THERE ARE TWO" 0110 PRINT "VERSIONS OF NUMBER SQUARES:" 0120 PRINT " 1 - SEQUENTIAL" 0130 PRINT " 2 - MAGIC SQUARE" 0140 INPUT "WHICH IS YOUR PLEASURE",T 0150 IF T=1 GOTO 310 0160 IF T<>2 GOTO 140 0170 : 0180 : SET UP MAGIC 0190 : SQUARE BOARD 0200 : 0210 FOR I=1 TO 4 0220 FOR J=1 TO 4 0230 READ M(I,J) 0240 LET B(I,J)=M(I,J) 0250 NEXT J 0260 NEXT I 0270 DATA 1,6,15,8,12,11,2,5,10,13,4,3,7,16,9,14 0280 LET I1=4 0290 LET J1=2 0300 GOTO 440 0310 : 0320 : SET UP SEQUENTIAL 0330 : BOARD 0340 : 0350 DIM B(4,4) 0360 FOR I=1 TO 4 0370 FOR J=1 TO 4 0380 LET B(I,J)=(I-1)*4+J 0390 NEXT J 0400 NEXT I 0410 LET I1=4 0420 LET J1=4 0430 : 0440 : NOW SCRAMBLE THE BOARD 0450 : TWO HUNDRED TIMES 0460 : 0470 PRINT "I AM NOW SCRAMBLING THE BOARD..." 0480 FOR Q=1 TO 200 0490 LET M=INT(1+RND*4) 0500 ON M GOTO 510,560,610,660 0510 IF I1=1 GOTO 490 0520 LET B(I1,J1)=B(I1-1,J1) 0530 LET B(I1-1,J1)=16 0540 LET I1=I1-1 0550 GOTO 700 0560 IF I1=4 GOTO 490 0570 LET B(I1,J1)=B(I1+1,J1) 0580 LET B(I1+1,J1)=16 0590 LET I1=I1+1 0600 GOTO 700 0610 IF J1=1 GOTO 490 0620 LET B(I1,J1)=B(I1,J1-1) 0630 LET B(I1,J1-1)=16 0640 LET J1=J1-1 0650 GOTO 700 0660 IF J1=4 GOTO 490 0670 LET B(I1,J1)=B(I1,J1+1) 0680 LET B(I1,J1+1)=16 0690 LET J1=J1+1 0700 NEXT Q 0710 : 0720 : PRINT BOARD 0730 : 0740 LET M9=0 0750 : OUTPUT A "HOME UP" 0760 PRINT CHR$(16); 0770 PRINT "---------------------" 0780 FOR I=1 TO 4 0790 FOR J=1 TO 4 0800 PRINT ": "; 0810 IF B(I,J)=16 PRINT " ";:GOTO 840 0820 IF B(I,J)<10 PRINT " "; 0830 PRINT B(I,J); 0840 NEXT J 0850 PRINT ":" 0860 PRINT "---------------------" 0870 NEXT I 0880 : 0890 : ERASE REST OF SCREEN AND 0900 : BEEP FOR INPUT 0910 : 0920 : PRINT CHR$(22);CHR$(7);CHR$(7); 0930 : 0940 : INPUT MOVE 0950 : 0960 INPUT "MOVE WHICH PIECE",M 0970 LET I1=0:J1=0 0980 FOR I=1 TO 4 0990 FOR J=1 TO 4 1000 IF B(I,J)=M THEN I1=I:J1=J 1010 NEXT J 1020 NEXT I 1030 IF I1=0 THEN PRINT "I CAN'T FIND THAT NUMBER":GOTO 940 1040 LET I2=0:J2=0 1050 FOR I=I1-1 TO I1+1 1060 IF I>4 GOTO 1090 1070 IF I<1 GOTO 1090 1080 IF B(I,J1)=16 THEN I2=I:J2=J1:GOTO 1170 1090 NEXT I 1100 FOR J=J1-1 TO J1+1 1110 IF J>4 GOTO 1140 1120 IF J<1 GOTO 1140 1130 IF B(I1,J)=16 THEN I2=I1:J2=J:GOTO 1170 1140 NEXT J 1150 LET M9=M9+1 1160 PRINT "NOT A VALID MOVE":GOTO 940 1170 LET B(I2,J2)=M 1180 LET B(I1,J1)=16 1190 ON T GOTO 1210,1320 1200 : 1210 : SEQUENTIAL SOLUTION 1220 : 1230 LET C=0 1240 FOR I=1 TO 4 1250 FOR J=1 TO 4 1260 IF B(I,J)M(I,J) GOTO 720 1390 NEXT J 1400 NEXT I 1410 : 1420 : A WIN IS DECLARED! 1430 : 1440 PRINT "THAT IS THE CORRECT SOLUTION!" 1450 INPUT "LIKE TO PLAY ANOTHER GAME",I$ 1460 IF LEFT$(I$,1)="Y" THEN RUN 1470 END