Class AiService

java.lang.Object
com.edu.xmum.CST210.Service.AiService
All Implemented Interfaces:
IAiService

public class AiService extends Object implements IAiService
Implementation of the IAiService interface. Provides methods to handle AI-related logic within the maze.
  • Constructor Details

    • AiService

      public AiService(IMazeService mazeService, IPlayerModel playerModel, IPlayerModel aiModel)
      Constructor for AiService. Uses dependency injection to initialize the maze service, player model, and AI model.
      Parameters:
      mazeService - The maze service instance.
      playerModel - The player model instance.
      aiModel - The AI model instance.
  • Method Details

    • moveAi

      public void moveAi()
      Moves the AI towards the player using the A* algorithm.
      Specified by:
      moveAi in interface IAiService
    • isPlayerCaught

      public boolean isPlayerCaught()
      Checks if the AI has caught the player.
      Specified by:
      isPlayerCaught in interface IAiService
      Returns:
      True if the AI has caught the player, false otherwise.
    • getAiModel

      public IPlayerModel getAiModel()
      Gets the AI model instance.
      Specified by:
      getAiModel in interface IAiService
      Returns:
      The AI model instance.
    • reset

      public void reset()
      Resets the AI's position to its initial start position.
      Specified by:
      reset in interface IAiService