applets.

Battleships Tactics

← All apps

About Battleships Tactics

Battleships is a guessing game for two players with two grids each: one for your own fleet, one for your shots at the other side's. You call a square ("C7"), and you're told miss, hit, or "you sank my cruiser". This page takes the shooting half of the game apart: how to find a hidden fleet in as few shots as possible, and how to hide one so it takes longest to find.

PLAY: the computer has hidden a fleet; clicktap a square to fire (or move with the arrow keys and press Enter). A ring is a miss, a red cross a hit; when a ship goes down it is named and pencilled round. Tick Show where the ships are likely to be for the same count the probability density hunter uses (it spoils the game a little, so it starts off). When the fleet is sunk the page plays 500 games of each strategy against fleets hidden the same way, so you can see how you did.

STRATEGIES: four hunters against the same hidden fleet, shot for shot. STEP fires one shot each, RUN keeps going until all four have finished (PAUSE stops them where they are, RESUME carries on). The fleet is shown faintly so you can see what each one is missing; the density hunter's pad is shaded with its count before each shot.

RACE: each hunter plays the same fleets, 100 to 10,000 games, in the background. The upper chart is how many games took each number of shots, the lower one how many had finished by each shot.

HIDING: the other side of the game. The map shows how often each square is fired at in a hunter's first 10, 20 or 30 shots; the table hides the fleet in six different ways and times the density hunter and the plain hunt-and-target hunter against each.

The orders along the top apply everywhere: the grid size, the fleet, and whether ships may touch (side by side or corner to corner). The usual fleet is 5, 4, 3, 3 and 2 squares. The ten-ship fleet (one of 4, two of 3, three of 2, four of 1) is the one long played on paper in Russia and much of eastern Europe, where ships are usually not allowed to touch, so picking it ticks that rule; you can change it back. You can also type a fleet of your own, up to ten ships of 1 to 6 squares.

THE STORY

Battleships began as a pencil-and-paper game, played on squared paper long before it was sold in boxes. It is often said to date from the First World War or a little before, but nobody has pinned down where or when it began. Printed pads of ready-ruled grids were on sale by the 1930s, under several names. The boxed versions with plastic pegs and boards came later, from the 1960s on. Because the game itself is old and simple, it belongs to nobody: the names here are plain ones, and the fleets are the usual pencil-game fleets.

THE FOUR HUNTERS

Random fires at a random untried square every time. It has to find all 17 ship squares among 100, and on average the last of 17 squares in a shuffled 100 comes at 17 × 101 ÷ 18 = 95.4: so random shooting nearly always clears most of the board. That figure is the Expected line in RACE.

Hunt and target fires at random until it hits, then works through the untried squares next to each hit (up, right, down, left), adding the neighbours of every new hit, until it runs out; then it hunts again. It doesn't use "you sank my...", so it often wastes shots round a ship that has already gone.

Hunt with parity is the same, but hunts only on a diagonal grid of squares: if the smallest ship left is 2 long, every ship must cover a square of a chessboard's one colour, so it only fires on those; if the smallest left is 3, every third square on each row is enough.

Probability density counts. For every ship still afloat it goes through every place that ship could lie: across or down, in no missed square and no square of a ship already sunk (and, if ships can't touch, not beside any hit it doesn't cover). Each square scores the number of those places that cover it, and it fires at the highest score. While there are hits not yet explained by a sinking, a place that covers k of them counts 30k times, so the count pulls straight towards the hits and along the line of a ship.

Sinkings are the subtle part. "You sank my cruiser" names the ship, not its squares: with four hits in a row and a 3-square ship sunk at one end, one of the hits belongs to someone else. The page works out every way the sunk ships could lie on the hits (not overlapping, and not touching each other if that's the rule) and marks as sunk only the squares that every way agrees on. Those squares are taken out of the count, the ship is taken off the list, and any hit that might still belong to a ship afloat keeps pulling the next shots. A ship is pencilled round once its squares are certain.

HOW GOOD ARE THEY?

Published simulations of the standard 10 × 10 game with the 5, 4, 3, 3, 2 fleet (best known is Nick Berry's 2011 article for his DataGenetics blog) put random shooting at about 96 shots, hunt and target about 65, parity a little better, and a probability density hunter about 42. This page's own hunters land at about 95, 66, 61 and 45. The density hunter here counts each ship on its own and adds the counts; a hunter that counted whole fleets at once (every way all the ships could lie together) would do a little better, but is far slower.

SIMPLIFICATIONS

The computer hides its fleet by placing the biggest ship first, each one at random among the places still free, so every layout isn't quite equally likely. It doesn't fire back: the page is about the hunting. The hunters don't learn from earlier games; a human opponent who always hides the same way can be read, which is what HIDING shows. Runs use a seeded random number generator, so the same orders give the same RACE and HIDING results; the results shown when the page opens were made that way with the usual orders.

FURTHER WATCHING AND READING

GRID FLEET
ENEMY WATERSyour shots
SIGNAL LOG
0shots fired

    ClickTap a square to fire. Keys: arrows and Enter, N new game, H shading.