3-001 // Sugarscape in Swarm. Copyright © 1997 Nelson Minar
3-002 // This program is distributed without any warranty; without even the
3-003 // implied warranty of merchantability or fitness for a particular purpose.
3-004 // See file LICENSE for details and terms of copying.
3-005 
3-006 #import <space.h>				  // we use Space features
3-007 #import <gui.h>
3-008 #import "SugarSpace.h"
3-009 
3-010 // The definition of a SugarAgent object. We inherit code from the generic
3-011 // SwarmObject, which provides memory allocation and other niceties. It
3-012 // does not provide any sort of agent behaviour, though, that's up to us.
3-013 // First, there are a lot of state variables
3-014 
3-015 @interface SugarAgent: SwarmObject
3-016 {
3-017   SugarValue currentSugar;			  // how much sugar I hold
3-018   SugarValue metabolism;			  // how much sugar I need
3-019   int vision;					  // how far I can see
3-020   int age;					  // how old I am
3-021   int deathAge;					  // how old I can get
3-022   
3-023   id modelSwarm;				  // my swarm
3-024   SugarSpace *sugarSpace;			  // the sugarspace I live in
3-025   @public
3-026   int x, y;					  // my position
3-027   // I won't change this myself
3-028 }
3-029 
3-030 // The main behaviour of an object - do one 'time step', one action.
3-031 - step;
3-032 
3-033 // The agent movement rule M.
3-034 - moveToBestOpenSpot;
3-035 
3-036 // data accessor functions.
3-037 - (SugarValue)getMetabolism;
3-038 - (int)getVision;
3-039 - (int)getAge;
3-040 - (SugarValue)getCurrentSugar;
3-041 - setModelSwarm: s;
3-042 - setCurrentSugar: (SugarValue)cs;
3-043 - setMetabolism: (SugarValue)m;
3-044 - setVision: (int)v;
3-045 - setDeathAge: (int)a;
3-046 
3-047 // display code so you can see the agents moving.
3-048 - drawSelfOn: (id <Raster>)r;
3-049 
3-050 @end


