Package madkit.kernel

Class Watcher

All Implemented Interfaces:
Comparable<AbstractAgent>
Direct Known Subclasses:
SwingViewer

public class Watcher extends AbstractAgent
This class defines a generic watcher agent. It holds a collection of probes to explore agents' internal properties.
Since:
MaDKit 2.0
Version:
5.0
Author:
Fabien Michel, Olivier Gutknecht
  • Constructor Details

    • Watcher

      public Watcher()
  • Method Details

    • addProbe

      public void addProbe(Probe<? extends AbstractAgent> probe)
      Adds the probe to the artificial organization so that it starts to probe the agents which are at the corresponding CGR location.
      Parameters:
      probe - the probe to add
    • removeProbe

      public void removeProbe(Probe<? extends AbstractAgent> probe)
      Removes the probe from the artificial organization, thus stopping the probing activity.
      Parameters:
      probe - the probe to remove
    • activate

      protected void activate()
      Description copied from class: AbstractAgent
      This method corresponds to the first behavior which is called by the MaDKit kernel when an agent is launched. Usually a good place to take a position in the organization of the artificial society.

      Here is a typical example:

       @Override
       protected void activate()
       {
              AbstractAgent.ReturnCode returnCode = requestRole("a community", "a group", "my role");
              if (returnCode == AbstractAgent.ReturnCode.SUCCESS){
                      if(logger != null)
                              logger.info("I am now playing my role in the artificial society");
              }
              else{
                      if(logger != null)
                              logger.warning("something wrong, return code is "+returnCode);
              }
       }
       
      Overrides:
      activate in class AbstractAgent
    • removeAllProbes

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

      public Probe<AbstractAgent>[] allProbes()
    • getProbes

      public Set<Probe<? extends AbstractAgent>> getProbes()
      Returns the probes which have been successfully added
      Returns:
      all the added probes
    • toString

      public String toString()
      Overrides:
      toString in class AbstractAgent
      Returns:
      a String giving the name and the current state of the agent