⚓ Battleship

A two-player naval combat game — choose how you want to play

Play in Browser (Graphical) Play on Mobile Play in Browser (Terminal-style)
🎯

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

ShipLengthSymbol
Carrier 5 cellsA
Battleship4 cellsB
Cruiser 3 cellsC
Submarine 3 cellsS
Destroyer 2 cellsD
🌊

Graphical Web Client

Recommended

The easiest way to play — click to place ships and click to fire. Works in any modern browser, no installation needed.

  1. Open webclient.html in your browser.
  2. 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.
  3. 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.
  4. 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!
  5. 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.

  1. Open player in your browser.
  2. Choose 1 to create a game (enter both player names) or 2 to join one an opponent created (enter your name and their name).
  3. Place ships one at a time by typing a coordinate (e.g. A3), choosing an orientation from the dropdown, and clicking Place Ship.
  4. 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

Get client.py from GitHub.

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
  1. Choose 1 to create a game — enter your name and your opponent's name.
  2. Your opponent runs the same command, chooses 2, and enters their name and your name to join.
  3. Place your ships by typing coordinates (e.g. C5) and orientation (H or V).
  4. When it's your turn, type a coordinate to fire. Type Q or 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.

  1. Open mobile in your phone's browser.
  2. Enter your name and your opponent's name, then tap Start / Join Game.
  3. Place your fleet by tapping cells on the grid. Use ↔/↕ to toggle orientation, 🎲 Random to auto-place, or ↩ Undo to remove the last ship.
  4. 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:

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.