Class Option

java.lang.Object
com.hypixel.hytale.server.npc.decisionmaker.core.Option
Direct Known Subclasses:
CombatActionEvaluator.RunOption, CombatActionOption, StateOption

public abstract class Option extends Object
An abstract class representing an option (e.g. a State, an Attack, etc) to be evaluated based on a number of Conditions. (Condition).

Options can define a weight coefficient which is used a secondary 'ranking' system. By setting a minimum weight for consideration in an execution all options falling below this are ignored. This prevents picking options we know for certain should not be selected and is also multiplied into the score for the option itself.

For the sake of improved performance, conditions are sorted based on an assigned 'cost' factor, with cheaper conditions being evaluated first. In the event that a single condition returns 0 (or below the minimum utility value assigned for the current execution), further evaluation is terminated and more expensive checks can potentially be foregone entirely.

Note: Options must not store instance information unique to an NPC as they are intended to be shared and run in parallel! This is the purpose of the Evaluator.OptionHolder.

Since:
2019/12/03
  • Field Details

  • Method Details

    • getConditions

      public String[] getConditions()
    • getWeightCoefficient

      public double getWeightCoefficient()
    • sortConditions

      public void sortConditions()
    • setupNPC

      public void setupNPC(ExecutionSupport executionSupport)
    • setupNPC

      public void setupNPC(Holder<EntityStore> holder)
    • calculateUtility

      public double calculateUtility(int selfIndex, @Nonnull ArchetypeChunk<EntityStore> archetypeChunk, Ref<EntityStore> target, CommandBuffer<EntityStore> commandBuffer, @Nonnull EvaluationContext context)
      Evaluates all conditions and returns a utility result for the option.
      Parameters:
      selfIndex - the index of the self entity in the archetype chunk
      archetypeChunk - entity archetype chunk for fetching own components
      target - a ref to the target entity being evaluated
      commandBuffer - command buffer for read-only fetching of other entities components
      context - the evaluation context
      Returns:
      a utility value for this option with an optional weight coefficient applied
    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object