Battleships

Build your agent to compete in the classic naval strategy game

Getting Started

Download the play script to run your battleship agent:

Run Your Agent

wget lode.delta-topgun.cz/assets/play.sh -O play.sh
chmod +x play.sh
./play.sh <how to run your program>

Manual Play

./play.sh --manual

Game Flow

  1. Wait for GAME STARTED message from server
  2. Place all your ships on the board (preparation phase)
  3. Send READY when done placing ships
  4. Wait for opponent to be ready
  5. When YOUR TURN appears, fire at enemy positions
  6. Game ends when all ships of one player are sunk

Game Phases

Preparation Begins after receiving GAME STARTED. Place your ships using PLACE command. Once ready, lock your board with READY. Wait for YOUR TURN.
Active Game Both players have locked their boards. Wait for YOUR TURN, then fire at opponent with FIRE. Your turn ends when you receive OK. If you get another response, you're still on turn and must retry or try a different action.
Game Over Game ends when all ships of one player are sunk. Both players receive GAME OVER.

Server Responses

The server responds with OK for success (optionally followed by data) or KO for errors (optionally followed by error description).

GAME STARTED Game has started, you can begin placing ships
YOUR TURN It's your turn to fire
GAME OVER Game has ended

FIRE Results

W Water (miss)
H Hit!
S Sunk!

Ship Types

Each ship has a root position (marked with ◆) which is used for placement. The PLACE command places the ship's root at the specified position.

C Carrier ×1 5 cells
Parts: (0,0) (1,0) (2,0) (3,0) (4,0)
B Battleship ×2 4 cells
Parts: (0,0) (1,0) (2,0) (3,0)
D Destroyer ×2 3 cells
Parts: (0,0) (1,0) (2,0)
S Submarine ×0 3 cells
Parts: (0,0) (1,0) (2,0) (not in default config)
P Patrol ×3 2 cells
Parts: (0,0) (1,0)

Default fleet: 9 ships total (C1 B2 D2 S0 P3) = 21 cells to place

Ship Directions

Use these directions with the PLACE command to rotate ships:

N Normal
R Reverse
D Down
U Up

Use SHIPS to see how many of each type to place, and SPARTS <ship> to get exact part positions.

Commands Reference

Command format: COMMAND [ARGS...]

Information Commands
? List all available commands → OK [commands...]
DIM Get board dimension → OK 10 (for 10×10 board)
SHIPS List ships to place with counts → OK B2 D2 S0 P3 C1
SPARTS <ship> Get ship parts as relative positions → OK (0,0) (1,0) ...
Preparation Phase
PLACE <ship> <pos> <dir> Place a ship. Example: PLACE C A1 NOK or KO [error]
DEL <pos> Delete ship at position. Example: DEL A1OK
MSHIPS List placed ships → OK C,A1,N B,E3,D ... (or just OK if empty)
READY Lock board and signal ready. ⚠️ Cannot be undone!
Battle Phase
FIRE <pos> Fire at enemy position. Example: FIRE B5OK W / OK H / OK S

💡 Your turn ends only when you receive OK. If you receive KO, you're still on turn and must retry.

Code Examples

Ready-to-use client implementations in multiple languages:

View Example Clients (Python, JavaScript, C, C++, C#)

Running Multiple Agents

Want to run a swarm of agents? Use the play-many script:

wget lode.delta-topgun.cz/assets/play-many.sh -O play-many.sh
chmod +x play-many.sh
./play-many.sh <count> <how to run your program>