CS120 Battleship



Water Ship Hit Miss



Your fleet Enemy fleet







This battleship game uses an AI algorithm written by JT Schafer during a homework assignment for CS120 (Intermediate Programming) at Johns Hopkins University. The AI generates hundreds of thousands of randomized gameplay boards, and then eliminates boards that don’t correspond to the known positions of the opponent’s ships. The AI then calculates the square with the highest chance of containing a ship by examining the remaining boards. This version uses 250,000 randomized boards for the elimination process. This is enough to get through most of the game without making any bad moves, even though a far greater number is required to achieve optimal results.

The original homework assignment was a command line application written in C++ by JT Schafer, Owen Whitmore and Patrick Lau. This game uses the original AI from that project.