Class Watcher

Direct Known Subclasses:
SimuEnvironment, SimuLauncher, SimuModel, Viewer

public abstract class Watcher extends SimuAgent
A Watcher is an agent that is designed to be part of a simulation engine to monitor and explore agents' internal properties.

To this end, it holds a collection of Probe which are used to monitor agents that play specific roles in specific groups.

The probes are added to the artificial organization of the simulation engine using addProbe(Probe) and removed using removeProbe(Probe).

Moreover, by default, the Watcher agent is automatically granted the role SimuOrganization.WATCHER_ROLE in the group SimuOrganization.ENGINE_GROUP when it is activated. This can be changed by overriding the onActivation() method.

Since:
MaDKit 2.0
  • Constructor Details

    • Watcher

      public Watcher()
  • Method Details

    • onActivation

      protected void onActivation()
      This method is called when the agent is activated. By default, it requests the role SimuOrganization.WATCHER_ROLE in the group SimuOrganization.ENGINE_GROUP.
      Overrides:
      onActivation in class Agent
    • addProbe

      public void addProbe(Probe probe)
      Adds the probe to the artificial organization so that it starts to probe the agents which belong to the group and play the role defined in the probe.
      Parameters:
      probe - the probe to add
    • removeProbe

      public void removeProbe(Probe probe)
      Removes the probe from the artificial organization, thus stopping the probing activity.
      Parameters:
      probe - the probe to remove
    • onEnd

      protected void onEnd()
      Removes all probes when the agent is ending
      Overrides:
      onEnd in class Agent
    • removeAllProbes

      public void removeAllProbes()
      Remove all probes at once.
    • getProbes

      public Set<Probe> getProbes()
      Returns the probes which are currently added to the artificial organization.
      Returns:
      the probes which are currently added to the artificial organization
    • toString

      public String toString()
      Returns the watcher's name followed by the list of probes it holds if any.
      Overrides:
      toString in class Agent
      Returns:
      the string