Optimal Battleship · detail

Battleship on 5×5

The largest board where we could compute exact best replies: how close our player comes to perfect, and what everything else gives away.

A detail page of Optimal Battleship · data as of 24 October 2026

Five by five, with two 3-cell ships and a 2-cell ship (written {3,3,2}), is the largest board on which we could compute exact best replies, and so the largest where "how close to perfect" has an exact answer. This page goes deeper than section 1 of the essay: the exact machinery, the player it built, the rules that player beats, and what extra information is worth.

Our best 5×5 player is close to perfect, not perfect: its exact best reply gains 1.44 points of win rate when it may choose where to hide and how to hunt, and about 0.85 when it may only hunt. It is also flat, needing 13.7 to 14.4 shots on average on every distinct layout. Every hand-written rule we tried wins at most 22.1% of races on its worst layout, the heat map only 4.1%.

A mixture built by self-play, without ever seeing a near-perfect player, wins 48.5% head-to-head against one and 48.4% on its worst layout. Knowing more than the rules announce is worth little against a frozen near-perfect opponent: 0.38 points for knowing which of your own ships have been hit, about 1.1 with everything a hunt could use in a variant rule, 1.57 for knowing in advance when your fleet will fall. Computing it exactly takes 45 minutes to 12 hours per best reply instead of 6 to 8 seconds.

1The board, the fleet and the race

Each player hides two 3-cell ships and a 2-cell ship on a 5×5 board: straight, inside the board, touching allowed, overlapping not. Every round both players fire one shot, answered "miss", "hit", "sank a 3" or "sank a 2" (the size only, never which ship). The first to sink the whole fleet wins the race; a finish in the same round counts half.

Every strategy here uses only what these rules announce, except where section 7 prices extra information.

The fleet covers 8 of the 25 cells. It can be hidden 8,000 ways, or 1,009 distinct layouts if rotations and reflections count as one. On a random layout a ship covers the center 40.55% of the time and a given corner only 21.45%, because fewer placements fit over a corner.

Terms, as in the essay:

2States of knowledge and the exact best reply

A hunter's state of knowledge is the set of layouts still consistent with everything it has seen. Games that leave the same set are the same state, which keeps the count small enough to compute. The whole set is needed because sinks are announced by size only, and their timing carries information.

Suppose a hunter fires at C1, C2 and C3 in that order, hits all three, and hears one "sank a 2". If the sink came with the second shot, the 2 was C1–C2 and C3 belongs to a live 3; if with the third, the 2 was C2–C3 and the live 3 runs through C1. Only the set of layouts keeps these apart.

On 5×5, with rotations and reflections folded together, there are 180,655,921 states in 26 layers, one per shot count. The graph takes about 100 GB of memory and rebuilds identically in about 10.5 minutes.

Against a fixed opponent, the best reply is one backward pass of dynamic programming. On a 56-core cloud machine a pass takes 6 to 8 seconds and up to 185 GB of memory.

# backward, from the last layer to the first
for each state s, reached after t shots:
    if every ship is sunk in s:
        # the race credit
        V(s) ← P(opponent needs more than t)
               + ½ · P(opponent needs exactly t)
    else:
        V(s) ← max over allowed cells c of
               Σ over answers a of
                   P(a | s, c) · V(next(s, c, a))
# P(a | s, c): the opponent's hider's weight on the
# layouts in s that answer a at c, divided by its
# weight on all of s

Two rules decide which cells are allowed: never fire at a cell that can no longer hold a ship, which costs nothing; and while a hit is not yet explained by a sink, fire only next to a hit, the finish-what-you-hit rule. Together they keep 28.8% of the moves (a move is a state and a cell to fire at): 659 million of 2.29 billion.

The second rule is a real restriction: the best unrestricted hunter sometimes leaves a wounded ship to probe elsewhere. The cost was small where measured (0.03 and 0.09 points on 4×4, 0.06 for one strong 5×5 hunt) but is unknown for the 5×5 best reply, so every 5×5 guarantee here holds among hunts that finish what they hit.

Why stop at 5×5? A best reply visits every state of knowledge, 181 million here, and beyond 5×5 the count puts exact best replies out of reach. The essay switches to self-play there, and so does the 10×10 page.

