Class BattleAIBase
java.lang.Object
com.pixelmonmod.pixelmon.battles.controller.ai.BattleAIBase
- All Implemented Interfaces:
BattleAILogic
- Direct Known Subclasses:
AggressiveAI,NoOpAI,RandomAI
Base class for battle AI.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.mojang.serialization.MapCodec<? extends BattleAIBase> protected final BattleAIType<?> Fields inherited from interface com.pixelmonmod.pixelmon.battles.controller.ai.BattleAILogic
CODEC -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBattleAIBase(com.mojang.serialization.MapCodec<? extends BattleAIBase> codec, BattleAIType<?> type) -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.MapCodec<? extends BattleAIBase> codec()protected List<MoveChoice> Gets all attack choices the AI can make during the turn.protected List<MoveChoice> Gets all attack choices that do not specifically target allies.Finds the strongest offensive move choices in the situation.protected List<MoveChoice> Gets all choices that the AI can make during the turn.protected PokemonMemoryFinds the memory of a certain Pokémon.Returns the moveset that the AI thinks a Pokémon has.getPossibleReviveIDs(BattleParticipant participant) Gets the IDs of all Pokémon in the participant's party that can be revived.protected MoveChoiceGets a random attack choice to use.Gets all possible switch choices the participant can make.Weights and returns all offensive move choices of a Pokémon.BattleAIType<?> type()voidweightFromOpponentOptions(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.voidweightFromUserOptions(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.protected voidweightOffensiveMove(PixelmonWrapper pw, MoveChoice choice) Determines the weight of offensive moves.protected voidweightOffensiveMove(PixelmonWrapper pw, MoveChoice choice, List<PixelmonWrapper> allies) Determines the weight of offensive moves.protected voidweightOffensiveMoves(PixelmonWrapper pw, List<MoveChoice> choices) Weights all offensive moves in a list of choices.voidweightRandomMove(PixelmonWrapper pw, MoveChoice userChoice, List<MoveChoice> possibleChoices) Weights a move that randomly selects from an assortment of moves.voidweightSingleTypeChange(PixelmonWrapper pw, MoveChoice userChoice, List<net.minecraft.core.Holder<Type>> newType, PixelmonWrapper target, List<MoveChoice> bestUserChoices, List<MoveChoice> bestOpponentChoices) Weights the effectiveness of a type change.voidweightStatusOpponentOptions(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.voidweightTypeChange(PixelmonWrapper pw, MoveChoice userChoice, List<net.minecraft.resources.ResourceKey<Type>> possibleTypes, PixelmonWrapper target, List<MoveChoice> bestUserChoices, List<MoveChoice> bestOpponentChoices) Weights the effectiveness of a type change.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.pixelmonmod.pixelmon.battles.controller.ai.BattleAILogic
getBestAttackChoices, getFaintedPokemonToRevive, getNextMove, getNextSwitch, getTopNAttackChoices, registerMove, registerSwitch, weightFromOpponentOptions, weightFromUserOptions, weightTypeChange
-
Field Details
-
codec
-
type
-
-
Constructor Details
-
BattleAIBase
protected BattleAIBase(com.mojang.serialization.MapCodec<? extends BattleAIBase> codec, BattleAIType<?> type)
-
-
Method Details
-
codec
- Specified by:
codecin interfaceBattleAILogic
-
type
- Specified by:
typein interfaceBattleAILogic
-
getChoices
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
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
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
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.
-
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
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
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
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
Description copied from interface:BattleAILogicWeights and returns all offensive move choices of a Pokémon.- Specified by:
getWeightedOffensiveChoicesin interfaceBattleAILogic- 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
Description copied from interface:BattleAILogicFinds the strongest offensive move choices in the situation. This should only be called when already in simulate mode.- Specified by:
getBestAttackChoicesin interfaceBattleAILogic- Parameters:
pw- The Pokémon to get the best move choices for.- Returns:
- The strongest offensive move choices in the situation.
-
getMoveset
Description copied from interface:BattleAILogicReturns the moveset that the AI thinks a Pokémon has.- Specified by:
getMovesetin interfaceBattleAILogic- Parameters:
pw- The Pokémon to get moves for.- Returns:
- The moveset that the AI thinks the Pokémon has.
-
getMemory
Finds the memory of a certain Pokémon. Creates a new one if a new opponent Pokémon has been seen.- Parameters:
pw- The Pokémon to get the memory for.- Returns:
- The memory of a certain Pokémon, or null if the Pokémon is not an opponent.
-
weightRandomMove
public void weightRandomMove(PixelmonWrapper pw, MoveChoice userChoice, List<MoveChoice> possibleChoices) Description copied from interface:BattleAILogicWeights a move that randomly selects from an assortment of moves.- Specified by:
weightRandomMovein interfaceBattleAILogic- 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, boolean weightNegative) Description copied from interface:BattleAILogicWeights a move based on the amount of turns the user takes to KO the opponent after using the move.- Specified by:
weightFromUserOptionsin interfaceBattleAILogic- 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, boolean weightNegative) Description copied from interface:BattleAILogicWeights a move based on the amount of turns the opponent takes to KO the Pokémon before and after using the move.- Specified by:
weightFromOpponentOptionsin interfaceBattleAILogic- 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<net.minecraft.resources.ResourceKey<Type>> possibleTypes, PixelmonWrapper target, List<MoveChoice> bestUserChoices, List<MoveChoice> bestOpponentChoices) Description copied from interface:BattleAILogicWeights the effectiveness of a type change.- Specified by:
weightTypeChangein interfaceBattleAILogic- 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<net.minecraft.core.Holder<Type>> newType, PixelmonWrapper target, List<MoveChoice> bestUserChoices, List<MoveChoice> bestOpponentChoices) Description copied from interface:BattleAILogicWeights the effectiveness of a type change.- Specified by:
weightSingleTypeChangein interfaceBattleAILogic- 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) Description copied from interface:BattleAILogicWeights a status based on the damage output of the opponent before and after applying it.- Specified by:
weightStatusOpponentOptionsin interfaceBattleAILogic- 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.
-