previndexinfo

code guessing, round #78, stage 1 (writing)

started at . submit by

specification

welcome back! your task is to play battleship. submissions may be written in any language.

battleship is a two player game where each player has a 10x10 square grid, called "territory". coordinates are written as A-J (vertical) then 0-9 (horizontal) so J0 is the southwest corner. battleship consists of two phases

phase one

place your ships. you have five ships. they are 2, 3, 4, 5, 6 grids long each. first, you must place those ships in your territory without them overlapping or getting outside the grid. you do this by specifying the square where each ship starts, in order, preceded by "-" (hyphen) if it is to be placed horizontally or a | (vertical bar) if placed vertically. you must deploy all 5 ships and no more. if you output

-B1
|H7
-F5
-G1
|B9

your board will look like

A| 0 0 0 0 0 0 0 0 0 0
B| 0 1 1 0 0 0 0 0 0 5
C| 0 0 0 0 0 0 0 0 0 5
D| 0 0 0 0 0 0 0 0 0 5
E| 0 0 0 0 0 0 0 0 0 5
F| 0 0 0 0 0 3 3 3 3 5
G| 0 4 4 4 4 4 0 0 0 5
H| 0 0 0 0 0 0 0 2 0 0
I| 0 0 0 0 0 0 0 2 0 0
J| 0 0 0 0 0 0 0 2 0 0
-+--------------------
 | 0 1 2 3 4 5 6 7 8 9

1, 2, 3, 4 and 5 represent the ships and 0 represents no ship here. of course your enemy does not know this. now for the fun part.

phase two

it's time for BATTLE!!!!!!!!!! simply send a coordinate that you want to ORBITAL STRIKE CANNON OF DEATH, like B4, and then a newline to CONFIRM the attack. if you hit something, you will hear a HIT (all on a single line). otherwise you hit the ocean which is a MISS (all on a single line).

when you win you will receive a WIN (all on a single line). when you lose, it is already too late apart from this you might receive other lines like HIT B4. this represents your enemy sending missiles. don't let your morale be affected, as you can't really do anything about this. it's just for demoralizing effect.

your challenge is to make a program that plays battleship. all unspecified behaviour is unspecified so you can fill the gaps with your imagination. as any language is allowed, there is no fixed API.

entries

2 entries have been received so far.

submit