CIT 591 Assignment 3: Three Musketeers
Fall 2014, David Matuszek

Purposes of this assignment

General idea of the assignment

Write a program 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.

Details

git and GitHub

git is a "Version Control System." That is, it keeps track of the current and all previous versions of a program, supports multiple current versions, and provides excellent support for teams in which multiple people contribute to the development of a program. GitHub is a web site which holds the programs being developed with git.

At your earliest convenience, download and install git on your own computer (if it isn't there already). We won't actually be using it on this assignment, however, because it's too easy to get tangled up in it if you don't know what you are doing. I will lecture on git later, in some detail. For this assignment, just go to https://github.com/DavidMatuszek/ThreeMusketeers and copy the two .py files you find there into your own directory.

Writing tests first

According to the dictates of agile programming, it is better to write the tests before writing the code to be tested. Since in this assignment I'm providing stubs for both methods and their tests, this is an easy time to try doing things the agile way.

I have an entire writeup on Test-Driven Design (TDD), but here's the capsule version:

  pick a method that doesn't depend on other, untested methods
  while the method isn't complete:
      write a test for the desired feature
      run all tests and make sure the new one fails
      while any test fails:
          add/fix just enough code to try to pass the tests
      refactor the code to make it cleaner

About the provided code

See the Wikipedia article for the rules of the game.

The "board" is represented as a list of five lists; each of these lists represents a row, and each list contains five elements. The first list represents the first row; the first element in each list represents the first column. The values in the list must each be one of three things: an 'M', representing a Musketeer, an 'R', representing one of Cardinal Richelieu's men; and a '-', representing an empty space. board is the one and only global variable in this program.

Directions are given as one of the four strings 'left', 'right', 'up', and 'down'.

Starter code, both three_musketeers.py and three_musketeers_test.py, can be found on GitHub at https://github.com/DavidMatuszek/ThreeMusketeers. Your job is to complete the program, writing both the tests and the code.

Some brief Python reminders

Here are some Python things to remember:

The computer does not have to play a great game--it does have to play legally. However, if the computer plays stupidly, it won't be much fun. If you would like to implement a simple strategy, here's a start:

Don't spend any more time than necessary on strategy until after the program is working!

Due date

Turn your assignment in to Blackboard before 6am Friday, September 19. This is a pair programming assignment, so you should decide which of you will turn it in (we don't want to grade two copies of the same program). Be sure to put both of your names in a comment right at the top of the program.