Record Class ChoiceEvaluation
- Record Components:
worstCase- the lowest score found for this choice across the evaluated outcomesaverageCase- the average score found for this choice across the evaluated outcomeshasAnyEffect- whether this choice has any meaningful effect on the battle stateminimumDamage- the minimum damage this choice is expected to deal, used as a final tie-breaker
- All Implemented Interfaces:
Comparable<ChoiceEvaluation>
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:
worstCaseis compared first, so safer choices are preferred.averageCaseis used when the worst-case score is tied.hasAnyEffectis used to prefer choices that actually affect the battle state.minimumDamageis 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 Summary
ConstructorsConstructorDescriptionChoiceEvaluation(double worstCase, double averageCase, boolean hasAnyEffect, double minimumDamage) Creates an instance of aChoiceEvaluationrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of theaverageCaserecord component.doublecollapse()Collapses this evaluation into a single sortable score.intcompareTo(@NotNull ChoiceEvaluation o) final booleanIndicates whether some other object is "equal to" this one.booleanReturns the value of thehasAnyEffectrecord component.final inthashCode()Returns a hash code value for this object.booleanisBetterThan(ChoiceEvaluation other) Checks whether this evaluation should be preferred over another evaluation.doubleReturns the value of theminimumDamagerecord component.final StringtoString()Returns a string representation of this record class.doubleReturns the value of theworstCaserecord component.
-
Constructor Details
-
ChoiceEvaluation
public ChoiceEvaluation(double worstCase, double averageCase, boolean hasAnyEffect, double minimumDamage) Creates an instance of aChoiceEvaluationrecord class.- Parameters:
worstCase- the value for theworstCaserecord componentaverageCase- the value for theaverageCaserecord componenthasAnyEffect- the value for thehasAnyEffectrecord componentminimumDamage- the value for theminimumDamagerecord component
-
-
Method Details
-
isBetterThan
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:
trueif 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,worstCaseshould dominateaverageCase,averageCaseshould dominatehasAnyEffect, andhasAnyEffectshould dominateminimumDamage.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
- Specified by:
compareToin interfaceComparable<ChoiceEvaluation>
-
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. -
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. -
equals
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 '=='. -
worstCase
public double worstCase()Returns the value of theworstCaserecord component.- Returns:
- the value of the
worstCaserecord component
-
averageCase
public double averageCase()Returns the value of theaverageCaserecord component.- Returns:
- the value of the
averageCaserecord component
-
hasAnyEffect
public boolean hasAnyEffect()Returns the value of thehasAnyEffectrecord component.- Returns:
- the value of the
hasAnyEffectrecord component
-
minimumDamage
public double minimumDamage()Returns the value of theminimumDamagerecord component.- Returns:
- the value of the
minimumDamagerecord component
-