CPS 108, Spring 2004, Battleship

Code/GUI info

Final Battleship program

Changing/Keeping original groups


Find partners at this link.

Here are the "offical" rules of battleship.

You are to design classes that will allow battleship to be played with the following scenarios.

Design Goals

As much as possible you should try to use a model, view, controller (MVC) design for your classes. It should be straightforward to implement a curses (text) version of your game, an GUI version of the game using different GUI toolkits, and a networked game. This means, for example, that if you're given code to process the network interactions between two players you should be able to use that code with your battleship classes with minimal modification of your classes. It would be fine to add new code, but ideally you will not modify existing code.

You should develop all .h files you'll need. Your classes should concentrate on behavior. You should have no (or little) private/protected data in your classes. At this point in the programming proces you're concentrating on the interactions between the classes you develop and the interactions between these classes and view/GUI/network code you might be provided.

Your classes should be flexible in accommodating boards of different sizes, ships of different sizes, and rules of ship placement. For example, in some versions of battleship two ships cannot be placed so that they are adjacent. In other versions such placement is possible.

What to Submit

You should submit all your .h files. These files should be syntactically legal C++ (they should compile). The files should include enough comments to indicate how they're used.

You should submit as part of your README extensive documentation on how you think your design will accommodate the criteria specified above. You should also provide documentation on how to program different games of battleship using your classes. Included in this documentation, ideally, will be sample code that shows how your classes will be used in different situations. For the initial design, you should show how your classes will facilitate playing solo against a computer's ships. You might, for example, provide code like this:


 Battleship game;
 Player * p = new KeyboardPlayer();
 game.makeBoard();
 while (! game.over()) {
     game.showBoard();
     Move m = p->getMove();
     game.makeMove(m);
 }
 game.showResults();

Please don't have your code resemble this unless you think it's a great design. I spent two minutes on it, so it's probably not great. I didn't check it with a compiler.

In addition to solo play, you should provide documentation/code that shows how your program can be used in a text-based game, a GUI environment, or perhaps over the Internet via a CGI program (all solo).

Ideally you'll also provide documentation that shows how your code/classes can be used to play against the computer, or over a network against another player.

Grading and Submit

Battleship will be worth 100 points. The final program(s) you write will count for 90 points. This initial design is worth 10 points. If your final design is close to your initial design you'll get a 20 point bonus that can be used for any programs written in 108 this semester.

  submit_cps108 battledesign *.h README other-files-as-needed

Owen L. Astrachan
Last modified: Sat Feb 14 21:49:00 EST 2004