Record Class ChoiceEvaluation

java.lang.Object
java.lang.Record
com.pixelmonmod.pixelmon.battles.controller.ai.evaluation.ChoiceEvaluation
Record Components:
worstCase - the lowest score found for this choice across the evaluated outcomes
averageCase - the average score found for this choice across the evaluated outcomes
hasAnyEffect - whether this choice has any meaningful effect on the battle state
minimumDamage - the minimum damage this choice is expected to deal, used as a final tie-breaker
All Implemented Interfaces:
Comparable<ChoiceEvaluation>

public record ChoiceEvaluation(double worstCase, double averageCase, boolean hasAnyEffect, double minimumDamage) extends Record implements Comparable<ChoiceEvaluation>
Comparable summary of a candidate battle choice after evaluation.

This record stores the values used to rank one possible action against another. The values are intentionally ordered by importance rather than treated as equally weighted parts of a normal evaluation score.

Choices are compared lexicographically:

  1. worstCase is compared first, so safer choices are preferred.
  2. averageCase is used when the worst-case score is tied.
  3. hasAnyEffect is used to prefer choices that actually affect the battle state.
  4. minimumDamage is used as the final tie-breaker.

This allows the AI to prefer actions with better guaranteed outcomes before considering average outcomes or smaller tactical differences.

  • Constructor Details

    • ChoiceEvaluation

      public ChoiceEvaluation(double worstCase, double averageCase, boolean hasAnyEffect, double minimumDamage)
      Creates an instance of a ChoiceEvaluation record class.
      Parameters:
      worstCase - the value for the worstCase record component
      averageCase - the value for the averageCase record component
      hasAnyEffect - the value for the hasAnyEffect record component
      minimumDamage - the value for the minimumDamage record component
  • Method Details

    • isBetterThan

      public boolean isBetterThan(ChoiceEvaluation other)
      Checks whether this evaluation should be preferred over another evaluation.

      The comparison is performed in priority order rather than by summing all values together. Worst-case score is considered first, followed by average-case score, whether the choice has any effect, and finally minimum damage.

      Parameters:
      other - the other evaluation to compare against
      Returns:
      true if this evaluation should be preferred over the other evaluation
    • collapse

      public double collapse()
      Collapses this evaluation into a single sortable score.

      The large multipliers are not cosmetic. They preserve the same priority order used by isBetterThan(ChoiceEvaluation) when a single numeric value is needed. In other words, worstCase should dominate averageCase, averageCase should dominate hasAnyEffect, and hasAnyEffect should dominate minimumDamage.

      This value should be treated as a comparison helper, not as a meaningful battle score to display to players or use as a tuned evaluator weight.

      Returns:
      a single score preserving the intended comparison priority
    • compareTo

      public int compareTo(@NotNull @NotNull ChoiceEvaluation o)
      Specified by:
      compareTo in interface Comparable<ChoiceEvaluation>
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • worstCase

      public double worstCase()
      Returns the value of the worstCase record component.
      Returns:
      the value of the worstCase record component
    • averageCase

      public double averageCase()
      Returns the value of the averageCase record component.
      Returns:
      the value of the averageCase record component
    • hasAnyEffect

      public boolean hasAnyEffect()
      Returns the value of the hasAnyEffect record component.
      Returns:
      the value of the hasAnyEffect record component
    • minimumDamage

      public double minimumDamage()
      Returns the value of the minimumDamage record component.
      Returns:
      the value of the minimumDamage record component