Assignment 10: Three Musketeers
Fall 2006, David Matuszek

Purposes of this assignment:

General idea of the assignment:

Write a JApplet to play the game of Three Musketeers--human against computer.

You have probably never heard of this game. That's okay, the rules are simple--that's why I chose it. The link above is to a Wikipedia article that explains the game, and I can answer questions if necessary. It also happens to be a pretty good game.

Besides, if you don't already use Wikipedia, it's time to start.


The human should be able to choose which side to play: the Musketeers, or Cardinal Richelieu's men. The Musketeers always move first.

In this game you move pieces around on a 5x5 grid. The usual way to do this (in a lot of similar games) is to first click on the piece you want to move--it should highlight in some way, so you know you've successfully selected it--and then click on the square you want to move it to. Then the computer, in its turn, should highlight the piece it's about to move--wait long enough for the human to see it--highlight the place it's about to move to--wait a bit more--then make the move. Your GUI should do this, or something similar, so that it's always clear what move is being made.

The GUI does not have to be beautiful. A good-looking and easy-to-use GUI makes the game more enjoyable to play, but first make something that works. In an assignment like this, it's easy to spend too much time on looks, then run out of time trying to make it actually work.

The GUI will almost certainly need a few GUI components in addition to the 5x5 playing board. For example, you need to be able to say which side the computer is playing. It would be nice to be able to quit a game and start over. The exact controls are up to you--but they should be easy and obvious.

The computer does not have to play a great game--it does have to play legally. If you would like to implement a simple strategy (rather than just make random moves), here's a start:

Again, don't spend any more time than necessary on strategy until after the program is working.

The computer should also notice when someone has won.

You should use the Model-View-Controller pattern. We will talk more about this in class, but basically it means that the game (the "model") should be independent of the GUI. That is, the part of the program that plays the game should not even "know" whether it is being used by a GUI or by, say, a text interface, or even another Three Musketeers program playing the part of the human. The applet GUI sends moves (and other commands) to the game, and gets moves (and other information, such as whether someone has won) back.

Grading--Read this!

Your program should work. You should have Javadoc for all public entities. You should have JUnit tests for all public methods in your game (but not the GUI). You should estimate how much time this will take you.

In addition, this time your program will be graded heavily on style.

I strongly advise you to think first about the overall design of your program. Come up with at least two (preferably three) ways to structure it before you choose one.

Due date:

Zip up your entire project, including an HTML page (name it index.html), and submit it via Blackboard by Sunday, December 3, before midnight. This will overlap slightly with the next (and final) program, which we will start in lab on Friday, December 1.