Awari

Author(s): Jon Passler
Publication: Syntax
Pub Details: Syntax/Syntax ZX80 v3 n2 (Volume 3, Issue 2)
Date: February 1982
Pages: 17-18

Awari is an ancient African game for two players. Six piles of three stones each are arranged in front of opposing players, with each player’s “home” to the right of the piles. The play consists of taking all the stones in one of the player’s piles and, moving counter-clockwise, dropping one stone in each pile or home until all are dropped. If a player’s last stone falls in his home, then he gets a second move. If the last stone falls in an empty pile and the opposite pile is not empty, then the player can move the last stone plus all stones in the opposite pile to his home. The game ends when either player runs out of moves. The player with the most stones in his home wins.

Sample strategy:

     5    0    1    3    0    4
5                                  5
     3    3    4    0    2    1

The computer would most likely move its number 6 pile (top left with 5 counters), since it would end up with 1+1+3 or 5 more counters in its home. Moving its pile 1 or 4 would only result in 4 more points. Were it your turn, a good defensive move would be your pile 2 with 3 counters. But moving pile 3, 5 or 6 first would be even better since you would get 1 more point plus a second move to take pile 2 out of harm’s way.

This Awari game is a simplified version of one in Basic Computer Games by Creative Computing. Although it only knows offensive moves, it plays a reasonably good game. If you’re like me, you’ll lose often enough to keep it interesting. The first player to move is chosen randomly, and then the first move alternates if you press NL or ENTER at the end of each game. Input STOP for your move to quit, then continue with GOTO 940 or RUN. Input any character at the end of a game to see the listing.

Note that the <> (not equal to) sign is shift T; don’t type less than and greater than signs. To enter lines 690 and 710, type the line number, PRINT command and ” mark, then press shift 9 to change to graphics. Press shift 7 25 times for line 690, shift 5 once for line 710. Press shift 9 again to return to normal input mode, then type the ending ” mark.

  10 REM AWARI
20 RAND
30 LET K1=INT (RND*2)+1
40 DIM A(14)
50 DIM S(14)
60 FOR I=1 TO 13
70 LET A(I)=3
80 NEXT I
90 LET A(7)=0
100 LET K=K1
110 LET Z=3
120 LET J=15
130 GOSUB 680
140 GOTO K*40+110
150 PRINT "YOUR MOVE";
160 GOTO 230
170 PRINT "AGAIN";
180 GOTO 230
190 PRINT "MY TURN-N/L";
195 INPUT I$
200 GOTO 270
210 PRINT "AGAIN-N/L";
215 INPUT I$
220 GOTO 270
230 INPUT M
240 IF A(M)=0 THEN GOTO 230
250 PRINT ": ";M
260 GOTO 500
270 IF Z>3 THEN GOTO 300
280 LET M=INT (RND*2)+12
290 GOTO 490
300 FOR I=1 TO 14
310 LET S(I)=A(I)
320 NEXT I
330 LET H1=A(14)-A(7)
340 FOR J=8 TO 13
350 IF A(J)=0 THEN GOTO 470
360 LET M=J
370 GOSUB 500
380 LET H2=A(14)-A(7)
390 IF M=14 AND K=2 THEN LET H2=H2+2
400 IF ABS (H1-H2)<2 THEN LET H2=H2+2
410 IF H1>H2 THEN GOTO 440
420 LET H1=H2
430 LET W=J
440 FOR I=1 TO 14
450 LET A(I)=S(I)
460 NEXT I
470 NEXT J
480 LET M=W
490 PRINT ": ";M-7
500 LET I=A(M)
510 LET A(M)=0
520 FOR I=I TO 1 STEP -1
530 LET M=M+1
540 IF M>14 THEN LET M=M-14
550 LET A(M)=A(M)+1
560 NEXT I
570 IF A(M)=1 AND M<>7 AND M<>14 THEN IF A(14-M)<>0 THEN GOTO 590
580 GOTO 620
590 LET A(INT K*7)=A(INT K*7)+A(14-M)+1
600 LET A(14-M)=0
610 LET A(M)=0
620 IF J<14 THEN RETURN
630 IF Z=3 THEN GOTO 670
640 FOR I=1 TO 11
650 SCROLL
660 NEXT I
670 LET Z=14
680 PRINT AT 0,12;"AWARI"
690 PRINT AT Z-2,1;"▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀" (25 shift 7)
700 FOR I=Z-2 TO Z+7
710 PRINT AT I,26;"▌" (shift 5)
720 NEXT I
730 PRINT AT Z,5;A(13);" ";A(12);" ";A(11);" ";A(10);" ";A(9);" ";A(8)
740 PRINT AT Z+2,1;"";
750 IF A(14)<10 THEN PRINT " ";
760 PRINT A(14);TAB 23;A(7)
770 PRINT AT Z+4,5;A(1);" ";A(2);" ";A(3);" ";A(4);" ";A(5);" ";A(6)
780 PRINT AT Z+7,1;"";
790 IF Z=3 THEN RETURN
800 FOR I=1 TO 6
810 IF A(I)<>0 THEN GOTO 840
820 NEXT I
830 GOTO 870
840 FOR I=8 TO 13
850 IF A(I)<>0 THEN GOTO 980
860 NEXT I
870 LET D=A(14)-A(7)
880 IF D=0 THEN PRINT "DRAW"
890 IF D<0 THEN PRINT "YOU WIN BY ";-D
900 IF D>0 THEN PRINT "I WIN BY ";D
910 INPUT I$
920 CLS
930 IF I$<>"" THEN LIST 10
940 IF K1=1 THEN LET W=2
950 IF K1=2 THEN LET W=1
960 LET K1=W
970 GOTO 40
980 IF (M=7 AND K=1) OR (M=14 AND K=2) THEN GOTO 1030
990 LET W=K
1000 IF W<2 THEN LET K=2
1010 IF W>1.5 THEN LET K=1
1020 GOTO 140
1030 LET K=K+.5
1040 GOTO 140
Syntactic Sum: 5918, 8K

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.