Thursday, March 15, 2012

Battleship Ship Placement - Part II

Previously I showed numerical PDF's for the placement of a ship. Now I am going to attack the analytical solution.

I'm defining the PDF as the possibility that a shot taken at a particular (i,j) coordinate on the board could result in a hit.  The simplest example is at a corner because there can only be two ships there.

 For a two by 1 ship the possible number of ships at a given (i,j) are laid out in the following image.
The probabilities are then: For a two by 1 ship the probabilities are:
These were tabulated up to the size of the ship, after that it repeats. For a ship of length two:

For a ship of length three:

 For a ship of length four:

 For a ship of length five:

 
The next issues is what happens to the PDF once we take a shot.

No comments:

Post a Comment