Class EvaluationBattleRandomness
- All Implemented Interfaces:
BattleRandomness
BattleRandomness implementation used for deterministic battle evaluation.
This policy intentionally removes most non-guaranteed random outcomes from AI evaluation so that simulated battle states are stable and repeatable. Guaranteed effects still succeed, while chance-based positive outcomes such as critical hits, secondary effects, move power boosts, and random recovery generally fail unless their chance is 100%.
Where a random value must still be selected, this implementation chooses a stable representative value, such as the minimum multi-hit count, the first available target or attack, or the midpoint of a fixed damage range.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchooseBefuddleStatus(PixelmonWrapper user, PixelmonWrapper target) Chooses the status applied by Befuddle.chooseDireClawStatus(PixelmonWrapper user, PixelmonWrapper target) Chooses the status applied by Dire Claw.floatchooseFixedDamageMultiplier(float min, float max) Chooses a fixed-damage multiplier.intchooseMultiHitCount(int minHits, int maxHits) Chooses the number of hits for a multi-hit move.Chooses the stat boost or special boost applied by a raid cheer effect.intchooseRaidCheerEffect(int effectCount) Chooses which raid cheer effect occurs.chooseStunShockStatus(PixelmonWrapper user, PixelmonWrapper target) Chooses the status applied by Stun Shock.chooseTriAttackStatus(PixelmonWrapper user, PixelmonWrapper target) Chooses the status applied by Tri Attack.copy(BattleRandomContext newController, BattleRandomSource newSource) Creates a copy of this randomness context for another battle controller and random source.getRandomAttack(List<Attack> possibleAttacks) Chooses a random attack from the possible attacks.getRandomStatIncrease(it.unimi.dsi.fastutil.ints.IntList possibleStats) Chooses a random stat from the possible stat list to increase.getRandomTarget(PixelmonWrapper user, PixelmonWrapper[] possibleTargets) Chooses a random target from the possible targets.net.minecraft.core.Holder<Type> getRandomType(List<net.minecraft.core.Holder<Type>> possibleTypes) Chooses a random type from the possible types.raw()Gets the raw battle randomness source.booleanrollAbilityEffect(double chance) Rolls whether an ability-based random effect occurs.booleanrollAccuracy(double accuracy) Rolls whether a move passes its accuracy check.booleanrollCheerChance(double chance) Rolls whether a raid cheer attempt succeeds.booleanrollConsecutiveMoveSuccess(double chance) Rolls whether a consecutively-used move succeeds.booleanrollCrit(double chance) Rolls whether an attack is a critical hit.booleanrollHeldItemEffect(double chance) Rolls whether a held item random effect occurs.Rolls Magnitude's magnitude and power.booleanrollMoveEffect(double chance) Rolls whether a move's main random effect occurs.booleanrollMovePowerBoost(double chance) Rolls whether a move receives a random power boost.booleanrollOHKOAccuracy(double accuracy) Rolls whether an OHKO move passes its special accuracy check.introllPresentPower(int maxPower) Rolls Present's random base power.booleanrollSecondaryEffect(double chance) Rolls whether a move's secondary effect occurs.booleanrollShockwaveChance(double chance) Rolls whether a shockwave-style random raid effect occurs.booleanrollStatusEffect(double chance) Rolls whether a status-inflicting effect occurs.booleanrollStatusPrevention(double chance) Rolls whether a status prevents the affected Pokémon from acting.booleanrollStatusRecovery(double chance) Rolls whether a status randomly recovers or ends.introllStatusTurns(int min, int max) Rolls the number of turns a status will last.booleanrollUserWinsSpeedTie(PixelmonWrapper user, PixelmonWrapper target) Rolls whether the user wins a speed tie against the target.
-
Constructor Details
-
EvaluationBattleRandomness
-
-
Method Details
-
raw
Description copied from interface:BattleRandomnessGets the raw battle randomness source.This should almost never be used directly by internal battle mechanics. Prefer adding or using a semantic method on this interface instead.
Direct raw access is appropriate for:
- Implementing methods inside a
BattleRandomnessimplementation. - External/non-battle-mechanic randomness where AI evaluation is irrelevant.
- Old AI implementations (such as Advanced/Tactical AIs)
- Temporary migration code where no semantic method exists yet.
If a random result can affect battle state, turn order, damage, status, targeting, move success, or any decision an AI may need to evaluate, add a semantic method instead of using this directly.
- Specified by:
rawin interfaceBattleRandomness- Returns:
- The raw battle random source.
- Implementing methods inside a
-
rollAccuracy
public boolean rollAccuracy(double accuracy) Description copied from interface:BattleRandomnessRolls whether a move passes its accuracy check.- Specified by:
rollAccuracyin interfaceBattleRandomness- Parameters:
accuracy- The move accuracy as a probability from0.0to1.0.- Returns:
- Whether the move hits.
-
rollOHKOAccuracy
public boolean rollOHKOAccuracy(double accuracy) Description copied from interface:BattleRandomnessRolls whether an OHKO move passes its special accuracy check.OHKO moves are separated from normal accuracy because they have unusually high impact and may need to be treated more conservatively by AI evaluation.
- Specified by:
rollOHKOAccuracyin interfaceBattleRandomness- Parameters:
accuracy- The OHKO accuracy as a probability from0.0to1.0.- Returns:
- Whether the OHKO move hits.
-
rollSecondaryEffect
public boolean rollSecondaryEffect(double chance) Description copied from interface:BattleRandomnessRolls whether a move's secondary effect occurs.This should be used for additional effects caused by a move, such as secondary status, stat drops, or similar effects that are not the primary purpose of the move.
- Specified by:
rollSecondaryEffectin interfaceBattleRandomness- Parameters:
chance- The secondary effect chance as a probability from0.0to1.0.- Returns:
- Whether the secondary effect occurs.
-
rollAbilityEffect
public boolean rollAbilityEffect(double chance) Description copied from interface:BattleRandomnessRolls whether an ability-based random effect occurs.- Specified by:
rollAbilityEffectin interfaceBattleRandomness- Parameters:
chance- The ability effect chance as a probability from0.0to1.0.- Returns:
- Whether the ability effect occurs.
-
rollCrit
public boolean rollCrit(double chance) Description copied from interface:BattleRandomnessRolls whether an attack is a critical hit.- Specified by:
rollCritin interfaceBattleRandomness- Parameters:
chance- The critical hit chance as a probability from0.0to1.0.- Returns:
- Whether the attack crits.
-
rollStatusEffect
public boolean rollStatusEffect(double chance) Description copied from interface:BattleRandomnessRolls whether a status-inflicting effect occurs.This is intended for random status application when the status effect itself is the thing being rolled.
- Specified by:
rollStatusEffectin interfaceBattleRandomness- Parameters:
chance- The status effect chance as a probability from0.0to1.0.- Returns:
- Whether the status effect occurs.
-
rollConsecutiveMoveSuccess
public boolean rollConsecutiveMoveSuccess(double chance) Description copied from interface:BattleRandomnessRolls whether a consecutively-used move succeeds.This is intended for Protect-like effects, Ally Switch repeat failure, and similar mechanics where repeated use lowers the success chance.
- Specified by:
rollConsecutiveMoveSuccessin interfaceBattleRandomness- Parameters:
chance- The success chance as a probability from0.0to1.0.- Returns:
- Whether the consecutive-use move succeeds.
-
rollStatusPrevention
public boolean rollStatusPrevention(double chance) Description copied from interface:BattleRandomnessRolls whether a status prevents the affected Pokémon from acting.Examples include full paralysis, immobilization from infatuation, drowsy action failure, and similar status-based turn denial.
- Specified by:
rollStatusPreventionin interfaceBattleRandomness- Parameters:
chance- The prevention chance as a probability from0.0to1.0.- Returns:
- Whether the status prevents action this turn.
-
rollHeldItemEffect
public boolean rollHeldItemEffect(double chance) Description copied from interface:BattleRandomnessRolls whether a held item random effect occurs.- Specified by:
rollHeldItemEffectin interfaceBattleRandomness- Parameters:
chance- The held item effect chance as a probability from0.0to1.0.- Returns:
- Whether the held item effect occurs.
-
chooseMultiHitCount
public int chooseMultiHitCount(int minHits, int maxHits) Description copied from interface:BattleRandomnessChooses the number of hits for a multi-hit move.Implementations should preserve any special distributions for common multi-hit moves, such as the standard weighted 2-5 hit distribution, rather than assuming uniform selection.
- Specified by:
chooseMultiHitCountin interfaceBattleRandomness- Parameters:
minHits- The minimum possible number of hits.maxHits- The maximum possible number of hits.- Returns:
- The selected number of hits.
-
rollUserWinsSpeedTie
Description copied from interface:BattleRandomnessRolls whether the user wins a speed tie against the target.- Specified by:
rollUserWinsSpeedTiein interfaceBattleRandomness- Parameters:
user- The Pokémon whose move order is being checked.target- The opposing Pokémon in the speed tie.- Returns:
- Whether
userwins the speed tie.
-
rollStatusRecovery
public boolean rollStatusRecovery(double chance) Description copied from interface:BattleRandomnessRolls whether a status randomly recovers or ends.Examples include random thawing from freeze or similar status recovery mechanics.
- Specified by:
rollStatusRecoveryin interfaceBattleRandomness- Parameters:
chance- The recovery chance as a probability from0.0to1.0.- Returns:
- Whether the status recovers.
-
rollMovePowerBoost
public boolean rollMovePowerBoost(double chance) Description copied from interface:BattleRandomnessRolls whether a move receives a random power boost.This is intended for moves where the primary damage profile changes due to a random effect, rather than for secondary effects.
- Specified by:
rollMovePowerBoostin interfaceBattleRandomness- Parameters:
chance- The power boost chance as a probability from0.0to1.0.- Returns:
- Whether the move receives the power boost.
-
chooseBefuddleStatus
Description copied from interface:BattleRandomnessChooses the status applied by Befuddle.- Specified by:
chooseBefuddleStatusin interfaceBattleRandomness- Parameters:
user- The Pokémon using Befuddle.target- The Pokémon receiving the status.- Returns:
- The selected status type.
-
chooseDireClawStatus
Description copied from interface:BattleRandomnessChooses the status applied by Dire Claw.- Specified by:
chooseDireClawStatusin interfaceBattleRandomness- Parameters:
user- The Pokémon using Dire Claw.target- The Pokémon receiving the status.- Returns:
- The selected status type.
-
chooseTriAttackStatus
Description copied from interface:BattleRandomnessChooses the status applied by Tri Attack.- Specified by:
chooseTriAttackStatusin interfaceBattleRandomness- Parameters:
user- The Pokémon using Tri Attack.target- The Pokémon receiving the status.- Returns:
- The selected status type.
-
chooseStunShockStatus
Description copied from interface:BattleRandomnessChooses the status applied by Stun Shock.- Specified by:
chooseStunShockStatusin interfaceBattleRandomness- Parameters:
user- The Pokémon using Stun Shock.target- The Pokémon receiving the status.- Returns:
- The selected status type.
-
rollStatusTurns
public int rollStatusTurns(int min, int max) Description copied from interface:BattleRandomnessRolls the number of turns a status will last.- Specified by:
rollStatusTurnsin interfaceBattleRandomness- Parameters:
min- The minimum number of turns.max- The maximum number of turns.- Returns:
- The selected duration.
-
chooseFixedDamageMultiplier
public float chooseFixedDamageMultiplier(float min, float max) Description copied from interface:BattleRandomnessChooses a fixed-damage multiplier.This is intended for fixed-damage moves with random damage ranges, such as Psywave-style effects. Normal attack damage variance should generally be handled by the attack damage calculator instead.
- Specified by:
chooseFixedDamageMultiplierin interfaceBattleRandomness- Parameters:
min- The minimum multiplier.max- The maximum multiplier.- Returns:
- The selected multiplier.
-
chooseRaidCheerEffect
public int chooseRaidCheerEffect(int effectCount) Description copied from interface:BattleRandomnessChooses which raid cheer effect occurs.- Specified by:
chooseRaidCheerEffectin interfaceBattleRandomness- Parameters:
effectCount- The number of possible cheer effects.- Returns:
- The selected cheer effect index.
-
chooseRaidCheerBoost
Description copied from interface:BattleRandomnessChooses the stat boost or special boost applied by a raid cheer effect.- Specified by:
chooseRaidCheerBoostin interfaceBattleRandomness- Returns:
- The selected raid cheer boost.
-
rollCheerChance
public boolean rollCheerChance(double chance) Description copied from interface:BattleRandomnessRolls whether a raid cheer attempt succeeds.- Specified by:
rollCheerChancein interfaceBattleRandomness- Parameters:
chance- The cheer success chance as a probability from0.0to1.0.- Returns:
- Whether the cheer succeeds.
-
rollShockwaveChance
public boolean rollShockwaveChance(double chance) Description copied from interface:BattleRandomnessRolls whether a shockwave-style random raid effect occurs.- Specified by:
rollShockwaveChancein interfaceBattleRandomness- Parameters:
chance- The shockwave chance as a probability from0.0to1.0.- Returns:
- Whether the shockwave effect occurs.
-
getRandomStatIncrease
Description copied from interface:BattleRandomnessChooses a random stat from the possible stat list to increase.- Specified by:
getRandomStatIncreasein interfaceBattleRandomness- Parameters:
possibleStats- The possible stat indexes.- Returns:
- The selected battle stat type.
-
rollMoveEffect
public boolean rollMoveEffect(double chance) Description copied from interface:BattleRandomnessRolls whether a move's main random effect occurs.This is intended for moves whose primary effect has a random activation chance, rather than for secondary effects, ability effects, or held item effects.
- Specified by:
rollMoveEffectin interfaceBattleRandomness- Parameters:
chance- The move effect chance as a probability from0.0to1.0.- Returns:
- Whether the move effect occurs.
-
rollMagnitude
Description copied from interface:BattleRandomnessRolls Magnitude's magnitude and power.- Specified by:
rollMagnitudein interfaceBattleRandomness- Returns:
- The selected Magnitude roll.
-
getRandomTarget
Description copied from interface:BattleRandomnessChooses a random target from the possible targets.- Specified by:
getRandomTargetin interfaceBattleRandomness- Parameters:
user- The Pokémon choosing the target.possibleTargets- The possible targets.- Returns:
- The selected target.
-
getRandomAttack
Description copied from interface:BattleRandomnessChooses a random attack from the possible attacks.- Specified by:
getRandomAttackin interfaceBattleRandomness- Parameters:
possibleAttacks- The possible attacks.- Returns:
- The selected attack.
-
getRandomType
public net.minecraft.core.Holder<Type> getRandomType(List<net.minecraft.core.Holder<Type>> possibleTypes) Description copied from interface:BattleRandomnessChooses a random type from the possible types.- Specified by:
getRandomTypein interfaceBattleRandomness- Parameters:
possibleTypes- The possible types.- Returns:
- The selected type.
-
rollPresentPower
public int rollPresentPower(int maxPower) Description copied from interface:BattleRandomnessRolls Present's random base power.- Specified by:
rollPresentPowerin interfaceBattleRandomness- Parameters:
maxPower- The maximum power value available to the roll.- Returns:
- The selected Present power.
-
copy
Description copied from interface:BattleRandomnessCreates a copy of this randomness context for another battle controller and random source.This is primarily intended for battle state copying, simulation, and AI lookahead.
- Specified by:
copyin interfaceBattleRandomness- Parameters:
newController- The battle controller the copied randomness should belong to.newSource- The random source the copied randomness should use.- Returns:
- The copied randomness context.
-