3The best-reply loop

Our near-perfect players come from the loop of the essay's section 1, which alternates an exact best reply with a linear program over the hunts found so far. The loop that actually ran also carried a pace and added many hunts per round:

q ← any placement distribution
pace ← a starting pace
pool ← empty
repeat:
    # one exact backward pass against q and pace
    add the best reply and its variants to pool
    mixture, q ← linear program over pool,
                 against pace
    pace ← halfway to the mixture's finishing times

Each pass produced 265 candidate hunts, the best reply and variants with other first shots or other handling of the first hits, and the loop kept the distinct ones. Moving the pace only halfway toward the mixture's finishing times damps it so that it does not swing.

Why a lottery over whole hunts rather than one strategy that rolls dice move by move? A state of knowledge forgets the order of its shots, and Kuhn's equivalence between the two (Kuhn 1953) needs a player who remembers everything. A single move-by-move strategy trained by counterfactual regret minimization (CFR+), the self-play method behind strong poker programs, stalled on 4×4: its best reply still won 58.4% of races.

By round 346 the pool held a mixture that won at least 50.00% on every layout against the loop's pace, needing 13.81 to 14.40 shots across the layouts. Winning half against its own pace is necessary, not sufficient (a random shooter does too), so the remaining rounds went into lowering what an exact best reply gains.

