Volume 10, Issue 2

Articles
In and Out
Trott's Corner
Beyond Sudoku
New Products
New Publications
Calendar
News Bulletins
New Resources
Classifieds

Editorial Policy
Staff and Contributors
Submissions
Subscriptions
Back Issues
Contact Information

Exploring Board Game Strategies

# Mancala: A Two-Player Game

Figure 8. A board of 4 x 8 Mancala.

Mancala is the ancient game of counting and strategy where each player must attempt to collect as many stones as possible before one of the players clears his side of stones (Figure 8). There are many versions of this traditional game.

Here are the rules of the version we will implement:

Each player has a side of the board. The six cups nearest each player belong to him and his mancala--another cup in which to place the captured stones--is to the right. Players alternate turns. During his turn, each player selects a cup of stones from one box on his side of the board. Each stone is placed one by one in the cups around the board (going counterclockwise), including his mancala but not the opponent's mancala. If the last stone lands in the player's own mancala, that player goes again. If the last stone lands in an empty cup on the player's own side, he captures all the stones from the opponent's cup directly opposite that cup. The game is over when a player has no more stones in play on the board. The winner is the player with the greatest total of stones in his mancala.

## Configuration of the Board

The following values define the physical parameters of the board (i.e., in our example a set of six cups for each of the two players). The last column of each row corresponds to the mancala of the player. The patterns are the number of stones in a cup.

Initially, the stones are equally distributed in the cups.

We use an additional global variable, Player, to manage the players.

## Visualizing the Board

A very basic visualization of the board is sufficient for playing--mancalas are separated.

## Transition Function

In this game, playing is just selecting one of the cups. IsPlayable only verifies that the selected cup is not empty.

The rules of the evolution of the board are much trickier to implement as many different cases may arise. GiveStone redistributes the stones of the selected cup.

Other just permutes 1 and 2, while PlayBoard manages the complete evolution of the board.

## Main Loop

The game ends when one player's cups are empty.

For this game, the basic textual interface for playing is quite convenient, as the player is only asked for one digit at each play.

When one player has no more stones, the other player puts all his remaining stones in his mancala. This is implemented by a refinement of the function EndGame.