UMBC CMSC 202
UMBC CMSC 202 CSEE | 202 | current 202

CMSC 202 - Project 1

BattleShips - A Game of War

Assigned Sunday September 17, 2006
Design Due Sunday September 24, 2006
Program Due Sunday October 1, 2006 at 11:59pm
Updates
[Search for the word "Updated"]
  • Sept. 26 - User Interaction clarified.
  • Sept. 25 - User Interaction updated - more specifics on user inputs.
  • Sept. 20 - User Interaction updated - do not reprompt after repeated guess.

Objectives


General Project Description

You have just recently started an internship with GamesCo - a local interactive game company and your supervisor wants you to create an electronic version of the old BattleShip game. You will be responsible for creating the interface that users will see, all of the game logic, a networking component that will allow users to play each other head-to-head, and an artificial-intelligence component that will allow users to play the computer. Each phase of this project will add on a different component so that by the end of the five phases, you will have a completely operational BattleShips game.

Project Description

For the first phase of the project, your boss wants you to focus on the representation of the board and interactivity with the human player. Also, for simplicity, he requires that you include a component that reads gameboards from a file. The following components of functionality are required, in the following order:

Board File

The following guarantees can be assumed about the board files we will use to test your application:

User Interaction

Users are expected to supply the following input when requested (but values and types are NOT guaranteed) The following are requirements for the user-interaction and will be tested: The following are guarantees for the user-interaction: Updated [Review all below]!

Design and Implementation Requirements

Functions

This project is designed to give you ample opportunity to explore, experience, and use functions with a variety of different styles of parameters. You MUST use functions in this project whenever possible. If your main function is longer than 25-50 lines or so - it is probably too long - you need to break it apart. However, if your functions are all less than 5 lines, or several look very similar, you may need to rethink/combine them.

The proper use and implementation of functions is an important part of this project (and your grade for this project). In particular,

Output

You project is required to produce reasonable output that is nicely formatted and readable for the user. In addition, your project is required to print the board to the user in the following format: 0 1 2 3 4 5 6 7 8 9 A o o H o o o o o o o B o o H o o o o o o o C o o o o o o o o o S D o o o o o o H o o S E o o o o o M H M o S F o o o o o o S o o S G S S S o o o S o o o H S o o o o o S o o o I S o o o o o o o o o J H o o o o o o o o o The following must be true about the board-display from your project, variations are not acceptable:

Example Input and Output

Example files have been provided in Ms. Wortman's public directory for this project (location listed below).

Example Program Execution

The following is an example of a single execution of a project. The middle has been extracted for simplicity (and length). Your output should be similar but need not be identical. linux1[96]% Proj1 Welcome to Battleship Tester! This application tests the Human component of the game and ensures that boards can be read in from a file. What file would you like to read the board from? boards/b1.txt 0 1 2 3 4 5 6 7 8 9 A o o S o o o o o o o B o o S o o o o o o o C o o o o o o o o o S D o o o o o o S o o S E o o o o o o S o o S F o o o o o o S o o S G S S S o o o S o o o H S o o o o o S o o o I S o o o o o o o o o J S o o o o o o o o o 0 1 2 3 4 5 6 7 8 9 A o o o o o o o o o o B o o o o o o o o o o C o o o o o o o o o o D o o o o o o o o o o E o o o o o o o o o o F o o o o o o o o o o G o o o o o o o o o o H o o o o o o o o o o I o o o o o o o o o o J o o o o o o o o o o Where would you like to attack? (row column) (ex: A 1) K 0 Sorry, you have chosen an illegal move. Please try again. (row column) A B Sorry, you have chosen an illegal move. Please try again. (row column) A 0 You have missed! 0 1 2 3 4 5 6 7 8 9 A M o S o o o o o o o B o o S o o o o o o o C o o o o o o o o o S D o o o o o o S o o S E o o o o o o S o o S F o o o o o o S o o S G S S S o o o S o o o H S o o o o o S o o o I S o o o o o o o o o J S o o o o o o o o o 0 1 2 3 4 5 6 7 8 9 A M o o o o o o o o o B o o o o o o o o o o C o o o o o o o o o o D o o o o o o o o o o E o o o o o o o o o o F o o o o o o o o o o G o o o o o o o o o o H o o o o o o o o o o I o o o o o o o o o o J o o o o o o o o o o Where would you like to attack? (row column) (ex: A 1) A 1 You have missed! 0 1 2 3 4 5 6 7 8 9 A M M S o o o o o o o B o o S o o o o o o o C o o o o o o o o o S D o o o o o o S o o S E o o o o o o S o o S F o o o o o o S o o S G S S S o o o S o o o H S o o o o o S o o o I S o o o o o o o o o J S o o o o o o o o o 0 1 2 3 4 5 6 7 8 9 A M M o o o o o o o o B o o o o o o o o o o C o o o o o o o o o o D o o o o o o o o o o E o o o o o o o o o o F o o o o o o o o o o G o o o o o o o o o o H o o o o o o o o o o I o o o o o o o o o o J o o o o o o o o o o Where would you like to attack? (row column) (ex: A 1) A 2 You have hit a ship! 0 1 2 3 4 5 6 7 8 9 A M M H o o o o o o o B o o S o o o o o o o C o o o o o o o o o S D o o o o o o S o o S E o o o o o o S o o S F o o o o o o S o o S G S S S o o o S o o o H S o o o o o S o o o I S o o o o o o o o o J S o o o o o o o o o 0 1 2 3 4 5 6 7 8 9 A M M H o o o o o o o B o o o o o o o o o o C o o o o o o o o o o D o o o o o o o o o o E o o o o o o o o o o F o o o o o o o o o o G o o o o o o o o o o H o o o o o o o o o o I o o o o o o o o o o J o o o o o o o o o o [...] [cut for length] [...] Where would you like to attack? (row column) (ex: A 1) I 0 You have hit a ship! 0 1 2 3 4 5 6 7 8 9 A M M H o o o o o o o B o o H o o o o o o o C o o o o o o o o o H D o o o o o o H o o H E o o o o o o H o o H F o o o o o o H o o H G H H H o o o H o o o H H o o o o o H o o o I H o o o o o o o o o J S o o o o o o o o o 0 1 2 3 4 5 6 7 8 9 A M M H o o o o o o o B o o H o o o o o o o C o o o o o o o o o H D o o o o o o H o o H E o o o o o o H o o H F o o o o o o H o o H G H H H o o o H o o o H H o o o o o H o o o I H o o o o o o o o o J o o o o o o o o o o Where would you like to attack? (row column) (ex: A 1) J 0 You have hit a ship! Congratulations, you have won the game!

