Java Game: Using minimax or similar algorithm for AI battles

Game Info:

  • Type: grid based ship game; where ships are one-directional (meaning they can only use the allowed moves in the direction it is facing)
  • Allowed Directions: NORTH,SOUTH,WEST,EAST
  • Allowed Moves: FORWARD, LEFT, RIGHT (LEFT and RIGHT moves at diagonals)
  • Allowed Total Moves per Turn: 4 (3 for bigger ships) // (all ships play their moves in the same turn)
  • Players allowed: 2+ (as many as server can hold)
  • Shooting: ships can shoot only from the left or right side of ship (player ships will have to be on the same X position or same Y position to hit each other (cannonballs go a max of 4 tiles)).

Example video:

With the provided information I would like to create a battling algorithm for when player ships get close to AI; where AI will battle with player.

Algorithm plan:

  1. Get players current position and facing on board
  2. Run simulation on every possible moves for player (LEFT,RIGHT,FORWARD move for each of the 4 slots) and check which route AI has most chance of damaging ship
  3. Have AI use route where it causes most damage.

I was thinking of some type of minmax algorithm; is there a better algorithm I could use? Also; could someone provide some sort of implementation so I know how to set it up, as I don’t have experience with different types of algorithms.

public class State {
    public Position playerPosition;
    public Position aiPosition;
    public VesselFace playerFace;
    public VesselFace aiFace;
    public int playerDamage;
    public int aiDamage;
    public boolean aiTurn;
    public State parentState;
    public State(Position playerPosition, VesselFace playerFace, int playerDamage, Position aiPosition, VesselFace aiFace, int aiDamage, boolean aiTurn) {
        this.playerPosition = playerPosition;
        this.aiPosition = aiPosition;
        this.playerFace = playerFace;
        this.aiFace = aiFace;
        this.aiTurn = aiTurn;
        this.aiDamage = aiDamage;
        this.playerDamage = playerDamage;