CISC 3115

Exercise 1: Mancala

Objectives:

Remember that exercises are to be done by each of you, working on your own. You may discuss with your teammates, but everyone should be on their own keyboard. These exercises are opportunities for you to "test" your understanding of the unit's concepts.

The Game

Mancala is very old game with many variants (though the variant most common in the US, known as Kalah, seems to have been invented here in the 1940s). It's also regularly discussed in artificial intelligence courses, as the rules of play are quite simple but strategy is a bit complex, making it an ideal "target" for writing a program that can play it well.

But that's not our objective in this exercise: we're simply going to write a program that allows two people to play each other. And I've done most of the work for you. Here's what you need:

The Exercise

In this exercise, you'll modify my simple implementation of this game. Download the source files and put them in an appropriate folder (maybe a folder called "Exercise1" inside your "CISC3115" folder). Use javac to compile them, and java to run the program (what commands, exactly, should you use?) Note that javac is pretty clever about figuring out what additional files need to be compiled.

The code runs, but it is obviously incomplete. In particular, you need to implement the "heart" of the game, the actions of a turn. As part of that, you need to implement logic to support two-player turn-taking. You should write at least one new method that implements this logic. You shouldn't need to modify any of the existing code, but you do need to understand its behavior, especially the behavior of the board display. You may also notice some API methods that are new to you; look them up!

Once you have the game working correctly, take a step back and think about the object-oriented design of this program. Hint: it's not the best. How might you make this more object-oriented? What additional classes might make sense? It might be helpful to look at where you have duplicate (or nearly duplicate) code—that's often a sign of a design improvement that could be made.

We'll spend the last 10 minutes of this "session" discussing this and some other issues.