# Princeton University COS 217: Introduction to Programming Systems

## The Game of Kalah: Egyptian Rules

### The Board

Kalah is played on a board that consists of 14 bowls arranged as shown above. The six small bowls at the bottom of the board belong to Player #1; they are numbered (counter-clockwise) 0 through 5. The large bowl at the right – bowl number 6 – also belongs to Player #1; it is Player #1’s kalah.

Similarly, the six small bowls at the top of the board belong to Player #2, and are numbered (counter-clockwise) 7 through 12. The large bowl at the left – bowl number 13 – is Player #2’s kalah.

During the game, each bowl contains zero or more stones. Players move by picking up stones from bowls and dropping stones into bowls, as dictated by the rules of the game.

### The Objective

The objective of the game is to collect more stones in your kalah than your opponent collects in his/her kalah.

### The Egyptian Rules

At the beginning of the game each small bowl contains four stones, and the two kalahs are empty. Player #1 moves first.

A player moves by picking up all stones from one of his/her bowls, and dropping them, one stone per bowl, in the counter-clockwise direction. If the player reaches his/her kalah, then he/she drops a stone in it. The player does not drop a stone in the opponent’s kalah.

Example: Player #1 might begin the game by picking up and dropping the stones from bowl 4. As a result of that move, bowl 4 would contain 0 stones, bowl 5 would contain 5 stones, bowl 6 (Player #1’s kalah) would contain 1 stone, bowl 7 would contain 5 stones, and bowl 8 would contain 5 stones.

If the player drops the last stone into his/her kalah, then the player moves again. Otherwise, the opponent moves.

Example: Player #1 might begin the game by picking up and dropping the stones from bowl 2. As a result of that move, bowl 2 would contain 0 stones, bowl 3 would contain 5 stones, bowl 4 would contain 5 stones, bowl 5 would contain 5 stones, and bowl 6 (Player #1’s kalah) would contain 1 stone. Since the last stone landed in Player #1’s kalah, Player #1 moves again.

If the player drops the last stone into one of his/her own small bowls, and that bowl was previously empty, then the player removes the stone from that bowl and drops it in his/her kalah. The player also removes all stones from the bowl that is directly opposite that bowl, and drops them in his/her kalah.

Example: Suppose that Player #1 drops the last stone into bowl 1, and that bowl 1 was previously empty (i.e. it now contains only one stone). In that case, Player #1 picks up the stone from bowl 1, and drops it into his/her kalah (bowl 6). Player #1 then picks up all stones from the opposing bowl – bowl 11 – and drops them into his/her kalah.

When one player no longer has any stones in his/her small bowls, the other player picks up all the stones that remain in his/her small bowls, and places them in his/her kalah. At that point the game is over. Note that it is not necessarily advantageous to be the first player to empty all of his/her small bowls.

Example: Suppose that bowls 0 through 5 are empty. Then Player #2 picks up all stones from bowls 7 through 12, and drops them into his/her kalah. The game is then over.

At the end of the game, whichever player has more stones in his/her kalah is the winner.