Battleship Game in Java Console with Opponent AI
The size of the board and the amount of ships can be customised.
Before you start playing, you need to place your ships on the left board.
- Find the letter of the ship you want to place (e.g. A, B, ...)
- Select an orientation (H - Horizontal, V - Vertical)
- Select a coordinate (left upper corner, beginning with the letter, e.g. F4)
Enter all letters and numbers in the console.
Example:
Place Submarine horizontally beginning in B3 -> SHB3
Start guessing a location on the right board and enter the coordinate (beginning with the letter) in the console.
A water tile is marked with ~.
After your guess, the AI also takes a guess and it is your turn again.
You win if you manage to locate all of your opponent's ships.
Before playing, the program generates a random ship arrangement.
While playing, the Opponent AI has two different modes:
- Pick a random spot until there is a ship
- Pick one of the 4 random spots around the ship until the orientation is obvious
After that, uncover the whole ship