10 REM "XCHANGE"
20 REM
30 RANDOMIZE TIMER
40 M1$="INVALID CHARACTER"
50 M2$="ILLEGAL MOVE"
60 M3$="YOU'RE THE WINNER"
70 A$= "*"
80 DIM X$(9), Y$(9)
90 PRINT "WANT INSTRUCTIONS (Y OR N)";
100 INPUT Q$
110 IF Q$="N" THEN 160
120 IF Q$="Y" THEN 150
130 PRINT "WHAT IS THAT ?"
140 GOTO 90
150 GOSUB 1000
160 PRINT "NUMBER OF PLAYER (1 OR 2)";
170 INPUT P
180 IF P=1 THEN 210
190 IF P=2 THEN 210
200 GOTO 160
210 GOSUB 2000
220 GOSUB 3000
225 IF Q$="X" THEN 280
230 IF P <> 2 THEN 250
240 GOSUB 4000
250 GOSUB 5000
260 GOSUB 6000
270 IF I <> 8 THEN 220
280 PRINT
290 PRINT "ANOTHER GAME(Y,N)";
300 INPUT Q$
310 IF Q$="Y" THEN 160
320 PRINT "SO LONG......." 
330 END      
414 I+3=J THEN 4180
1000  PRINT "ALL THE LETTERS A-H AND THE STAR ARE OUT OF ORDER"
1010 PRINT "YOU CAN XCHANGE THEM AROUND WITH THE STAR UNTIL"
1015 PRINT "THEY ARE IN ORDER A-H AND * AT THE END. BUT IT CAN"
1020 PRINT "BE ONLY ABOVE, BELOW,LEFT, OR RIGHT OF THE * TO BE ABLE TO XCHANGE."
1040 PRINT
1130 PRINT "READY";
1140 INPUT Q$
1150 PRINT "HERE WE GO"
1160 RETURN
1999 REM "SCRAMBLE"
2000 DATA A, B, C, D, E, F, G, H, *
2010 FOR I=1 TO 9
2020 READ X$(I)
2030 NEXT I
2040 RESTORE
2050 FOR I=1 TO 9
2060 R=INT(10*RND(1))
2070 IF R < 1 THEN 2060
2080 X$=X$(I)
2090 X$(I)=X$(R)
2100 X$(R)=X$
2110 NEXT I
2120 FOR I=1 TO 9
2130 Y$(I)=X$(I)
2140 NEXT I
2150 GOSUB 5000
2160 RETURN
2999 REM "PLAYER-X MOVES"
3000 PRINT "MOVE";
3010 INPUT Q$
3015 IF Q$="X" THEN 3200
3020 IF Q$ <> A$ THEN 3050
3030 PRINT M2$
3040 GOTO 3000
3050 FOR I=1 TO 9
3060 IF Q$=X$(I) THEN 3100 
3070 NEXT I
3080 PRINT M1$
3090 GOTO 3000
3100 FOR J=1 TO 9
3110 IF X$(J)=A$ THEN 3130
3120 NEXT J
3130 IF I+1=J THEN 3180
3140 IF I+3=J THEN 3180
3150 IF I-1=J THEN 3180
3160 IF I-3=J THEN 3180
3170 GOTO 3030
3180 X$(J)=X$(I)
3190 X$(I)=A$
3200 RETURN
3999 REM "PLAYER-Y MOVES"
4000 PRINT TAB(16) "MOVES";
4010 INPUT Q$
4020 IF Q$ <> A$ THEN 4050
4030 PRINT M2$
4040 GOTO 4000
4050 FOR I= 1 TO 9
4060 IF Q$=Y$(I) THEN 4100
4070 NEXT I
4080 PRINT TAB(16) M1$ 
4090 GOTO 4000
4100 FOR J=1 TO 9
4110 IF Y$(J)=A$ THEN 4130
4120 NEXT J
4130 IF I+1=J THEN 4180
4140 IF I+3=J THEN 4180
4150 IF I-1=J THEN 4180 
4160 IF I-3=J THEN 4180
4170 GOTO 4030
4180 Y$(J)=Y$(I)
4190 Y$(I)=A$
4200 RETURN
4999 REM "PRINT GRIDS"
5000 PRINT
5010 FOR I=1 TO 9 STEP 3
5020 FOR J=I TO I+2
5030 PRINT " "X$(J);
5040 NEXT J
5050 IF P=2 THEN 5100
5060 PRINT
5070 NEXT I
5080 PRINT
5090 RETURN
5100 FOR J= I TO I+2
5110 PRINT TAB(16)  " "Y$(J);
5120 NEXT J
5130 GOTO 5060
5999 REM "WINNER CHECK"
6000 FOR I=1 TO 8
6010 READ X$
6020 IF X$(I) <> X$ THEN 6070
6030 NEXT I
6040 PRINT M3$
6050 RESTORE
6060 RETURN
6070 IF P <> 2 THEN 6050
6080 FOR I=1 TO 8
6090 READ Y$
6100 IF Y$(I) <> Y$ THEN 6050
6110 NEXT I
6120 PRINT TAB(16) M3$
6130 GOTO 6050
