Assignment #1

Battleships, Version 1 Without Graphics

Due: We. Sept. 15th
Score: 10 points + 2 bonus points


Write a version of the well known paper/pencil game 'Battleships'. Since you all know the rules of the game i'll just define some necessary specifications.
The game should be played on a board 20x20 fields, each player may place 5 ships with a fixed size of 3 fields horizontally or vertically on the field. Overlaps are not allowed, of course, since we don't use submarines.
A players move consists of firing a torpedo to a certain field of the opponent, the fields are given by coordinates, e.g. 'A,3'. The opponents answer can be: 'water', 'hit' or 'close'. 'Close' seems not to be a common rule, it means: 'you hit water, but either north, south, east or west there's a ship that is not discovered yet'. This rule is the only rule that makes the game halfway exciting, that's why we use it.

As discussed in class, here are some helps/constraints how to program the game:

The Output

The most sophisticated part of this game is the output. Though it only consists of characters, showing the state of each field, the character (in a later version: the graphic-tile) must be determined. The following characters/states must be used:

A typical output would be:

Although it is tempting here, do not mix the actual graphic output with the program logic to determine the character !

The AI

There will be none in here, we simply will cheat (many games do that!). Since the computer is controlling the whole game and it has the full knowledge to play optimally, we just have to artificially make it more stupid than it actually is. A move of the computer simply consists of a random shot, the probability of hitting a ship or water is controlled by the level, from 1: idiot to 5: god.
You can add strategies, e.g. the knowledge about a close shot or a hit, to gain bonus points in this assignment.

The Grading

The following scheme will be used, it also should give you a guideline for the order you should process the different tasks: