Class PlayerBreadthFirstAI

  • All Implemented Interfaces:
    PlayerAI, Constants, java.lang.Runnable

    public class PlayerBreadthFirstAI
    extends AI
    implements PlayerAI, Constants
    This is an implementation of the Breadth-First search algorithm with multiple objectives
    • Constructor Detail

      • PlayerBreadthFirstAI

        public PlayerBreadthFirstAI​(Scene scene,
                                    Player player)
        Initialize the algorithm
        Parameters:
        scene - The scene the AI is in
        player - The player being controlled by AI
    • Method Detail

      • search

        public boolean search​(State searchInitial,
                              State searchGoal)
        Find a path to the goal
        Specified by:
        search in interface PlayerAI
        Parameters:
        searchInitial - The start point
        searchGoal - The goal
        Returns:
        Returns true if a path to the goal is found or false otherwise
      • addDestination

        public void addDestination​(State destination)
        Add a destination to the AI
        Specified by:
        addDestination in interface PlayerAI
        Overrides:
        addDestination in class AI
        Parameters:
        destination - The state containing the destination
      • removeKeyDestination

        public void removeKeyDestination​(int x,
                                         int y)
        Remove the picked up key from destinations if it is there
        Overrides:
        removeKeyDestination in class AI
        Parameters:
        x - The x coordinate of the key
        y - The y coordinate of the key
      • sortDestinations

        public void sortDestinations()
        Sort the destinations by importance, if the importance is the same then sort them by distance
        Specified by:
        sortDestinations in interface PlayerAI
      • run

        public void run()
        Run the steps in a loop
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class AI