Mancala Playing Agent

 


Mancala is an ancient African game of math and skill. Two players are needed. The board is set up as shown above. Each player has a row of six bins on their side and one kalaha. The game starts with four stones (or shells, gems, etc) in each bin but not the kalahas. During their turn, a player may move the pieces from their side of the board but not their opponents. The winning player has the most stones in their kalaha at the end of the game. Note that there are variations that use a different number of bins as well as a different number of starting stones in each bin.

On a turn, a player will scoop up all of the stones in any one of the six bins on their side. This player will then proceed to deposit these stones, one at a time, into each bin they come to starting with the bin to the right of the one they recently emptied. Once they come to their kalaha, they drop one stone in it and then continue to deposit the remaining stones in the bins on their opponent's side. If they come to their opponent's kalaha, it is skipped over and the remaining stones are deposited in the bins on the player's side. Thus, the pieces are deposited in a roughly counter-clockwise manner around the board. If the player's last stone lands in their own kalaha, they may take another turn.  In addition, if the player's last stone lands in an empty bin on their side, it and all stones in the opponent's bin opposite it are deposited into the player's kalaha. It is then their opponent's turn.

The game is over when either player has no stones left on their side of the board. The player with stones left may then deposit all of them into their own kalaha. The player with the most stones in their kalaha is the winner.

The game applet provided here is played as follows: To move, the player must first select the desired bin by clicking the radio button below it and pressing the Move button. This process is repeated for as long as the player has moves. After the player's turn is over, the computer will select its move automatically. It may take the computer around 10 seconds or so to select a move depending on the web browser's CPU. The Reset button can be used at any time to return the board to its original start-game state. The player's kalaha is labeled "P1" and the player will always move first.

Troubleshooting

If the game applet does not appear, the latest version of the Java Runtime Environment may be required. It can be downloaded here.

This applet has been tested with Firefox, Mozilla, and Internet Explorer under MS Windows 98, MS Windows XP, Linux, and OS X.