1: package agent2d;

  3: import swarm.objectbase.SwarmImpl;
  4: import swarm.objectbase.Swarm;
  5: import swarm.activity.Activity;
  6: import swarm.activity.Schedule;
  7: import swarm.activity.ScheduleImpl;
  8: import swarm.defobj.Zone;
  9: import swarm.gui.Raster;

 11: import swarm.Selector;

 13: import Organization;

 15: public abstract class SocialAgent2d extends Agent2d {
 16:   Schedule schedule;
 17:   
 18:   public SocialAgent2d (Zone aZone, Organization org,
 19:                         int x, int y,
 20:                         int scatter, int size) {
 21:     super (aZone, org, x, y, scatter, size);

 23:     schedule = new ScheduleImpl (aZone, 1);

 25:     try {
 26:       schedule.at$createActionTo$message
 27:         (0,
 28:          this,
 29:          new Selector (getClass (), "stepAgent", false));
 30:     } catch (Exception e) {
 31:       e.printStackTrace (System.err);
 32:       System.exit (1);
 33:     }
 34:   }
 35:   
 36:   public Activity activateIn (Swarm context) {
 37:     super.activateIn (context);

 39:     schedule.activateIn (this);
 40:     return getActivity ();
 41:   }

 43:   public void stepAgent () {
 44:     stepSocialAgent (getNeighbor (size));
 45:   }

 47:   public void stepSocialAgent (Agent2d neighbor) {
 48:   }

 50:   public Object drawSelfOn (Raster r) {
 51:     super.drawSelfOn (r);
 52:     r.rectangleX0$Y0$X1$Y1$Width$Color
 53:       (x - size, y - size, x + size, y + size, 1, color);
 54:     return this;
 55:   }

 57:   public boolean frob (int direction) {
 58:     System.out.print (this + " sure, whatever!");
 59:     return false;
 60:   }
 61: }