Mancala (the game in Python)

The word mancala means to transfer in Arabic. This game, which by some estimates is 7,000 years old, challenges players to move pieces from bin to bin in its special board. Many rule variations exist, and mancala is played in some form in almost every African country.

There are over 800 different types for this turn-based strategy game. The boards can range from something simple with two rows of bins to more artistically-crafted designs made to look like things like seashells or animals.

image alt text

Rules

                Player 1 Side
            <-------------------  
         1    2    3    4    5    6        
  Store  _    _    _    _    _    _ 
    _   / \  / \  / \  / \  / \  / \    _
   / \  \_/  \_/  \_/  \_/  \_/  \_/   / \
   | |   _    _    _    _    _    _    | |
   \_/  / \  / \  / \  / \  / \  / \   \_/
        \_/  \_/  \_/  \_/  \_/  \_/  Store
         6    5    4    3    2    1
            ------------------->  
                Player 2 Side

Setting up the board

The Mancala board is made up of two rows of six pockets (also called “holes,” or “pits*) each. Four pieces are placed in each of the 12 pockets. The color of the pieces is irrelevant. Each player has a “store” (also called a “Mancala” to his/her right side of the Mancala board. The object of the game is to collect the most pieces by the end of the game.

How to play

  1. The game begins with one player picking up all of the pieces in any one of the pockets on his/her side.
  2. Moving counter-clockwise, the player deposits one of the stones in each pocket until the stones run out.
  3. If you run into your own Mancala (store), deposit one piece in it. If you run into your opponent’s Mancala, skip it and continue moving to the next pocket.
  4. If the last piece you drop is in your own Mancala, you take another turn.
  5. If the last piece you drop is in an empty pocket on your side, you capture that piece and any pieces in the pocket directly opposite.
  6. Always place all captured pieces in your Mancala (store).
  7. The game ends when all six pockets on one side of the Mancala board are empty.
  8. The player who still has pieces on his her side of the board when the game ends will capture all of these pieces
  9. Count all the pieces in each Mancala. The winner is the player with the most pieces.

Python Implementation

Github source