AFRICAN SEEDS

-------------

by M.J.Edwards

from ZX Computing August/September 1985



Down in darkest Gwent something stirs. It's M.J.Edwards playing this brain

testing game!!!





AFRICAN SEEDS is based on the mancala games popular in Africa. The nature of

the games varies widely from place to place, but they are usually based on

capturing counters from rows of cells. The counters may be seeds, beans,

stones or twigs. The cells may be holes in the ground, cups, or hollows in

beautifully carved wooden game-boards. There may be two, three or four

players and either two or four rows of cells, and the way they are divided

between the players, and the conditions under which capture can occur, vary

according to whether the game is Awari, Ayo, Ba-Awa, Lontu-holo, Wari, Whyo,

or one of the four-rank mancala games. Wari and Awari are probably the most

profound in strategy, and are considered to be on a level with chess, but

other games are faster, with more dramatic changes in fortune.



The games are well suited for computer play. The element of calculation is

important, and computers can be programmed without too much difficulty to

beat humans. From the players point of view, it is much easier to type in a

letter on a computer keyboard, than to pick up maybe thirteen counters from

one cup and put them individually into another row of cups.



This program can be beaten  though at level 0 youll have to work rather

hard to do so. Sometimes you will see how to win easily, but a sequence of

lifts can continue for, say, twenty-five moves, and the computer is rather

better at keeping track of them than I am! Dont lose heart, though, the

computers depth of search is deliberately limited  and even at its highest

level, its still capable of blunders just as big as yours.



At the start of the game, the computer tosses for first move. If you win, you

will be invited to enter a letter to denote the cup you want to lift. The

computer will take the seeds out, and sow them in successive cups in an

anti-clockwise direction. If the final seed of the lift falls into an

occupied cell, all the seeds in that cell are lifted and the sowing continues

as before. Otherwise, if the final seed lands in an empty hole  and the

sowing must continue until this is so  you capture the seeds in the hole

immediately opposite, if it is in your opponent's row, or none if it is in

your own row.



The only problem with making captures is that if you leave the computer with

no seeds to play, it will claim the win by forfeit. With that proviso, once

you have captured twenty-five or more seeds, the victory is yours.



The computers speed of response depends upon the level chosen, but is

reasonably fast anyway. Just in case you get bored, you are treated to a

display of flashing lights and bleeps (a feature lacking in the African

originals?). They are intended for more than diversion, though  they show

which moves are being made or considered. A steady blue light shows the cup

where a sequence of lifts ends. A flashing blue light shows where a capture

occurs.



The structure of the program is simple, and the table should make it easy to

modify. For example, if you leave out the instructions and some "special

effects", it ought to be possible to squeeze it all into a 16 K Spectrum. Or,

you might prefer to display integers, as in Lines 2325-2330, instead of the

pips in Lines 2301-2324. If you want to make the computer stronger, then you

could replace the part of Line 1150 after the INPUT with the simpler "GO TO

1300",and replace the "+20" in Line 1070 with "+50". Save the program with

(using whatever title you like) SAVE "AS" LINE 1000.



LINES  FUNCTION                 SUBROUTINES CALLED

1000   Initialise               Display

                                User-defined graphics

                                Instructions

                                Codes for print positions held in strings

1200   Computer's move          End check

1300   Analysis and evaluation  Move check and capture check

                                Display board

                                End check

1500   Player's move            Make move

                                Tidy display

                                Display board

       GO TO 1200 ELSE

       END



Subroutines:

100     Lift and sow = Make or Check a move

200     Check for end of move and capture

300     Display board

400     Tidy display

500/600 Result = END

700     End of game check

2000    Display

2100    User-defined graphics

2160    Codes for letter positions

3000    Codes for seed positions

2400    Instructions



Variables used:

zx      set to 1 for computers move

d       depth of search

l       level chosen

c       stalemate counter

sc      set to 1 to make a move, or set to 0 to evaluate the position

win     number of points scored on a move

end     set to one if a sequence of lifts reaches an end

op      the cell opposite the end of a sequence of lifts



Arrays used:

b(12)   board positions

h(12)   model board fo analysis

m(12)   move evaluation

s(2)    the scores: s(1) is the computer's, and s(2) the player's

a$(12)  column positions for letter display

x$(12)  row positions for seed display

y$(12)  column positions for seed display



Data and user-defined graphics:



Lines 2300-2324 consititute a "look-up" table which works much faster than a

user-defined function displays integers.

Graphics A to H represent the numbers 1 to 8.

Graphics I to L represent the corners of the cups in the order top right, top

left, bottom left, bottom right.

