Contents
Class Condition
java.lang.Object
com.hypixel.hytale.server.npc.decisionmaker.core.conditions.base.Condition
- All Implemented Interfaces:
JsonAsset<String>, JsonAssetWithMap<String, IndexedLookupTableAssetMap<String, Condition>>
- Direct Known Subclasses:
CurveCondition, RandomiserCondition, ScaledCurveCondition, SimpleCondition
public abstract class Condition
extends Object
implements JsonAssetWithMap<String, IndexedLookupTableAssetMap<String, Condition>>
An abstract Condition to be evaluated as part of an
Option. Resulting utility is between 0 and 1.
Any condition returning 0 will result in the entire option being taken out of consideration for this execution.
The utility scores from individual conditions are multiplied together to produce a final score, with a compensation factor calculated to prevent bias against options with many conditions.
There are several important base condition types:
Condition.AlwaysTrueCondition: Returns maximum utility in all cases.SimpleCondition: Boolean condition returning one value for false and another for true.CurveCondition: Evaluates a percentage-based parameter (0-1) against aResponseCurveand returns the corresponding value from the y-axis.ScaledCurveCondition: As with the CurveCondition, except that the input parameter is a value range scaled down to be between 0-1.
Note: Conditions must not store instance information unique to an NPC as they are intended to be shared and run in parallel!
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final BuilderCodec<Condition> static final intstatic final AssetCodecMapCodec<String, Condition> static final intstatic final doublestatic final intstatic final intstatic final ValidatorCache<String> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract doublecalculateUtility(int selfIndex, ArchetypeChunk<EntityStore> archetypeChunk, Ref<EntityStore> target, CommandBuffer<EntityStore> commandBuffer, EvaluationContext context) Calculates a utility value based on parameters contained within the EvaluationContext.static Conditionstatic IndexedLookupTableAssetMap<String, Condition> static AssetStore<String, Condition, IndexedLookupTableAssetMap<String, Condition>> getId()abstract intReturns a value representing the relative simplicity/cost to evaluate the condition, where lower numbers are simpler to compute.voidsetupNPC(Holder<EntityStore> holder) voidsetupNPC(ExecutionSupport executionSupport) This method is called when an NPC is instantiated in order to initialise certain parameters on the NPC to be able to supply requisite information for the conditiontoString()
-
Field Details
-
NO_TARGET
public static final double NO_TARGET- See Also:
-
ALWAYS_TRUE_SIMPLICITY
public static final int ALWAYS_TRUE_SIMPLICITY- See Also:
-
BOOLEAN_CHECK_SIMPLICITY
public static final int BOOLEAN_CHECK_SIMPLICITY- See Also:
-
NORMALISED_CURVE_SIMPLICITY
public static final int NORMALISED_CURVE_SIMPLICITY- See Also:
-
SCALED_CURVE_SIMPLICITY
public static final int SCALED_CURVE_SIMPLICITY- See Also:
-
HIGH_COST_SIMPLICITY
public static final int HIGH_COST_SIMPLICITY- See Also:
-
CODEC
-
BASE_CODEC
-
CHILD_ASSET_CODEC
-
CHILD_ASSET_CODEC_ARRAY
-
VALIDATOR_CACHE
-
-
Constructor Details
-
Condition
-
-
Method Details
-
getAssetStore
@Nonnull public static AssetStore<String, Condition, IndexedLookupTableAssetMap<String, Condition>> getAssetStore() -
getAssetMap
-
getId
-
setupNPC
This method is called when an NPC is instantiated in order to initialise certain parameters on the NPC to be able to supply requisite information for the condition- Parameters:
executionSupport- the NPC executionSupport being instantiated
-
setupNPC
-
getReference
-
calculateUtility
public abstract double calculateUtility(int selfIndex, ArchetypeChunk<EntityStore> archetypeChunk, Ref<EntityStore> target, CommandBuffer<EntityStore> commandBuffer, EvaluationContext context) Calculates a utility value based on parameters contained within the EvaluationContext. Utility values are normalised between 0 and 1.- 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- additional contextual information relating to the option- Returns:
- a utility value
-
getSimplicity
public abstract int getSimplicity()Returns a value representing the relative simplicity/cost to evaluate the condition, where lower numbers are simpler to compute.- Returns:
- a simplicity value
-
toString
-
getAlwaysTrueFor
-