Search code examples
artificial-intelligencegame-enginegame-developmentminimaxheuristics

Can I minimax a battleship 2 player game?


I have a game project to implement and was thinking of building a battleship game (https://en.wikipedia.org/wiki/Battleship_(game)).

The project requires me to build an AI computer that can run a minimax algorithm.

Is it possible to implement minimax on this kind of game?


Solution

  • Short answer: No.

    The minimax algorithm needs some sort of evaluation of the gamestate in every node. In battleship you don't have all information as a player or AI (opponent ships are not known) which makes it impossible to do this. You could of course cheat and let the AI test all possible moves and find the hidden ships X moves ahead, but I would say this is against the rules. The AI would then always find the ship and always make hits which would also make it very boring to play against.

    You can find some inspiration for example here on other algorithms to use.