3 ~~~~~~~~~~~~~~~~~ ____oo_
7 | 6 | 5 | 4 | 3 | 2 | 1 | MARMITA
8 |ooo|ooo|ooo|ooo|ooo|ooo|
9 My home | | | | | | | Your home
10 |ooo|ooo|ooo|ooo|ooo|ooo|
11 | 1 | 2 | 3 | 4 | 5 | 6 |
15 Awari is an African game played with seven sticks and
16 thirty-six stones or beans laid out as shown above. The
17 board is divided into six compartments or pits on each side.
18 In addition, there are two special HOME pits at the end.
20 A move is made by taking all the beans from any
21 (non-empty) pit on your own side. Starting from the pit to
22 the right of this one, these beans are "sown" one in each
23 pit working around the board anticlockwise.
25 A turn consists of one or two moves. If the last bean of
26 your move is sown in your own home you may take a second
29 If the last bean is sown in a move lands in an empty pit,
30 provided that the opposite pit is no empty, all the beans in
31 the opposite pit, together with the last bean sown are
32 "captured" and moved to the players home.
34 When either side is empty, the game is finished. The
35 player with the most beans in his home has won.
37 In the computer version, the board is printed as 14
38 numbers representing the 14 pits.
44 The pits on your (lower) side are numbered 1-6 from left
45 to right. The pits on my side (computer) are numbered from
48 To make a move you type in the number of the pit.
50 If the last bean lands in your home the computer types
51 "Again?" and then you type in the second move.
53 If you want to terminate the game just type "END" in your
56 The computer move is typed followed by a diagram of the
57 board in its new state. The computer allways offers you the
58 first move. This consider to be a slight advantage.
60 There is a learning mechanism in the program that causes
61 the play of the computer to improve as it plays more games.
63 This version of Awari is adopted from one originally
64 written by Geoff Wyvill of Bradford, Yorksire, England and
65 translated to IBM REXX by Bill N. Vlachoudis.
66 E-mail addr: V.Vlachoudis@cern.ch
67 bnv@nisyros.physics.auth.gr
70 if Args = '?
' then Call Help
73 Say Center('A W A R I
',79)
74 Say Center('~~~~~~~~~~~~~~~~~',79)
75 Say ; Say Center('by V
.Vlachoudis@cern
.ch
',79)
77 Say Center('For instructions about the game enter
"awari ?" in cmd line
.',79)
78 Say Center('or simply enter
"?" in your move
.',80)
81 awarif = open("awari.var","r")
82 If awarif ~= -1 then Do
84 interpret read(awarif)
88 /* // 'GLOBALV SELECT AWARI STACK N
'
92 'GLOBALV SELECT AWARI GET
F.'i
96 E = 0 ; B. = 3 ; C = 0 ; F.n = 0 ;
102 Do forever /* Main Loop */
104 Call Input "Your move?"
106 if M = H then Call Input "Again?"
124 Say ; Say "Game Over"
126 if D < 0 ;then Sa = "I win by "0-D" point"
134 Sa = "You win by "D" point"
136 if abs(D)=1 | D = 0 ;then Say Sa'.'
144 Do until Valid /* Test if input is Valid */
146 Parse UPPER External M .
152 When M = 'END
' then Do
153 Say "Thanks for the game."
154 Say "Have a nice day."
155 /* Save everything we done till now */
156 awarif = Open("awari.var","w")
157 If awarif ~= -1 then Do
158 Call write awarif,"N =" N
160 Call write awarif, vardump('F.')
163 /*// 'GLOBALV SELECT AWARI SETP N
'N
165 'GLOBALV SELECT AWARI SETP
F.'I F.I
167 /* O.k. now Exit from the program */
170 When ~Datatype(M,'NUM
') then Say "Not valid move '"M"'"
172 M = Trunc(M) ; M = M - 1
173 if M<0 | M>5 | B.M=0 ;then Say "Illegal move '"M+1"'"
179 H = 6 /* O.k. it is valid */
180 Call MakeMove /* Make the move he asked */
181 Call Print /* Print the board */
188 if k > 6 then k = k - 7
190 if C < 9 then F.n = F.n * 6 + K /* Learn dummit */
193 if B.i ~= 0 then Signal Cpufin
205 Print: /* Procedure for printing the board */
210 P = P || format(B.i,4)
213 Say CC Format(B.13,2) ' ' Format(B.6,2)
216 P = P || Format(B.i,4)
221 Moveit: Procedure Expose B. H M /* Move the 'M
' pit */
226 if M > 13 then M = M - 14
230 if B.M = 1 then /* Last bit was empty */
231 if M ~= 6 then /* Not your home */
232 if M ~= 13 then /* Not my home */
233 if B.P~= 0 then Do /* Opposite pit was empty too */
241 D = -99 ; H = 13 ; Q = -99
243 G.i = B.i /* Save the board */
246 Do J = 7 to 12 /* Calc for all the possible */
247 if B.J = 0 then ITERATE /* moves */
252 if B.i = 0 then ITERATE
257 if B.L = 0 then /* Again the same story */
258 if L ~= 6 then /* Life goes on... */
259 if L ~= 13 then R = B.P + R
266 if k > 6 then k = k - 7
268 if F.n*6 + k = Trunc(F.i/6**(7-C) + 0.1) then Q = Q - 2
273 B.i = G.i /* Restore the board */
276 if Q >= D then Do /* if the current move is better */
277 A = J /* then Save it */
287 /* Help me if you can, I'm feeling down
... */
290 if left(Sourceline(Line
),2) = '*/' then return
292 if line
// 23 = 0 then Do
293 Say
'Press <enter> to continue...'