10 PRINT "GAME OF 'ROTATE' BY DAVE AHL.  ENJOY !!"\ PRINT 
12 PRINT "INSTRUCTIONS (Y OR N)";\ INPUT A$\ PRINT \IF A$="N" THEN 140
15 PRINT "IN THIS GAME THE BOARD IS LAID OUT AS FOLLOWS:"
20 DIM B(16),B$(16)\RANDOMIZE 
25 FOR I=1 TO 16\ B(I)=I \ NEXT I
30  PRINT \FOR I=1 TO 13 STEP 4
35 PRINT USING "##  ##  ##  ##",B(I),B(I+1),B(I+2),B(I+3)
40 NEXT I\ PRINT 
45  PRINT "BOARD POSITIONS ARE OCCUPIED RANDOMLY BY THE LETTERS A TO P."
50  PRINT "THE OBJECT OF THE GAME IS TO ORDER THE LETTERS BY ROTATING"
55  PRINT "ANY FOUR LETTERS CLOCKWISE ONE POSITION.  YOU SPECIFY THE"
60  PRINT "UPPER LEFT POSITION OF THE FOUR YOU WISH TO ROTATE, I.E.,"
65  PRINT "VALID MOVES ARE 1, 2, 3, 5, 6, 7, 9, 10, AND 11."
70  PRINT "CONSEQUENTLY, IF THE BOARD LOOKED LIKE:"
75  FOR I=1 TO 16\B$(I)=CHR$(I+64)\NEXT I\B$(2)="C"\B$(3)="G"
80 B$(6)="B"\B$(7)="F"\GOSUB 400
85  PRINT "AND YOU ROTATED POSITION 2, THE BOARD WOULD BE:"
90  FOR I=2 TO 7\B$(I)=CHR$(I+64)\NEXT I\GOSUB 400
95  PRINT "AND YOU WOULD WIN !"\ PRINT 
100  PRINT "YOU ALSO GET ONE 'SPECIAL' MOVE PER GAME WHICH YOU MAY OR"
105  PRINT "MAY NOT NEED.  THE SPECIAL MOVE ALLOWS YOU TO EXCHANGE"
110  PRINT "ANY TWO ADJACENT LETTERS IN A ROW.  TO MAKE THIS MOVE,"
115  PRINT "INPUT A '-1' AS YOUR MOVE AND YOU WILL BE ASKED FOR THE"
120  PRINT "POSITIONS OF THE TWO LETTERS TO EXCHANGE.  REMEMBER -- "
125  PRINT "ONLY ONE SPECIAL MOVE PER GAME!"\ PRINT 
130  PRINT "TO GIVE UP AT ANY TIME, TYPE A '0'."\ PRINT \ PRINT "GOOD LUCK !"\ PRINT 
140 FOR I=1 TO 16\B$(I)="0"\NEXT I
150 FOR I=1 TO 16
160 T$=CHR$(INT(16*RND+65))
165 FOR J=1 TO I
170 IF B$(J)=T$ THEN 160
175 NEXT J
180 B$(I)=T$\NEXT I
190 M=0\S=0\ PRINT "HERE'S THE STARTING BOARD..."\GOSUB 400
200 PRINT "POSITION TO ROTATE";\ INPUT I\IF I=0 THEN  PRINT \ PRINT \GOTO 140
205 IF I=-1 THEN 510
210 IF I=4 THEN 215
211 IF I=8 THEN 215
212 IF I>12 THEN 215
213 GOTO 220
215 PRINT "ILLEGAL.  AGAIN..."\GOTO 200
220 M=M+1\T$=B$(I)
230 B$(I)=B$(I+4)\B$(I+4)=B$(I+5)\B$(I+5)=B$(I+1)\B$(I+1)=T$
240 GOSUB 400\REM  *** PRINT BOARD
300 REM   *** DO WE HAVE A WINNER?
305 FOR I=1 TO 16
310 IF CHR$(I+64)<>B$(I) THEN 200
315 NEXT I
320  PRINT \ PRINT "YOU ORDERED THE BOARD IN";M;"MOVES."\M1=M1+M\G=G+1
325  FOR I=1 TO 15\PRINT  CHR$(7);\NEXT I
330  PRINT \PRINT "PLAY AGAIN (Y OR N)";\ INPUT A$\IF A$="Y" THEN 140
340  PRINT \ PRINT "YOU PLAYED";G;"GAMES AND ORDERED THE BOARD IN AN AVERAGE"
350  PRINT "OF";M1/G;"MOVES PER GAME."\ PRINT \GOTO 999
390 REM   *** PRINT BOARD SUBROUTINE
400  PRINT \FOR I=1 TO 13 STEP 4
410  PRINT  B$(I);" ";B$(I+1);" ";B$(I+2);" ";B$(I+3)
420 NEXT I\ PRINT \RETURN 
500 REM   *** SPECIAL MOVE SUBROUTINE
510 PRINT "EXCHANGE WHICH TWO POSITIONS";\ INPUT X,Y
520 IF X<>Y+1 THEN IF X<>Y-1 THEN  PRINT "ILLEGAL.  AGAIN..."\GOTO 510
530 S=S+1\IF S>1 THEN  PRINT "ONLY ONE SPECIAL MOVE PER GAME."\GOTO 200
540 T$=B$(X)\B$(X)=B$(Y)\B$(Y)=T$\GOTO 240
999 END 
