Playing Mancala is easy:In the next episode he promises to look at unit testing in IronPython by showing us how he tested this code.
The board has two stores (also called Mancala) one for each player and the goal of the game is to collect as many stones as possible.
remark – if you don’t see the stores in the board above don’t worry my board doesn’t have any. instead I keep the seeds/stones won at the sides of the board.
Each player has six pots he can play from (the ones closer to his side) in the board above my side is the six lower pots.
Players alternate turns, in his turn a player choose one of his pots, takes all of the stones from that pot and places them one by one on every pot he passes in counter clockwise order. When the player passes his store (Mancala) he places a stone there as well.
If the last stone placed in the player’s store he gets another turn.
If the last stone is placed in an empty pot he captures the stones on the opposite pot and places them in his store along with the capturing stone.
And finally the game continues until one of the players clears all of his side (and cannot “move”).
Classes of the game
I have four classes in my Mancala implementation:
- Board – has most of the game logic along with the board representation
- Store – represent the player’s stores and has a counter for the number of seeds in store
- Pot – represent a simple pot along with the amount of seeds in it
- MancalaException – game specific exception
Monday, May 18, 2009
A follow up from Part 1: where to start, this is a blog entry by Dror Helper on starting programming with IronPython. This entry mainly explores Python the language; including exceptions, classes, methods and magic methods. He has set himself the task of implementing a version of the Mancala board game.