# How to Win at Battleship

Universal Studios hopes to rake in millions of dollars this weekend with the release of its new action film *Battleship*, and sales of the classic board game are expected to get a nice boost, too. As readers may recall, the game play is simple: Each player arranges five ships—an aircraft carrier, battleship, cruiser, submarine, and destroyer—on a ten-by-ten grid of squares and attempts to “sink” his opponent’s ships by calling out the squares where he believes his enemy’s ships are hiding. Most players approach the game as essentially one of chance, targeting squares at random and hoping for a “hit.” But is there a better strategy? If a friend challenges you to a nostalgic game of Battleship this weekend, is there a way to increase the chances that your fleet will emerge victorious?

There is. Nick Berry, a technology consultant and president of DataGenetics, a data mining company based in Seattle, has meticulously laid out several strategies that will improve your chances of sinking your opponent’s ships before she sinks yours. These methods are battle-tested: Berry created computer algorithms to employ his strategies in hundreds of millions of simulations so he could calculate their respective success rates.

Berry started by assessing the strategy most players intuit, which he refers to as Hunt/Target. The computer begins in Hunt mode—that is, firing at random until it hits a ship. When it has a hit, it focuses fire on the adjacent squares. Once the ship is sunk, the computer reverts back to Hunt mode until it hits another target. In Berry’s simulations, it took an average of 66 moves to sink an opponent’s battleship. It’s a serviceable approach, but there’s still a lot of random guessing involved.

To improve upon the Hunt/Target method, Berry devised a tactic that combines Hunt mode with the concept of mathematical parity. Think of it this way: Imagine if the board were color-coded like a checkerboard, with white and blue squares. Even the smallest ship—the destroyer—covers two squares, and would therefore have to rest on both a white and a blue square. Fire only at blue squares and you will eventually hit every ship at least once. This method effectively allows you to reduce the number of targets on the board by half when you’re in Hunt mode. (When you register a hit you enter Target mode, and both blue and white squares are in play until you sink the ship.) This strategy yields a slightly better average than regular Hunt/Target mode: an average of 65 moves to sink your opponent’s fleet.

Berry’s *most* efficient approach to Battleship uses a probability density function, which takes into consideration the different ways the ships can fit across the board. Here, Berry’s algorithm considers all of the possible configurations of the five ships and calculates a probability that any given square is occupied by a ship. At the outset of the game, obviously, the ships could be anywhere—there isn’t much difference in the probabilities for each square. But as the game progresses, you eliminate more and more squares from the board, and also reduce the number of possible configurations—the five-square aircraft carrier can’t be hiding in a four-square stretch of sea. A human player can’t realistically calculate the probabilities for each square as accurately as Berry’s model, but she can keep in mind the underlying strategy here. By considering the length of each ship that remains on the board and aiming for the area of the board that has the highest probability of containing those ships, you greatly improve your hit rate. When Berry’s computer used this approach, he reduced the average number of moves per game to 44 moves.

Of course, Battleship remains a game of chance. When I spoke with Berry, he pointed out that there’s no approach that will allow man or machine to win every time out. As a testament to the game’s random nature (and surely to some human error), my small sampling of three games using Hunt/Target, Hunt/Target with parity, and an attempt at using probability density yielded games lasting 38, 41, and 55 moves respectively. I won two out of three times.

Berry, who spent 10 years working in Microsoft’s Casual Game division (which now produces the Xbox) enjoys analyzing classic board games. You can find his strategies for Risk, Candyland, and Chutes & Ladders—the former two are also being turned into feature films—on his blog.