Annotation Interface Goal


@Documented @Retention(RUNTIME) @Target({}) public @interface Goal
Defines a goal for planning.

Goals represent desired states that an agent wants to achieve. The

invalid reference
com.tnsai.planning.Planner
uses goals to create action plans that transform the current state into the goal state.

Goal Satisfaction

A goal is satisfied when its condition() evaluates to true against the current state (beliefs). The condition is expressed as a simple expression evaluated against State fields.

Usage


 @RoleSpec(
     name = "Soldier",
     goals = {
         @Goal(name = "survive", condition = "health > 0", priority = Priority.CRITICAL),
         @Goal(name = "armed", condition = "ammo > 10", priority = Priority.HIGH),
         @Goal(name = "patrol", condition = "isPatrolling == true", priority = Priority.NORMAL)
     }
 )
 public class SoldierRole extends Role {
     @State private int health = 100;
     @State private int ammo = 50;
     @State private boolean isPatrolling = false;
 }
 

Condition Syntax

OperatorExample
Equalitystate == ALIVE
Comparisonhealth > 50
Logical ANDhealth > 0 && ammo > 0
Logical ORstate == ALIVE || state == RECOVERING
Negation!isDead

Action Mapping

Actions are linked to goals via

invalid reference
Action#fulfills()
:

 @ActionSpec(
     type = ActionType.LOCAL,
     precondition = "health <= 50",
     postcondition = "health = 100",
     fulfills = {"survive"}  // Links to "survive" goal
 )
 public void heal() { ... }
 
Author:
TnsAI Team
See Also:
  • State
  • invalid reference
    Action#precondition()
  • invalid reference
    Action#postcondition()
  • invalid reference
    Action#fulfills()
  • invalid reference
    com.tnsai.planning.Planner
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Condition that must be true for the goal to be satisfied.
    Unique name identifying this goal.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
    Deadline in ticks for achieving this goal.
    Human-readable description of this goal.
    boolean
    Whether this goal persists after being achieved.
    Goal priority.
  • Element Details

    • name

      String name
      Unique name identifying this goal.

      Referenced by

      invalid reference
      Action#fulfills()
      to link actions to goals.
      Returns:
      goal name
    • condition

      String condition
      Condition that must be true for the goal to be satisfied.

      Evaluated against current state (belief map).

      Examples:

      • "health > 50" - numeric comparison
      • "state == ALIVE" - enum/string equality
      • "health > 0 && ammo > 0" - logical AND
      • "true" - always satisfied (useful for reactive goals)
      Returns:
      condition expression
    • priority

      Priority priority
      Goal priority.

      Higher priority goals are addressed first by the planner.

      Returns:
      priority level (default: NORMAL)
      Default:
      NORMAL
    • description

      String description
      Human-readable description of this goal.

      Used in documentation and agent explanations.

      Returns:
      goal description
      Default:
      ""
    • persistent

      boolean persistent
      Whether this goal persists after being achieved.

      Persistent goals are continuously monitored and re-planned if they become unsatisfied. Non-persistent goals are removed once achieved.

      Examples:

      • Persistent: "survive" (always needs to be maintained)
      • Non-persistent: "reach_destination" (one-time achievement)
      Returns:
      true if goal persists (default: true)
      Default:
      true
    • deadline

      int deadline
      Deadline in ticks for achieving this goal.

      If positive, the goal must be satisfied within this many ticks. Used for time-sensitive planning.

      Returns:
      deadline in ticks, or -1 for no deadline (default)
      Default:
      -1