CMSC 201
Programming Project Two

Naval Battle

Out: Wednesday 10/03/07
Due: Before Midnight, Wednesday 10/17/07

The design document for this project, design2.txt ,
is due: Before Midnight, Wednesday 10/10/07

The Objective

The objective of this assignment is to give you practice with project and function design. It will also give you an opportunity to work with a two-dimensional array and passing that array to functions for manipulation.

The Background

This project is loosely based on the game Battleship. Those of you who are already familiar with this game should note that the project description does not follow the same rules as the game. Numerous changes have been made to make a similar game that is much easier to code than the original would be.

The board for this game forms a grid that is 10 rows high by 10 columns wide, that simulates an area of the ocean. Within this area of the ocean are 5 ships, placed there by the computer, but the player cannot see where they are. The objective of this game is for the player to sink all 5 of the ships within a specific number of turns, in our case 40 turns.

For each turn, the player will fire a torpedo into a specific location, indicated by the coordinates of the grid. The computer will then inform the player whether the torpedo hit a target or missed, by placing an O on the board if the shot was a miss or by placing an X on the board if the shot was a hit. A single hit is never enough to sink a ship. The larger the ship, the more hits it can withstand before it sinks. If a ship is 3 units long then it spans three blocks on the grid and would require 3 torpedo hits, one in each of the grid squares occupied by the ship, in order to sink it.

If you would like to practice playing a similar game so that you understand it, I have found a version called Armada on the web that will allow you to play against the computer. Practice Playing Armada

The Task

Design and code a project that will allow you to play Naval Battle against the computer.

The Specifications

Further Specifications

Suggestions

Sample Run

This is the sample run.

Although your output need not be identical to that in the output file, all information (including a greeting and instructions that are not shown in the output) must be present.

Please be aware that this may NOT be a complete test of the program.

Submitting the Program

You are to use separate compilation for this project, so you will be submitting a minimum of three files.
Your C source code file that contains main() MUST be called proj2.c. I would expect that you would also have files called battle.c and battle.h, but you may choose to have additional .c and .h files.

To submit your project, type the following at the Unix prompt. Note that the project name starts with uppercase 'P'.

submit cs201 Proj2 proj2.c battle.c battle.h (and possibly other files, separated by spaces)

To verify that your project was submitted, you can execute the following command at the Unix prompt. It will show all files that you submitted in a format similar to the Unix 'ls' command.

submitls cs201 Proj2