Annotation Interface Effect


@Documented @Retention(RUNTIME) @Target({}) public @interface Effect
Defines a structured effect (state modification) for planning.

Effects describe how an action changes the agent's state. Used by the planner to predict action outcomes.

Operations

OperationDescriptionExample
SETAssign a valuestate = ALIVE
ADDAdd to numericcount = count + 1
SUBTRACTSubtract from numericenergy = energy - 10
MULTIPLYMultiply numericscore = score * 2
TOGGLEFlip booleanisActive = !isActive
CLEARSet to null/emptyerror = null
INCREMENTAdd 1counter++
DECREMENTSubtract 1counter--

Usage


 @ActionSpec(
     type = ActionType.LOCAL,
     description = "Consume energy to perform action",
     effects = {
         @Effect(state = "energy", operation = Operation.SUBTRACT, value = "10"),
         @Effect(state = "lastAction", operation = Operation.SET, value = "consume")
     }
 )
 public void consumeEnergy() { ... }
 
Author:
TnsAI Team
See Also:
  • invalid reference
    Action#effects()
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Effect operations for state modification.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The operation to perform on the state.
    The state field that this effect modifies.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Optional condition for conditional effects.
    The value to use in the operation.
  • Element Details

    • state

      String state
      The state field that this effect modifies.

      Should match a field annotated with @State.

      Returns:
      state field name
    • operation

      Effect.Operation operation
      The operation to perform on the state.
      Returns:
      operation type
    • value

      String value
      The value to use in the operation.

      Can be a literal ("ALIVE", "10") or a reference to another state/parameter.

      Returns:
      value string
      Default:
      ""
    • condition

      String condition
      Optional condition for conditional effects.

      Effect only applies if condition is true.

      
       @Effect(
           state = "cellState",
           operation = Operation.SET,
           value = "DEAD",
           condition = "neighborCount < 2"
       )
       
      Returns:
      condition expression
      Default:
      ""