Battleship (also Battleships or Sea Battle) is a guessing game for two players. It is known worldwide as a pencil and paper game which dates from World War I. The game takes place on a 10x10 board where the rows are numbered with letters (from a to j), and the columns are numbered with numbers from 1 to 10.
Each player has a board, on which he places 10 ships. Each
ship occupies a number of consecutive squares on the grid, arranged
either horizontally or vertically, but never in diagonal. A ship
can neither touch nor overlap with any other ship. The ships can be
2, 3, 4 or 5-square long. The most common setting for the fleet is:
1 ship of length 5, 2 ships of length 4, 3 ships of length 3, and 4
ships of length 2.
As long as those rules hold, the player can place
their ships wherever they want in the board. Then the game proceeds
in rounds, and each player will try to sink the ships of the
oppossite player by ’shooting’ directly to a valid coordinate.
Input
For example, the ship defined by a1 3 h occupies the squares a1, a2, a3, while the ship defined by a1 3 v occupies the squares a1, b1, c1.
Output
Follow the format shown on the examples below.
Observation
typedef vector< vector<bool> > Board;
distancia((i,j), (i′,j′)) = max{∣ i−i′∣, ∣ j−j′∣} |
Input
a1 5 h a10 4 v g10 4 v j5 3 h j1 3 h f1 3 v c2 2 h e4 2 v h5 2 h a7 2 h a1 a5 a6 d8 e8 f8 e6 e7
Output
12345678910 a XXXXX.XX.X b .........X c .XX......X d .........X e ...X...... f X..X...... g X........X h X...XX...X i .........X j XXX.XXX..X a1 touched! a5 touched! a6 water! closest ship at distance 1 d8 water! closest ship at distance 2 e8 water! closest ship at distance 2 f8 water! closest ship at distance 2 e6 water! closest ship at distance 2 e7 water! closest ship at distance 3