Annotation Interface Goal
Goals represent desired states that an agent wants to achieve.
The
invalid reference
com.tnsai.planning.Planner
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
| Operator | Example |
|---|---|
| Equality | state == ALIVE |
| Comparison | health > 50 |
| Logical AND | health > 0 && ammo > 0 |
| Logical OR | state == 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:
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionintDeadline in ticks for achieving this goal.Human-readable description of this goal.booleanWhether this goal persists after being achieved.Goal priority.
-
Element Details
-
name
String nameUnique name identifying this goal.Referenced by
to link actions to goals.invalid reference
Action#fulfills()- Returns:
- goal name
-
condition
String conditionCondition 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 priorityGoal priority.Higher priority goals are addressed first by the planner.
- Returns:
- priority level (default: NORMAL)
- Default:
NORMAL
-
description
String descriptionHuman-readable description of this goal.Used in documentation and agent explanations.
- Returns:
- goal description
- Default:
""
-
persistent
boolean persistentWhether 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 deadlineDeadline 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
-