Class Option
- Direct Known Subclasses:
CombatActionEvaluator.RunOption, CombatActionOption, StateOption
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondoublecalculateUtility(int selfIndex, ArchetypeChunk<EntityStore> archetypeChunk, Ref<EntityStore> target, CommandBuffer<EntityStore> commandBuffer, EvaluationContext context) Evaluates all conditions and returns a utility result for the option.String[]doublevoidsetupNPC(Holder<EntityStore> holder) voidsetupNPC(ExecutionSupport executionSupport) voidtoString()
-
Field Details
-
ABSTRACT_CODEC
-
-
Method Details
-
getConditions
-
getWeightCoefficient
public double getWeightCoefficient() -
sortConditions
public void sortConditions() -
setupNPC
-
setupNPC
-
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 chunkarchetypeChunk- entity archetype chunk for fetching own componentstarget- a ref to the target entity being evaluatedcommandBuffer- command buffer for read-only fetching of other entities componentscontext- the evaluation context- Returns:
- a utility value for this option with an optional weight coefficient applied
-
toString
-