CSc 120: Battleship: Rules
Legal Placement
In order for a placement to be legal, each of the five ships must be placed legally.
A ship placement with endpoints (x1, y1)
and (x2, y2) is
legal if all of the following conditions are satisfied:
-
The ship must either be parallel to the x axis or
else parallel to the y axis.
-
The ship must be contained within the 10x10 grid of the game board,
i.e., 0 ≤ x1, y1,
x2, y2 ≤ 9.
-
The distance between the end-points (x1, y1)
and (x2, y2) must match the
size of the ship.
-
Each grid point (x, y)
occupied by the ship, i.e., including and lying between
the end-points (x1, y1)
and (x2, y2), cannot be occupied by
any other ship.
The following illustrates examples of legal and illegal placements:
Legal Guesses
A guess x, y is legal if it is within the game board, i.e.,
0 ≤ x, y ≤ 9