How the Game Works
Battleship is a two-player guessing game. Each player secretly places a fleet of five ships on a 10×10 grid, then players take turns firing at coordinates on the opponent's grid. The first player to sink all five of the opponent's ships wins.
All three clients connect to the same server — players can mix and match freely. One player on the web client can play against a player using the terminal, or any other combination.
Coordinates
Columns are letters A–J (left to right) and rows are numbers 1–10 (top to bottom).
Enter a column letter followed by a row number, e.g. C5 or J10.
Shot Results
- Miss — no ship at that location
- Hit — a ship occupies that cell
- Destroyed — that ship is completely sunk
Ship Placement
- Ships extend right (Horizontal) or down (Vertical)
- Ships cannot overlap or go off the board
- Both players place ships before the game begins
Turns
- Players alternate turns — one shot per turn
- You cannot fire at the same location twice
- The game ends when one player's fleet is fully sunk
The Fleet
| Ship | Length | Symbol |
|---|---|---|
| Carrier | 5 cells | A |
| Battleship | 4 cells | B |
| Cruiser | 3 cells | C |
| Submarine | 3 cells | S |
| Destroyer | 2 cells | D |
Graphical Web Client
RecommendedThe easiest way to play — click to place ships and click to fire. Works in any modern browser, no installation needed.
- Open webclient.html in your browser.
- Enter your name and your opponent's name, then click Start / Join Game. The first person to click this button creates the game; the second person joins it.
- Place your fleet by clicking cells on the grid. Use the ↔/↕ button to toggle orientation, 🎲 Random to auto-place, or ↩ Undo to remove the last ship.
- Once both players have placed their ships, the game begins automatically. Click a cell on the opponent's board to select it, then press Fire!
- The game ends when all ships on one side are destroyed. Click Play Again to start a new game.
Use the ✕ Quit button to leave a game early — this cancels it for both players.
Terminal-Style Browser Client
A keyboard-driven text interface that runs in the browser — same server, same game, different look and feel.
- Open player in your browser.
- Choose 1 to create a game (enter both player names) or 2 to join one an opponent created (enter your name and their name).
- Place ships one at a time by typing a coordinate (e.g.
A3), choosing an orientation from the dropdown, and clicking Place Ship. - When it's your turn, type a coordinate and press Fire! The board updates automatically while you wait for your opponent.
Command-Line Client
A Python script that runs in a terminal window. Requires Python 3 and the requests library.
Installation
pip install requests
Download
Running against the hosted server
python client.py --server https://boardgame.this-is-only-a-test.com
Running against a local server
python server.py # in one terminal
python client.py # in two other terminals, one per player
- Choose 1 to create a game — enter your name and your opponent's name.
- Your opponent runs the same command, chooses 2, and enters their name and your name to join.
- Place your ships by typing coordinates (e.g.
C5) and orientation (HorV). - When it's your turn, type a coordinate to fire. Type
Qor press Ctrl+C to quit — this cancels the game for both players.
Mobile Web Client
A touch-optimized version of the graphical client designed for phones. Boards switch between tabs so everything fits on a small screen.
- Open mobile in your phone's browser.
- Enter your name and your opponent's name, then tap Start / Join Game.
- Place your fleet by tapping cells on the grid. Use ↔/↕ to toggle orientation, 🎲 Random to auto-place, or ↩ Undo to remove the last ship.
- During play, switch between the Opponent and My Fleet tabs. Tap a cell on the opponent's board to select it, then tap Fire!
Timeouts
The server automatically cancels a game if both players go idle:
- › During setup (placing ships) — 2 minutes of no activity
- › During play — 20 seconds of no activity
Activity is measured by polling — as long as a browser tab is open and connected, or the terminal client is running, the timer keeps resetting.