The Linear Theory of Battleship
thevirtuosi.blogspot.com
thevirtuosi.blogspot.com
My personal experience working with Battleship AI is to play the highest probability. As a human your best option is to place ships closer to the middle and not on edges because of how a person reacts when hitting a ship.
Once a person "hits" the ship they know only that they've made a hit, not what they hit or whether they landed on the middle/side etc. By placing ships along the borders you're essentially reducing the problem space for them to guess. When you ship is in the middle-ish areas the player has a 25-50% chance of hitting the next square of the ship depending on what location they hit at. When your ship is in the corner or side there is only 2 or 3 options before they begin their guessing... (I hope that makes sense)
The AI that the author has presented is ideal for reducing the problem space that exists on the board by segmenting the possible locations that the ship will fit in. Once the problem space is small enough it makes it easy to pick out where ships are hiding.
This is where this falls down. Since I know it's optimal for you to choose one of those three middle squares, I do not want any boat configuration that covers two of them, so I will always pick either the far left patrol boat or the far right patrol boat.
Except if I always pick the far left or right, why would you ever pick middle to start? You wouldn't. Finding an equilibrium to these games is hard, but I'd guess a 50/50 mixed strategy of placing a boat either on the extreme right or extreme left and a 50/50 guessing strategy of B1 or D1 would be a Nash Equilibrium of this game. And the boat arrangement would look nothing like what you'd expect from a random arrangement, in fact there'd be a giant black probability square right in the middle of the board.
I worry people don't believe this, so let me use a silly outlandish example to prove my point.
Here's a game: Suppose we have a countably infinite number of boxes, all numbered. You pick one to hide under, and I have to find you by looking under boxes which I choose, one at a time. I get to look at as many boxes as I like until I find you or get tired and go home.
Under box 1 is famed astronomer Neil deGrasse Tyson, who was spying on you with his (perhaps magical) telescope all morning. He will gladly tell me where you hid.
I now announce my strategy for this game, namely, to pick Box 1 and ask Tyson how to win.
Will you now respond with the original, "From the point of view of game theory, this is not an optimal strategy since it merely invites the opponent to avoid box 1. ..."?
The point of this silly example game is that randomized strategies aren't necessarily helpful for certain classes of games where one strategy gives you disproportionate information about the state of the game.
Guess my number games and battleship games risk being very similar to my extreme illustrative example, but I'll admit I don't know how much.
Bottom line: I just resent the insistence that good game theorists dogmatically REQUIRE randomness in all competitive situations. This is not necessarily the case.
http://en.wikipedia.org/wiki/Pure_strategy#Pure_and_mixed_st... http://en.wikipedia.org/wiki/Strategic_dominance
It is obvious that if there is a dominant pure strategy, then that is the strategy to play, and there is no need for a mixed strategy.
Anyone with elementary game theory knows this, and, really, no 'good game theorist' is going to 'dogmatically' assert otherwise.
I tend to place the large ships as close together as rules allow, in order to leave as much freedom to place the smaller ships. Something like (if ships can lie along a border; periods are squares where no ship can lie):
#####.####
..........
###.###..
........I'd be more interested to see optimal play solved for that version.
A knowledgeable opponent will have a tendency to place ships such that they're not touching each other, else the second ship might be hit while trying to sink the first ship.
A full analysis of the problem would also generate optimized search patterns, and explore possible countermeasures.
It's also not clear whether to dedicate your turns to sinking ships that have been hit, or searching for new ships. If and when turns can accomplish both, an advantage is gained.
Another interesting aspect would be to look a dataset of ship placement and search strategies from human games.
What first caught my attention was that there were four squares between the missed shots, which cannot contain a carrier and thus should be black.
However, upon further examination, it occurred to me that the squares under the misses should also be black.
I will add that anyone who has actually played battleship even casually knows that placing one or more ships in the corners is a good defensive strategy because shots placed in the corner return the least amount of information to your opponent regardless of whether they hit or miss.
Finally, I was somewhat surprised by the lack of a search strategy which recognized the makeup of the opponents fleet. By eliminating spaces in groups of three, one gains information about the location of 80% of the opponents fleet (i.e. sub, cruiser, battleship, and carrier) while still having a reasonable chance of finding the PT boat - and certainly a better chance than the haphazard pattern shown in the diagram.
Essentially it weighs the board and creates what I called a Probability Map to determine where ships lie. My tests gave the computer ~48% win rate against myself and ~60% against random friends. Its accuracy is double that of a random shooting AI.
I can go into more details about the advantages and disadvantages of the algorithm here if there's any interest. I'd have posted it a couple months ago when I published it had I known there was interest in such a project...
IIRC, Bayes prof was very similar to the concept of the game, by throwing pebbles on a table and trying to predict where they land.
http://www.cores2.com/files/FinalResearchPaper.pdf
Another page:
http://blog.codeus.net/a-lost-battleship-ai-and-probability-...
Both have source code.
I've always wanted starcraft to be scriptable so it would be code vs code instead of twitch vs twitch. But that is a big first step. So maybe some battleship?