News

Seattle man devises algorithm to help you win at Battleship

Original photo: http://www.flickr.com/photos/angelicarenee337/5572931456/

SEATTLE — A Seattle man says he's found a way to give you a better shot at winning the classic board game Battleship.

Nick Berry, the president of Seattle-based DataGenetics, recently devised a computer algorithm that increases a player's odds of hitting a target on the board.

Here's the gist: Berry calls the most common strategy Hunt/Target mode -- that is, players fire random shots until they hit something (Hunt) and then zero in on nearby squares once a hit happens (Target). Berry, according to Slate, found that strategy required an average of 66 moves to sink an opponent's battleship.

To better his odds, Berry set his algorithm to split the board up into a checkerboard-like pattern. Since every battleship has to touch at least two squares, dividing the board that way essentially halves the number of potential targets in Hunt mode. It also led to a slightly better sunk-battleship average: 65 moves.

But there's an even better way, as Slate writer Aisha Harris explains:

<span>"Berry's </span><em>most</em><span> 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."</span>

Photo credit: Angelica Whatserface / Flickr

0