Home CPSC 220

Mancala Game


Due: October 5



To continue practicing Java programming including control structures, input, output, variables, functions and arrays.


For this program, you will write a version of the Mancala board game in Java. Mancala is one of the oldest board games and variations are played all over the world. Mancala is a two-player game and each player has one side of the board. Each side consists of six holes and a "well" which can store pieces:

There are 48 pieces which begin divided evenly among the 12 holes, with four pieces in each. The goal of the game is to get as many pieces into your well as possible.

Play consists of multiple turns in which the player whose turn it is chooses one of their holes. They then pick up the pieces in that hole and move them to their right, dropping a piece in each hole on the way. If they reach their well, they drop one piece there as well. If they still have pieces after dropping one into the well, they begin dropping pieces into their opponents side of the board as well - moving right to left. Players never drop pieces into their opponent's well, however.

If a player reaches their well with the last piece from the hole they picked up, then they get to go again.

If a player drops their last piece into one of their empty holes, and their opponent has any pieces in the adjacent hole, then the player takes the piece they dropped and those in the opponent's adjacent hole and puts them into their well.

Play ends when either player has zero pieces in the holes on their side of the board at the end of a turn. Once one player runs out, any pieces in the other player's holes are added to that player's well. The player with the most pieces in their well is then declared the winner.

There is an online version of Mancala here which you can use to familiarize yourself with the game.




Computer Strategy

For this assignment, you will need to come up with a strategy for the computer player. The simplest strategy to make the game work would be to have the computer select its move at random, or always start from one end or the other. If you choose this strategy, you can receive a grade of up to an 85% on the assignment, assuming everything else works perfectly.

To get a better grade, you will need to program more intelligent behavior. How you accomplish this is up to you, but your grade will be based on how difficult your program is to beat, and by how sophisticated your algorithm is. Especially good strategies can get extra credit!


General Requirements



To submit your program, email the source file to ifinlay@umw.edu.

Copyright © 2024 Ian Finlayson | Licensed under a Attribution-NonCommercial 4.0 International License.