The loop stopped at round 2,120 with 12,609 hunts in its pool, while the linear program still reported hunts that would raise its value. Nor did the pool hold the true best reply: against the final player's hiding, the best hunt in it gains 0.26 points and the exact hunting reply 0.86, both at the run's pace (0.85 at the player's own, the value used elsewhere on this page).

A small player exists: with 1,009 layout constraints, some optimal mixture uses at most 1,010 hunts (Carathéodory's theorem). Ours is diffuse instead: nearly all of its roughly 12,600 hunts carry some weight, none more than 0.35%.

4The near-perfect player

This section is about our best player, from round 2,120 of the best-reply loop.

Its worst layout

Against the pace the run was using when it stopped, the best player never wins less than 49.87% on any layout, a guarantee the linear program proves (the essay's 49.9%). Raced against its own exact finishing times, its worst layout gives 49.85%.

That worst layout is the corner pack: both 3s stacked in the top-left corner (A1–C1, A2–C2) and the 2 in the top-right (E1–E2), drawn in Figure 5. Its average there is ordinary, 14.03 shots, but it rarely finishes fast (Figure 3): within 12 shots in 10.7% of games against 24.0% overall. A best reply hides for exactly this: what hurts is the spread of the opponent's finishing time, not its average.

How exploitable it is

The joint best reply, which chooses where to hide and how to hunt, gains 1.44 points (among hunts that finish what they hit): it hides on the corner pack and hunts with the exact best reply. The hunt-only reply keeps the player's hiding and gains about 0.85; the hide-only reply keeps its hunting and gains 0.13 (0.15 against its own exact finishing times).

Much of the strength is in the hiding: had the player hidden its fleet uniformly at random, a hunting best reply would gain 3.11 points against it, against 0.86 with its real hider at that same pace.

How it hides and where it opens

Figure 1
Where the near-perfect players hide and fire first
A random layout
ABCDE1234521303630213035383530363841383630353835302130363021
Center 40.55%, corners 21.45%
The near-perfect hider
ABCDE1234526323932263231323132393230323932313231322632393226
Edge middles 39%, center 30%, corners 26%
The first shot
ABCDE1234500.380.300.321320.381391380.321320.300.380.30
Never a corner; half next to the center
Percent of games in which each cell holds a ship (left and middle, one shared shading scale) or receives the first shot (right, its own scale). Left: all 8,000 layouts equally likely. Middle: the best player's hider. Right: the replay player, from the same run 44 rounds later and built against this same hider; the best player's hunts are not stored shot by shot.

The hider moves weight from the middle toward the edges (Figure 1): a corner holds a ship 26.2% of the time against 21.45% at random, an edge middle 39.0% against 36.0%, the center only 30.0% against 40.55%. Every distinct layout gets weight 0.009% to 0.30% (a family of eight gets 0.10% at random).

Its favorite is the corner pack, at 3.0 times the random weight, as for the hider of the reference player (the snapshot section 5 scores the rules against); all five of its favorites put a 3 along an edge from a corner, where a heat-map hunter looks last.

The hunter opens near the middle instead: the replay player's first shot is never a corner and lands next to the center 50.4% of the time, on the center 9.0% and on an edge middle 30.5%.

Call the hottest cell the one most likely to hold a ship given everything announced and how the opponent hides (here, the same near-perfect hider). Before the first shot those are the four edge middles (39%), so the 30.5% are exactly its first shots at the hottest cell. Over a game it fires there on only 55% of its shots, rising to 80% of 14th shots.

Conditioned on the whole game so far, not just the state of knowledge, the lottery can be replayed as dice rolled at each move (Kuhn 1953): of its 14.07 shots, 6.19 are random choices on average, and 88.6% go to the cell it is most likely to pick.

Flat and fast

Flatness is the clearest mark of near-perfect play (Figure 2): the best player's expected shots range only from 13.72 to 14.35 across the 1,009 layouts, the middle 80% within 14.00 to 14.16. For every rule in the figure the middle 80% alone is wider than that whole range, and the heat map's layouts run from 9.44 to 18.15 shots.

Figure 2
Flat versus fast: expected shots on each distinct layout
81012141618Expected shots on each distinct layoutNear-perfect player (exact)Near-perfect player (exact): middle 80% of layouts 14.00–14.16 shots; range 13.72–14.35; median 14.0613.7214.353-parity + computer finish + latenear-miss cells (strong)3-parity + computer finish + late near-miss cells (strong): middle 80% of layouts 13.74–16.04 shots; range 12.00–16.69; median 15.143-parity by hand3-parity by hand: middle 80% of layouts 14.25–16.28 shots; range 12.61–16.90; median 15.423-parity, densest first3-parity, densest first: middle 80% of layouts 12.61–15.76 shots; range 9.92–16.74; median 14.50Heat mapHeat map: middle 80% of layouts 11.88–15.91 shots; range 9.44–18.15; median 14.039.4418.15
Each row shows one hunter's expected shots on each of the 1,009 distinct layouts: the line runs from its fastest to its slowest layout, the bar covers the middle 80% of layouts, and the vertical tick marks the median. Layouts count once each, not weighted by any hider. The near-perfect player's values are exact; the rules' are estimates from simulated games (rule names as in section 5). The self-play mixture is not shown: its per-layout values were not extracted for this page; its average is 14.18 shots and its slowest layout 14.43.

Flat does not cost speed: the player averages 14.07 shots, fewer than the fastest rule, the heat map (14.42 under the reference player's hider), and only 0.1% of its games need more than 19 (Figure 3).

Figure 3
How long a game takes
Near-perfect player, all layoutsNear-perfect player, corner packHeat map
0%10%20%30%81012141618202210th pct.median90th pct.Heat map (estimated)Heat map (estimated): 8 shots, 0.1%Heat map (estimated): 9 shots, 0.5%Heat map (estimated): 10 shots, 2.1%Heat map (estimated): 11 shots, 5.3%Heat map (estimated): 12 shots, 9.9%Heat map (estimated): 13 shots, 15.1%Heat map (estimated): 14 shots, 18.7%Heat map (estimated): 15 shots, 17.4%Heat map (estimated): 16 shots, 13.8%Heat map (estimated): 17 shots, 10.1%Heat map (estimated): 18 shots, 5.6%Heat map (estimated): 19 shots, 1.3%Heat map (estimated): 20 shots, 0.1%Heat map (estimated): 21 shots, 0.0%Heat map (estimated): 22 shots, 0.0%Near-perfect player, all layoutsNear-perfect player, all layouts: 8 shots, 0.2%Near-perfect player, all layouts: 9 shots, 1.0%Near-perfect player, all layouts: 10 shots, 3.2%Near-perfect player, all layouts: 11 shots, 7.2%Near-perfect player, all layouts: 12 shots, 12.4%Near-perfect player, all layouts: 13 shots, 16.9%Near-perfect player, all layouts: 14 shots, 17.9%Near-perfect player, all layouts: 15 shots, 15.1%Near-perfect player, all layouts: 16 shots, 11.7%Near-perfect player, all layouts: 17 shots, 8.4%Near-perfect player, all layouts: 18 shots, 4.6%Near-perfect player, all layouts: 19 shots, 1.3%Near-perfect player, all layouts: 20 shots, 0.1%Near-perfect player, all layouts: 21 shots, 0.0%Near-perfect player, all layouts: 22 shots, 0.0%Near-perfect player, corner packShot on which the fleet sinksShare of games
The chance of sinking the fleet on exactly each shot: the best player on all layouts and on the corner pack alone (exact, the fleet hidden by its own hider in the first case), and the heat map (estimated, under the reference player's hider). Dashed lines at 11, 14 and 17 shots mark the best player's 10th percentile, median and 90th percentile.

5Hand-written rules on 5×5

Every rule is scored against the reference player (round 1,963), head-to-head and on its worst layout against that player's pace. The rules come in families, with the short names used below:

There is a cliff: every rule wins at most 22.1% of races on its worst layout, the self-play mixture 48.4%, and nothing lands in between (Table 1, plotted in the essay's section 1). The heat map is the best rule head-to-head (45.1%) and the worst on its worst layout (4.1%).

Table 1
Every hand-written rule on 5×5
StrategyHead-to-headWorst layoutBoth adversarialMean shotsSlowest layout
Self-play mixture48.5%48.4%—14.1914.43
Smart 3-parity, three-ship core36.0%22.1%30.8%15.1816.45
3-parity + computer finish + late near-miss cells (light)37.3%20.4%29.4%15.2316.72
3-parity + computer finish37.2%20.1%28.9%15.2516.79
3-parity by hand35.3%19.9%27.6%15.4316.90
3-parity + computer finish + late near-miss cells (strong)37.6%19.6%29.7%15.1816.69
Checkerboard + computer finish + late near-miss cells (strong)34.2%18.7%27.0%15.3416.87
Checkerboard by hand30.8%18.7%25.4%15.7317.12
Checkerboard + computer finish + late near-miss cells (light)33.7%18.3%27.1%15.3916.83
Checkerboard + computer finish33.5%18.1%26.7%15.4216.88
Particle filter41.8%17.8%27.2%14.7316.81
3-parity, densest first †42.5%17.3%28.8%14.7216.74
Checkerboard, densest first †42.5%4.8%19.0%14.6017.88
Heat map45.1%4.1%17.2%14.4218.15
Sorted by worst case; shaded rows are the ones the text discusses most. All rows are against the reference player; for the self-play mixture, head-to-head has each player hiding its own way. Both adversarial: the reference player's fleet sits where the rule hunts worst, and the rule's own fleet where the reference player hunts worst. Mean shots: under the reference player's hider. Slowest layout: expected shots on the layout where the strategy is slowest on average. Rules are estimates from 8,192 to 65,536 games per layout, worst layouts re-checked deeper; the self-play mixture is exact. † Always uses the same diagonal direction, so its result differs among the eight rotated and reflected copies of a layout; we scored one copy per family.

The best rule on both worst-case measures is one you can play by hand, smart 3-parity's three-ship core: 22.1% on its worst layout (21.2% before the zone final) and 16.45 shots on its slowest. In shots the gap is plain: the best player's slowest layout needs 14.35, about 2.1 fewer in a game of about 14. The coin is what lifts the rule: never jumping (20.4%) and always jumping (21.0%) each do worst on a different layout, and drawing one or the other each game hedges between them. The computer version, which hunts the 2 on the color with fewer unshot cells instead, reaches 22.2%.

Of the rules that need a computer, the best are the two 3-parity rules with late near-miss cells: 20.4% (light) and 19.6% (strong) on their worst layouts, 16.72 and 16.69 shots on their slowest.

The "both adversarial" column also lets the rule hide its own fleet where the reference player hunts worst: its worst case rises by 7 to 14 points, to at most 30.8% (smart 3-parity's core).

The cliff deepens as the board grows (Figure 4): from 4×4 to 5×5 the rules that chase density (heat map, particle filter, 3-parity densest first) lose 11 to 15 points of worst case, the two rules played by hand only 2 to 3. The heat map falls from 19.5% to 4.1%.

Figure 4
From 4×4 to 5×5: the rules' worst cases
Rule you can play by handRule that needs a computerHeat-map hunters (need a computer)
0%10%20%30%4×45×53-parity by hand, 4×4: 22.2% on its worst layout3-parity by hand, 5×5: 19.9% on its worst layout3-parity by hand 19.9%3-parity + computer finish + late near-miss cells (strong), 4×4: 26.6% on its worst layout3-parity + computer finish + late near-miss cells (strong), 5×5: 19.6% on its worst layout3-parity + computer finish 19.6%+ late near-miss cells (strong)Checkerboard by hand, 4×4: 21.2% on its worst layoutCheckerboard by hand, 5×5: 18.7% on its worst layoutCheckerboard by hand 18.7%Particle filter, 4×4: 28.5% on its worst layoutParticle filter, 5×5: 17.8% on its worst layoutParticle filter 17.8%3-parity, densest first, 4×4: 28.8% on its worst layout3-parity, densest first, 5×5: 17.3% on its worst layout3-parity, densest first 17.3%Heat map, 4×4: 19.5% on its worst layoutHeat map, 5×5: 4.1% on its worst layoutHeat map 4.1%Win rate on its worst layout
Win rate on the worst layout for the six rules scored on both boards, each raced against that board's near-perfect player (the reference player on 5×5, our near-perfect 4×4 player on 4×4). All values are estimates from simulated games. 3-parity by hand goes from 22.2% to 19.9%, the checkerboard by hand from 21.2% to 18.7%.

The heat map's trap

The heat map is fast on ordinary layouts because it fires where ships usually are. Fewer placements fit over an edge or corner, so it rates those cells low and reaches them last. On the corner pack it needs 18.15 shots instead of 14.42 and wins 4.1% of races; the particle filter and the checkerboard densest first share that worst layout.

Figure 5
The heat map's trap
ABCDE12345
on averageon the corner pack
13141516171819Expected shotsHeat map: 14.42 → 18.15Heat map, on the corner pack: 18.15 shotsHeat map, on average: 14.42 shotsNear-perfect player: 14.07 → 14.03Near-perfect player, on the corner pack: 14.03 shotsNear-perfect player, on average: 14.07 shots
The corner pack: 3s at A1–C1 and A2–C2, the 2 at E1–E2. Shading shows how often a random layout covers each cell, from 21% at a corner to 41% at the center. Right: expected shots on average and on this layout. The heat map wins 4.1% of races here; the best player wins 49.85% against its own finishing times.

The near-perfect hunter's hardest race is on the same layout, yet it still wins 49.85% there: a hunt that randomizes leaves a hider nothing to aim at. On the classic board the same trap holds the heat map to at most about 4 races in 100 (the essay's opening, classic page).

Playing 5×5 yourself. By hand, play 3-parity (worst case 19.9%, the checkerboard 18.7%) and avoid the heat map (4.1% on its worst layout). To hide, lean toward the edges as the near-perfect hider does: a corner 26% of the time against 21% at random, the center 30% against 41%. The essay's How to hunt covers the classic and large boards.

6A mixture built by self-play

Past 5×5 the essay builds its strategies by self-play (section 2): the loop sets its own pace and adds hunts found by search instead of exact best replies. On 5×5 we can check how close that gets. The run tried 22,010 hunts and kept 318, which win 49.97% against their own pace on the worst layout (exact: computed on every layout, not estimated).

Against the reference player it wins 48.54% head-to-head, each player hiding its fleet its own way, and 48.36% on its worst layout; on its own worst layout the reference player still wins 51.32% against the mixture's pace. So the near-perfect player is ahead on every count, by about 1.5 points, and the mixture is a little slower (14.18 shots on average, 14.43 on its slowest layout).

The two hiders barely resemble each other (correlation 0.08 over the 1,009 layouts), yet swapping them moves the head-to-head result by just 0.03 points: both hunters are nearly flat, so the hiding place matters little to either.

The run climbed steadily: on its worst layout, against its final pace, it won 48.26% at round 281, 49.59% at 969 and 49.97% at 1,799, where it hit its budget of 1,800 rounds with gains leveled off. Flat is not perfect, since a random shooter is flat too, but on 5×5 self-play lands within 1.5 points of near-perfect play, the evidence for trusting it on larger boards (10×10 with three ships).

7What context is worth

Real Battleship offers more than the rules-only game: you see which of your ships have been hit, you may know who goes first, and you know where you hid. Context lets you play the score: when behind, a riskier hunt can pay. To price it, we freeze an opponent and compute the exact best reply with and without the extra information.

On 5×5 the frozen opponent is the best player's hider with the replay player's 255 hunts; on 4×4, a separately tightened near-perfect 4×4 player. Each best reply's win rate is an upper bound against an opponent who adapts. The gains shown here are differences of two such win rates, so they are not bounds of either sign, and against an adapting opponent the information could be worth less.

The 5×5 base is looser: its context-free best reply already gains 0.90 points (0.001 on 4×4), and the 5×5 gains come on top.

Figure 6
What context is worth
Gain from each kind of information
5×54×4
00.511.5Points over the context-free best replyWhere you hid your own shipsWhere you hid your own ships, 5×5: 0.12 points0.12 ± 0.03 (5×5)Where you hid your own ships, 4×4: 0.11 points0.11 (4×4)Which of your ships are hit, memorylessWhich of your ships are hit, memoryless, 5×5: 0.25 points0.25 (5×5)Which of your ships are hit, memoryless, 4×4: 0.13 points0.13 (4×4)Which of your ships are hitWhich of your ships are hit, 5×5: 0.38 points0.38 (5×5)Which of your ships are hit, 4×4: 0.23 points0.23 (4×4)Hits counted ship by shipHits counted ship by ship, 5×5: 0.42 points0.42 (5×5)Hits counted ship by ship, 4×4: 0.30 points0.30 (4×4)Which ships are hit + where you hidWhich ships are hit + where you hid, 5×5: 0.78 points0.78 ± 0.03 (5×5)Which ships are hit + where you hid, 4×4: 0.49 points0.49 (4×4)… + taking turns (a variant rule)… + taking turns (a variant rule), 5×5: 1.12 points1.12 ± 0.03 (5×5)… + taking turns (a variant rule), 4×4: 0.88 points0.88 (4×4)Ceiling: knowing when your fleet will fallCeiling: knowing when your fleet will fall, 5×5: 1.57 points1.57 (5×5)Ceiling: knowing when your fleet will fall, 4×4: 1.01 points1.01 (4×4)
A known deadline (5×5): the best hunt for it minus the player
012345Within 8 shots: best hunt for that deadline 0.3%, near-perfect player 0.2% (+0.1 points)8Within 9 shots: best hunt for that deadline 1.8%, near-perfect player 1.1% (+0.6 points)Within 10 shots: best hunt for that deadline 5.8%, near-perfect player 4.4% (+1.4 points)10Within 11 shots: best hunt for that deadline 13.8%, near-perfect player 11.6% (+2.2 points)Within 12 shots: best hunt for that deadline 27.0%, near-perfect player 24.0% (+3.0 points)12Within 13 shots: best hunt for that deadline 44.2%, near-perfect player 40.9% (+3.3 points)Within 14 shots: best hunt for that deadline 61.8%, near-perfect player 58.9% (+3.0 points)14Within 15 shots: best hunt for that deadline 77.2%, near-perfect player 73.9% (+3.2 points)Within 16 shots: best hunt for that deadline 89.9%, near-perfect player 85.6% (+4.3 points)16Within 17 shots: best hunt for that deadline 98.0%, near-perfect player 94.0% (+4.0 points)Within 18 shots: best hunt for that deadline 100.0%, near-perfect player 98.6% (+1.4 points)18Within 19 shots: best hunt for that deadline 100.0%, near-perfect player 99.9% (+0.1 points)4.3 at 16 shotsDeadline: shots allowedPoints
Top: gain in points of win rate over the context-free best reply, against a frozen near-perfect opponent on each board. Rows that use where you hid are estimates on 5×5 (± one standard error, from 64 sampled layouts); everything else is exact, and the memoryless value is a lower bound for the best memoryless hunt. The dashed bars are the ceiling, a bound that uses information the rules never announce. The ceiling shown is for a player who does not know its seat; the taking-turns row's ceiling is 2.12 (5×5) and 1.50 (4×4). Bottom: for each deadline n, how many points more often the best hunt aimed at that deadline (a different hunt for each n) sinks the fleet within n shots than the near-perfect player does, both against the near-perfect hider; exact.

Which ships are hit is worth 0.38 points on 5×5 and 0.23 on 4×4, about a quarter of the ceiling on both boards. A memoryless hunt keeps 66% of that on 5×5 (59% on 4×4), and counting hits ship by ship adds only 0.05. Using where you hid brings it to 0.78, against a ceiling of 1.57 points on 5×5 and 1.01 on 4×4.

Taking turns, which also tells you your seat (worth only 0.03 points alone on 5×5), brings it to 1.12; with the seat known the ceiling is higher, 2.12 points on 5×5 and 1.50 on 4×4.

Why so small?

Every signal about your own fleet acts only through when it falls, and even knowing that exactly is worth only 1.57 points. A hunt aimed at a known deadline beats the player's chance of finishing by then by at most 4.3 points, at 16 shots (Figure 6, bottom). Not knowing the deadline, a player must compromise among these hunts, and that compromise is all the information can buy back.

On 3×3 with two 2-cell ships, knowing which of your ships are hit or sunk and seeing the opponent's shots is worth 0.55 points against the usual equilibrium. Against the equilibrium of the variant in which each player knows its seat, whose hunt depends on where it hid, it is worth 16.6: that opponent's shots give its layout away (Aumann and Maschler; see Hart 2006).

Table 2
What context is worth and costs on 5×5
InformationGain (points)HistoriesSettledTime per reply
None (rules only)———6–8 seconds
Same, memoryless+0.2510,344—18 minutes
Which of your ships are hit+0.386,9922,30945 minutes
Hits counted ship by ship+0.4285,74458,31812.0 hours
Which ships are hit + where you hid+0.78 ± 0.0312,9515,8002.0 hours *
Gains are over the context-free best reply, against the frozen opponent above. The rules-only reply is one pass over the 181 million states of knowledge. Histories: distinct histories of the signal that the exact reply tracks on top of the states of knowledge. Settled: histories in which the opponent's finishing time is already certain, which a reply aimed at that deadline settles at once. The memoryless row is one good memoryless hunt, found by a simpler calculation and scored exactly; the best one could gain a little more. * One batch of about 20 sampled layouts; batches took 1.2 to 2.1 hours. Memory: about 100 GB for the plain graph (up to 185 GB during a pass) and 256 to 285 GB at peak for the context runs, all on the same 56-core machine type.

Context is also expensive (Table 2). A signal splits every state by its history, so the exact reply for the simplest signal, which ships are hit, takes 45 minutes, roughly 340 to 450 times as long as without context; the study cost about $142 of cloud computing. That is why the essay drops context beyond 5×5.

8Smaller boards, open questions, reproducing

Smaller boards

On 4×4 the same fleet hides 804 ways (103 distinct), and our near-perfect 4×4 player finishes in 11.23 shots on average. Its exact best reply, which picks a hiding place and the hunt that goes with it, wins 50.14%; a reply that hides and hunts independently gains under 0.02 points, so almost all of the 0.14 comes from coupling (essay, section 1). Measured separately against the tightly converged 4×4 player of an earlier context study, a reply that tunes its hunt to where it hid its own fleet gains 0.12 points, and 0.30 if it also chooses that hiding place. The later context study (section 7) froze another tightened 4×4 player, against which the context-free hunting reply gains 0.001 points.

On 3×3 we used a different fleet, two 2-cell ships ({2,2}), which hides 44 ways (7 distinct). That game is solved to within 0.3 points: the equilibrium hunter is a lottery over 264 fixed hunts and always finishes in 4 to 8 shots, while any fixed firing order can be forced to fire all nine cells and so wins 0% on its worst layout.

Open questions

Reproducing and replaying

The graph rebuilds identically in about 10.5 minutes. The best player is stored as its hider and its exact finishing times on every layout; the replay player's 255 hunts (re-derived bit for bit from their recipes), its recorded shots on all 8,000 layouts and every context strategy are stored and replay exactly.

No playable 5×5 opponent is on these pages; the essay's Replay 1 shows the replay player at work.

The page draws on four strong players: three snapshots of the one best-reply run, frozen at different rounds for different studies, with average finishing times within 0.01 shots, and the self-play mixture (Table 3).

Table 3
Four strong 5×5 players
PlayerRoundFixed huntsMean shotsWorst layoutBest reply: hunt only / jointUsed for
Best player2,12012,60914.0749.85%+0.85 / +1.44Sections 3 and 4
Reference player1,96311,08314.06—+0.61 / — †Rules (section 5), self-play (section 6)
Replay player2,16425514.0749.79%+0.90 / ≥ +1.53 ‡Opening, replays, context (section 7)
Self-play mixture1,799 §31814.1849.97%— / —Section 6
The first three are snapshots of one run. Fixed hunts: for the best player, the pool of hunts found by its round; for the reference player, the count recorded with that snapshot; for the replay player and the self-play mixture, the hunts that carry weight, of 1,534 logged and 22,010 tried. Mean shots: with the fleet hidden by the player's own hider. Worst layout: win rate on its worst layout against its own exact finishing times (section 4). — Not measured. † A projection puts it at +0.6 to +1.1 points. ‡ A lower bound: the best of 77 hiding places tried, each with its best hunt. § Round of its own self-play loop. The replay player's hide-only reply gains 0.21 points, and its worst case against the pace it was built for is 49.75%.
Sources and caveats

Every number on this page is read by the page's build script from eight data files, which a separate script extracted from the project's results and checked against the values recorded there:

Smart 3-parity's three-ship core, with its zone final, was scored later with the same protocol, by an engine that reproduces the earlier runs bit for bit when the zone final is switched off; the build script reads that run's results file directly, and the earlier run's for the value before the zone final.

The build script also reads three project files directly: the 5×5 context report's main table (the ceiling for a player who knows its seat, 2.12 and 1.50 points, and the replay player's joint reply, at least 1.53), the self-play comparison (the mixture's 14.19 shots under the reference player's hider) and the essay's source text (the 4×4 decoupled reply). A few numbers come from the project's notes: the round times and milestones of the best-reply loop (the 5×5 equilibrium ledger), the cost of the targeting rule on 4×4 and on one 5×5 hunt (the targeting cross-check), and the replay and storage checks (the 5×5 context report). The loop that built the player needed about 326 to 381 GB of memory, on a 448 GB machine. A round took about 14 minutes at first, almost all of it spent walking the graph, and about 2 minutes after a move to a faster machine type and batching.

Exact: layout counts and coverage; every number about the near-perfect players (expected shots per layout, finishing times, worst cases, best replies), including the best player's 49.87% guarantee, which the linear program proves against the pace the run was using; the self-play mixture's numbers, including its 49.97%; the context values that do not use where you hid; the deadline curve. Estimated: every hand-written rule's number (8,192 to 65,536 games per layout, worst layouts re-checked deeper; a standard error of at most about 0.05 points on a worst case), and the context values that use where you hid (64 sampled draws over 59 distinct layouts; ± about 0.03 points). Projected: the reference player's full best reply (0.6 to 1.1 points). Bounds: the context ceiling uses information the rules never announce. Every context best reply is computed against a frozen opponent, so its win rate is an upper bound against one who adapts, and (since the replies, like the opponent, finish what they hit) a lower bound on an unrestricted reply to that same opponent. The gains reported are differences of two such win rates and are not bounds of either sign. The replay player's joint reply (at least 1.53 points) is the best of 77 hiding places tried, a lower bound.

Caveats: three snapshots of one run appear here (Table 3), and each number names its player. All 5×5 guarantees hold among hunts that finish what they hit. Shot counts on 5×5 are means. Times and memory were measured on a 56-core cloud machine type, except the first rounds of the best-reply loop, which ran on a slower machine type (above); dollar costs are estimates from the machines' logs, not bills. The essay's sources hold the reference list.

← Back to Optimal Battleship