java.lang.Object
com.pixelmonmod.pixelmon.battles.controller.ai.BattleAIBase
Direct Known Subclasses:
AggressiveAI, NoOpAI, RandomAI

public abstract class BattleAIBase extends Object
Base class for battle AI.
  • Constructor Details

    • BattleAIBase

      public BattleAIBase(BattleParticipant participant)
      Initializes the AI.
      Parameters:
      participant - The participant controlled by the AI.
  • Method Details

    • getNextMove

      public abstract MoveChoice getNextMove(PixelmonWrapper pw)
      Gets the move the AI will make next.
      Parameters:
      pw - The Pokémon to make a move with.
      Returns:
      The move the AI will make next.
    • getNextSwitch

      public abstract UUID getNextSwitch(PixelmonWrapper pw)
      Gets a Pokémon to switch to when forced to switch.
      Parameters:
      pw - The Pokémon switching out.
      Returns:
      The ID of the Pokémon to switch to.
    • getFaintedPokemonToRevive

      public abstract UUID getFaintedPokemonToRevive()
      Gets a Pokémon to revive when forced to revive.
      Returns:
      The ID of the Pokémon to switch to.
    • registerMove

      public void registerMove(PixelmonWrapper user)
      Registers an enemy move into the AI's memory.
    • registerSwitch

      public void registerSwitch(PixelmonWrapper switchOut, PixelmonWrapper switchIn)
      Registers an enemy switch-in into the AI's memory.
    • getChoices

      protected List<MoveChoice> getChoices(PixelmonWrapper pw)
      Gets all choices that the AI can make during the turn.
      Parameters:
      pw - The Pokémon to get choices for, or null if the AI is forced to switch.
      Returns:
      A list of all choices that the AI can make during the turn.
    • getAttackChoices

      protected List<MoveChoice> getAttackChoices(PixelmonWrapper pw)
      Gets all attack choices the AI can make during the turn.
      Parameters:
      pw - The Pokémon to get choices for.
      Returns:
      A list of all attack choices that the AI can make during the turn.
    • getAttackChoicesOpponentOnly

      protected List<MoveChoice> getAttackChoicesOpponentOnly(PixelmonWrapper pw)
      Gets all attack choices that do not specifically target allies.
      Parameters:
      pw - The Pokémon to get choices for.
      Returns:
      A list of attack choices that the AI can make during the turn.
    • getSwitchChoices

      public List<MoveChoice> getSwitchChoices(PixelmonWrapper pw)
      Gets all possible switch choices the participant can make.
      Parameters:
      pw - The Pokémon making a move, or null if switching in from a fainted Pokémon.
      Returns:
      A list of All possible switch choices the participant can make.
    • getPossibleSwitchIDs

      protected List<UUID> getPossibleSwitchIDs()
      Gets the IDs of all Pokémon in the participant's party that can switch in.
      Returns:
      The IDs of all Pokémon in the participant's party that can switch in.
    • getPossibleReviveIDs

      protected List<UUID> getPossibleReviveIDs()
      Gets the IDs of all Pokémon in the participant's party that can be revived.
      Returns:
      The IDs of all Pokémon in the participant's party that can be revived.
    • getRandomAttackChoice

      protected MoveChoice getRandomAttackChoice(PixelmonWrapper pw)
      Gets a random attack choice to use.
      Parameters:
      pw - The Pokémon to make a move with.
      Returns:
      The move the AI will make next.
    • weightOffensiveMove

      protected void weightOffensiveMove(PixelmonWrapper pw, MoveChoice choice)
      Determines the weight of offensive moves.
      Parameters:
      pw - The Pokémon using the move.
      choice - The move choice being evaluated.
    • weightOffensiveMove

      protected void weightOffensiveMove(PixelmonWrapper pw, MoveChoice choice, List<PixelmonWrapper> allies)
      Determines the weight of offensive moves.
      Parameters:
      pw - The Pokémon using the move.
      choice - The move choice being evaluated.
      allies - The allies of the Pokémon in battle.
    • weightOffensiveMoves

      protected void weightOffensiveMoves(PixelmonWrapper pw, List<MoveChoice> choices)
      Weights all offensive moves in a list of choices.
      Parameters:
      pw - The Pokémon deciding a move.
      choices - The move choices the Pokémon has.
    • getWeightedOffensiveChoices

      protected List<MoveChoice> getWeightedOffensiveChoices(PixelmonWrapper pw)
      Weights and returns all offensive move choices of a Pokémon.
      Parameters:
      pw - The Pokémon to get choices for.
      Returns:
      A list of offensive move choices that can be made by the Pokémon.
    • getBestAttackChoices

      public List<MoveChoice> getBestAttackChoices(PixelmonWrapper pw)
      Finds the strongest offensive move choices in the situation. This should only be called when already in simulate mode.
      Parameters:
      pw - The Pokémon to get the best move choices for.
      Returns:
      The strongest offensive move choices in the situation.
    • getBestAttackChoices

      public List<List<MoveChoice>> getBestAttackChoices(List<PixelmonWrapper> pokemonList)
      Gets the best attack choices for multiple Pokémon.
      Parameters:
      pokemonList - The Pokémon to get attack choices for.
      Returns:
      A list of attack choices for each specified Pokémon.
    • getMoveset

      public List<Attack> getMoveset(PixelmonWrapper pw)
      Returns the moveset that the AI thinks a Pokémon has.
      Parameters:
      pw - The Pokémon to get moves for.
      Returns:
      The moveset that the AI thinks the Pokémon has.
    • weightRandomMove

      public void weightRandomMove(PixelmonWrapper pw, MoveChoice userChoice, List<MoveChoice> possibleChoices)
      Weights a move that randomly selects from an assortment of moves.
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move with random selection.
      possibleChoices - The possible moves that the move can select.
    • weightFromUserOptions

      public void weightFromUserOptions(PixelmonWrapper pw, MoveChoice userChoice, List<MoveChoice> bestChoicesBefore, List<MoveChoice> bestChoicesAfter)
      Weights a move based on the amount of turns the user takes to KO the opponent after using the move.
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move being used.
      bestChoicesBefore - The user's best choices before using the move.
      bestChoicesAfter - The user's best choices after using the move.
    • weightFromUserOptions

      public void weightFromUserOptions(PixelmonWrapper pw, MoveChoice userChoice, List<MoveChoice> bestChoicesBefore, List<MoveChoice> bestChoicesAfter, boolean weightNegative)
      Weights a move based on the amount of turns the user takes to KO the opponent after using the move.
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move being used.
      bestChoicesBefore - The user's best choices before using the move.
      bestChoicesAfter - The user's best choices after using the move.
      weightNegative - Whether to weight negatively if the move causes the user to take more turns to KO the opponent.
    • weightFromOpponentOptions

      public void weightFromOpponentOptions(PixelmonWrapper pw, MoveChoice userChoice, List<List<MoveChoice>> bestChoicesBefore, List<List<MoveChoice>> bestChoicesAfter)
      Weights a move based on the amount of turns the opponent takes to KO the Pokémon before and after using the move.
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move being used.
      bestChoicesBefore - The opponent's best options before using the move.
      bestChoicesAfter - The opponent's best options after using the move.
    • weightFromOpponentOptions

      public void weightFromOpponentOptions(PixelmonWrapper pw, MoveChoice userChoice, List<List<MoveChoice>> bestChoicesBefore, List<List<MoveChoice>> bestChoicesAfter, boolean weightNegative)
      Weights a move based on the amount of turns the opponent takes to KO the Pokémon before and after using the move.
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move being used.
      bestChoicesBefore - The opponent's best options before using the move.
      bestChoicesAfter - The opponent's best options after using the move.
      weightNegative - Whether to weight negatively if the move causes the opponent to KO the Pokémon faster.
    • weightTypeChange

      public void weightTypeChange(PixelmonWrapper pw, MoveChoice userChoice, List<Element> possibleTypes, List<MoveChoice> bestUserChoices, List<MoveChoice> bestOpponentChoices)
      Weights the effectiveness of a type change.
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move being used.
      possibleTypes - The possible types the Pokémon can become.
      bestUserChoices - The best user choices before the type change.
      bestOpponentChoices - The best opponent choices before the type change.
    • weightTypeChange

      public void weightTypeChange(PixelmonWrapper pw, MoveChoice userChoice, List<Element> possibleTypes, PixelmonWrapper target, List<MoveChoice> bestUserChoices, List<MoveChoice> bestOpponentChoices)
      Weights the effectiveness of a type change.
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move being used.
      possibleTypes - The possible types the Pokémon can become.
      target - The Pokémon whose type is being changed.
      bestUserChoices - The best user choices before the type change.
      bestOpponentChoices - The best opponent choices before the type change.
    • weightSingleTypeChange

      public void weightSingleTypeChange(PixelmonWrapper pw, MoveChoice userChoice, List<Element> newType, PixelmonWrapper target, List<MoveChoice> bestUserChoices, List<MoveChoice> bestOpponentChoices)
      Weights the effectiveness of a type change.
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move being used.
      newType - The type that the target will become.
      target - The Pokémon whose type is being changed.
      bestUserChoices - The best user choices before the type change.
      bestOpponentChoices - The best opponent choices before the type change.
    • weightStatusOpponentOptions

      public void weightStatusOpponentOptions(PixelmonWrapper pw, MoveChoice userChoice, PixelmonWrapper target, StatusBase status, List<PixelmonWrapper> opponents, List<MoveChoice> bestOpponentChoices)
      Weights a status based on the damage output of the opponent before and after applying it.
      Parameters:
      pw - The Pokémon using the move.
      userChoice - The move to be used.
      target - The Pokémon targeted by the status.
      status - The status being applied.
      opponents - The opponents of the move's user.
      bestOpponentChoices - The best choices of the opponent.