I’ve been playing battleship a lot recently. My friends and I have given up on playing pool and are pretty much exclusively playing this game.
After winning a ton of games by luck, I figured I do could even better using a strategy.
Since there are a few different rulesets, here’s a quick overview of the ruleset I was playing with on GamePigeon’s iMessage version of the game.
- The board is 10×10 squares.
- There are 1 len-4, 2 len-3, 3 len-2, and 4 len-1 ships.
- You cannot place ships adjacent or diagonal to another ship.
An obvious strategy for Battleship is to shoot where the ships are most likely to be placed.
To calculate this probability, we can enumerate over all the possible ships on the board.
While we do this, count the number of times a ship occupies each specific square. Then, we can make that array into a heat map that shows the probability of a ship being in that particular square.
Since there are 1 len-4, 2 len-3, 3 len-2, and 4 len-1 ships, we will increment each square by the number of ships that could be placed there. That’s why the squares are incrementing by values other than 1.
We end up with a heatmap that looks like this:

We can do this mid-game to get a heatmap specific to that board:

We’ll be referring to these values as “probability scores” from here on out. Just rem