Example Board Files

The following are three example boards to test your program, but I would recommend creating your own boards by hand that will test the boundaries of the board (i.e. first and last rows and columns, four corners, etc.) o o S o o o o o o o o o S o o o o o o o o o o o o o o o o S o o o o o o S o o S o o o o o o S o o S o o o o o o S o o S S S S o o o S o o o S o o o o o S o o o S o o o o o o o o o S o o o o o o o o o o o o S S S S o o o o o o o o o S o o o o o S S S S S o o S o o o o o o o o o S o o o o o o o o o S o o o o o o o o o o o o o o o o o o o o o o o S S S S o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o S S S S S S S o o o o o o o o o o S S S o o o o o o o o o o o o o o o S S S S o o o o o o S S S o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o

Data Structures

The following are requirements of the data structures that you must use in your project

Tips for Success

Here are some tips for having a simpler development process:

General Tips


Project Design Assignment

Your project design document for project 1 must be named p1design.txt. Be sure to read the
design specification carefully. Submit your design in the usual way: submit cs202 Proj1 p1design.txt Remember - the design is due ONE WEEK before the project. Late designs will not be accepted.

Project Makefile

The "make" utility is used to help control projects with large numbers of files. It consists of targets, rules, and dependencies. You have already learned about make files in lab. For this project, the makefile will be provided for you. You will be responsible for providing makefiles for all future projects. Copy the file makefile from Ms. Wortman's public directory to your directory.

When you want to compile and link your program, simply type the command make or make Proj1 at the Linux prompt. This will compile all necessary .cpp files and create the executable named Proj1.

The make utility can also be used for compiling a single file without linking. For example, to compile Proj1.cpp, type make Proj1.o.

In addition to compiling and linking your files, make can be used for maintaining your directory. Typing make clean will remove any extraneous files in your directory, such as .o files and core files. Typing make cleanest will remove all .o files, core files, Proj1 executable and backup files created by the editor. More information about these commands can be found at the bottom of the makefile.


Grading

The grade for this project will be broken down as follows. A more detailed breakdown will be provided in the grade form you receive with your project grade.

85% - Correctness

This list may not be comprehensive, but everything on this list will be verified by the graders.

15% - Coding Standards

Your code adheres to the
CMSC 202 coding standards as discussed and reviewed in class.
In particular, since this is your first C++ program, pay particular attention to the list below. Graders will check all applicable items in the coding standards.
  1. Your file header comments
  2. Your function header comments (particularly pre- and post-conditions)
  3. Function and variable names
  4. In-line comments
  5. Code readability
  6. Limiting variable scope

Project Submission

Steps for Submission

  1. submit all files
  2. submitls to verify they are in the remote directory
  3. submitmake to build your files remotely
  4. submitrun to run your files remotely
Assuming you've used the recommended file names, then to submit your project, type the command submit cs202 Proj1 Proj1.cpp Proj1Aux.cpp Proj1Aux.h Makefile The order in which the files are listed doesn't matter. However, you must make sure that all files necessary to compile your project (using the makefile) are listed. You need not submit all files at the same time. You may resubmit your files as often as you like, but only the last submittal will be graded and will be used to determine if your project is late. For more information, see the projects page on the course website.

You can check to see what files you have submitted by typing

submitls cs202 Proj1

Be sure to build your project once it has been submitted using the submitmake command, so that you know that all of the files are there and are the most up-to-date versions:

/afs/umbc.edu/users/d/a/dana3/pub/CMSC202/submitmake cs202 Proj1

Test your program to ensure that all files are the most recent versions:

/afs/umbc.edu/users/d/a/dana3/pub/CMSC202/submitrun cs202 Proj1

More complete documentation for submit and related commands can be found here.

Remember -- if you make any change to your program, no matter how insignificant it may seem, you should recompile and retest your program before submitting it. Even the smallest typo can cause compiler errors and a reduction in your grade.

Avoid unpleasant surprises!

Be sure to use the submitmake and submitrun utilities provided for you to compile, link and run your program after you've submitted it.


Last Modified: Sunday, 01-Oct-2006 19:28:09 EDT