Interface Behavior

All Known Implementing Classes:
FlockingBehavior

public interface Behavior
Represents a specific task or behavior exhibited by an Agent.

Behaviors can be simple (one-shot actions) or complex (finite state machines, cyclic tasks).

Since:
2.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Execution logic of the behavior.
    boolean
    Checks if the behavior has completed its task.
    Gets the agent this behavior belongs to.
    default void
    Lifecycle method called when the behavior ends.
    default void
    Lifecycle method called when the behavior starts.
    void
    setAgent(Agent agent)
    Sets the agent this behavior belongs to.
  • Method Details

    • action

      void action()
      Execution logic of the behavior. This method is called repeatedly by the agent scheduler until done() returns true.
    • done

      boolean done()
      Checks if the behavior has completed its task.
      Returns:
      true if the behavior is finished, false otherwise.
    • onStart

      default void onStart()
      Lifecycle method called when the behavior starts.
    • onEnd

      default void onEnd()
      Lifecycle method called when the behavior ends.
    • setAgent

      void setAgent(Agent agent)
      Sets the agent this behavior belongs to.
      Parameters:
      agent - the owner agent.
    • getAgent

      Agent getAgent()
      Gets the agent this behavior belongs to.
      Returns:
      the owner agent.