5 PRINT TAB(24);"AWARI"
7 PRINT TAB(5);"CREATIVE COMPUTING, MORRISTOWN N.J."
10 DATA 0
15 DIM B(13),G(13),F(50):READ N
16 INPUT "WOULD YOU LIKE THE RULES (YES=1)";Z
17 IF Z=1 GOTO 900
18 Z=0
20 PRINT:PRINT:E=0
25 FOR I=0 TO 12:B(I)=3:NEXT I
30 C=0:F(N)=0:B(13)=0:B(6)=0
35 GOSUB 500
40 PRINT "YOUR MOVE";:GOSUB 110
45 IF E=0 THEN 80
50 IF M=H THEN GOSUB 100
55 IF E=0 THEN 80
60 PRINT "MY MOVE IS ";:GOSUB 800
65 IF E=0 THEN 80
70 IF M=H THEN PRINT ",";:GOSUB 800
75 IF E>0 THEN 35
80 PRINT:PRINT"GAME OVER"
85 D=B(6)-B(13):IF D<0 THEN PRINT "I WIN BY";-D;"POINTS":GOTO 920
90 N=N+1:IF D=0 THEN PRINT "DRAWN GAME":GOTO 920
95 PRINT "YOU WIN BY";D;"POINTS":GOTO 920
100 PRINT "AGAIN;
110 INPUT M:IF M<7 THEN IF M>0 THEN M=M-1:GOTO 130
120 PRINT "ILLEGAL MOVE":GOTO 100
130 IF B(M)=0 THEN 120
140 H=6:GOSUB 200
150 GOTO 500
200 K=M:GOSUB 600
205 E=0:IF K>6 THEN K=K-7
210 C=C+1:IF C<9 THEN F(N)=F(N)*6+K
215 FOR I=0 TO 5:IF B(I)<>0 THEN 230
220 NEXT I
225 RETURN
230 FOR I=7 TO 12:IF B(I)<>0 THEN E=1
231 NEXT I
232 RETURN
235 GOTO 220
500 PRINT:PRINT"    ";
505 FOR I=12 TO 7 STEP -1:GOSUB 580
510 NEXT I
515 PRINT:I=13:GOSUB 580
520 PRINT "                         ";:PRINT B(6):PRINT "    "; 
525 FOR I=0 TO 5:GOSUB 580
530 NEXT I
535 PRINT:PRINT:RETURN
580 IF B(I)<10 THEN PRINT " ";
585 PRINT B(I);:RETURN
600 P=B(M):B(M)=0
605 FOR P=P TO 1 STEP -1:M=M+1:IF M>13 THEN M=M-14
610 B(M)=B(M)+1:NEXT P
615 IF B(M)=1 THEN IF M<>6 THEN IF M<>13 THEN IF B(12-M)<>0 THEN 625
620 RETURN
625 B(H)=B(H)+B(12-M)+1:B(M)=0:B(12-M)=0:RETURN
800 D=-99:H=13
805 FOR I=0 TO 13:G(I)=B(I):NEXT I
810 FOR J=7 TO 12:IF B(J)=0 THEN 885
815 G=0:M=J:GOSUB 600
820 FOR I=0 TO 5:IF B(I)=0 THEN 845
825 L=B(I)+I:R=0
830 IF L>13 THEN L=L-14:R=1:GOTO 830
835 IF B(L)=0 THEN IF L<>6 THEN IF L<>13 THEN R=B(12-L)+R
840 IF R>Q THEN Q=R
845 NEXT I
850 Q=B(13)-B(6)-Q:IF C>8 THEN 875
855 K=J:IF K>6 THEN K=K-7
860 FOR I=0 TO N-1:IF F(N)*6+K=INT(F(I)/6^(7-C)+.1) THEN Q=Q-2
870 NEXT I
875 FOR I=0 TO 13:B(I)=G(I):NEXT I
880 IF Q>=D THEN A=J:D=Q
885 NEXT J
890 M=A:PRINT CHR$(42+M);:GOTO 200
895 FOR I=0 TO N-1:PRINTB(I):NEXT I
896 GOTO 999
900 PRINT "Awari is an ancient African game played with a"
901 PRINT "board divided into 6 pits on each side.  There"
902 PRINT "are 2 special home pits at the ends.  3 stones"
903 PRINT "are in each of the 12 pits. A move is made by"
904 PRINT "taking all stones from any (non-empty) pit on"
905 PRINT "your side.  Starting from the pit to the right"
906 PRINT "of this one, stones are 'sown' 1 in each pit"
907 PRINT "(counterclockwise).  A turn consists of 1 or 2"
908 PRINT "moves. If your last stone is sown in your own"
909 PRINT "home, take a second move.":PRINT "     "
910 PRINT "If the last stone sown lands in an empty pit,"
911 PRINT "provided that the opposite pit isn't empty, all"
912 PRINT "stones in the opposite pit and the last stone"
913 PRINT "sown are captured and moved to the players home"
914 PRINT "(right end).":PRINT "   "
915 PRINT "When either side is empty, the game ends.  The"
916 PRINT "player with the most stones wins.":PRINT "  "
917 PRINT "To make a move type in the number of your pit (1-6)."
918 INPUT "(ENTER ANY NUMBER TO CONTINUE)";Z
919 GOTO 18
920 INPUT "ANOTHER GAME (NO = 1)";Z
921 IF Z=1 THEN 999
922 Z=0:GOTO 16
999 END
R ANY NUMBER TO CONTINUE)";Z
919 GOTO 18
920 INPUT "ANOTHER GAME (NO = 1)";Z
