[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SWARM problems
From: |
Doug Donalson |
Subject: |
Re: SWARM problems |
Date: |
Wed, 24 Jun 1998 16:07:56 -0700 |
Laurence,
Making a list for each object type is the best and easiest way to go. Here
are a couple of code fragments from an object called a "cell" which keeps track
of the agents in my simulation presently residing in each 2D lattice site.
The ".h" file (not a fragment!)
@interface AphytisCell: SwarmObject {
@public
int numberOfAdultAphytis;
int numberOfAdultRedScale;
int numberOfJuvenileAphytis;
int numberOfJuvenileRedScale;
int numberOfBirths;
int numberOfAphytisDeaths;
int numberOfRSDeaths;
int numberOfMolts;
int numberOfEmerge;
int numberOfPredation;
int numberOfAphytisIn;
int numberOfAphytisOut;
int numberOfRSIn;
int numberOfRSOut;
int x,y;
// *****************define the lists******************
id adultAphytisList;
id adultRedScaleList;
id juvenileAphytisList;
id juvenileRedScaleList;
//**************************************************
int active;
id myWorld,myModel;
int worldXSize,worldYSize;
id neighborCells[20];
int disburse[20];
id oppositeCell;
int nullNeighbors;
double resourceLevel,refugeLevel;
int wrapSpace;
int squareBoundary;
}
-createEnd;
-incrementNumberOfBirths;
-incrementNumberOfAphytisDeaths;
-incrementNumberOfRSDeaths;
-incrementNumberOfMolts;
-incrementNumberOfEmerge;
-incrementNumberOfPredation;
-incrementNumberOfAphytisIn;
-incrementNumberOfAphytisOut;
-incrementNumberOfRSIn;
-incrementNumberOfRSOut;
-clearStats;
-setX: (int) X;
-setY: (int) Y;
-(int)getX;
-(int)getY;
-(int)totalNumber;
-(int)iAmActive;
-setActive: (int) flag;
-drawNumberOfAdultAphytis: (Raster *) r;
-drawNumberOfAdultRedScale: (Raster *) r;
-displayAphytis;
-(int)getNumberOfAdultAphytis;
-(int)getNumberOfAdultRedScale;
-getAdultAphytisList;
-getAdultRedScaleList;
-incrementAdultAphytis;
-decrementAdultAphytis;
-incrementAdultRedScale;
-decrementAdultRedScale;
-addAdultRedScale: newBug;
-removeAdultAphytis: deadBug;
-addAdultAphytis: newBug;
-removeAdultRedScale: deadBug;
-drawNumberOfJuvenileAphytis: (Raster *) r;
-drawNumberOfJuvenileRedScale: (Raster *) r;
-(int)getNumberOfJuvenileAphytis;
-(int)getNumberOfJuvenileRedScale;
-setNeighbors;
-printNeighbors;
-getNeighbor: (int)offset;
-getJuvenileAphytisList;
-getJuvenileRedScaleList;
-incrementJuvenileAphytis;
-decrementJuvenileAphytis;
-incrementJuvenileRedScale;
-decrementJuvenileRedScale;
-addJuvenileRedScale: newBug;
-removeJuvenileAphytis: deadBug;
-addJuvenileAphytis: newBug;
-removeJuvenileRedScale: deadBug;
-setResourceLevel: (double) resource;
-setRefugeLevel: (double) refuge;
-(double)getResourceLevel;
-(double)getRefugeLevel;
-getOppositeCell;
-average;
@end
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Here is create end where I set up the four lists.
-createEnd
{
id listType;
id aZone;
active=1;
aZone=[self getZone];
listType = [List customizeBegin: [self getZone]];
[listType setIndexFromMemberLoc: offsetof( AdultAphytis, listMember )];
listType = [listType customizeEnd];
adultAphytisList = [listType create: [self getZone]];
listType = [List customizeBegin: [self getZone]];
[listType setIndexFromMemberLoc: offsetof( AdultRedScale, listMember )];
listType = [listType customizeEnd];
adultRedScaleList=[listType create: [self getZone]];
listType = [List customizeBegin: [self getZone]];
[listType setIndexFromMemberLoc: offsetof( JuvenileAphytis, listMember )];
listType = [listType customizeEnd];
juvenileAphytisList = [listType create: [self getZone]];
listType = [List customizeBegin: [self getZone]];
[listType setIndexFromMemberLoc: offsetof( JuvenileRedScale, listMember )];
listType = [listType customizeEnd];
juvenileRedScaleList=[listType create: [self getZone]];
return self;
}
I hope this helps a little?
Cheers,
D3
Laurence wrote:
> Hi,
>
> I'm currently working on a model of chemotaxis using SWARM, and need some
> advice. I use objects to represent enzymes / proteins in the system that
> signal each other. I have different classes to represent each type of
> component, and the present program contains 1 object of each class. I now
> need to extend it so that each protein type is represented in it's relative
> concentration.
>
> 1) How can I create / manage a population of objects of different classes?
> Do I need to use lists? Do I need a seperate list to hold the objects of
> each class? Can you point me in the direction of some code that does similar
> stuff?
>
>
>
> Best wishes, Laurence (address@hidden)
> ---------------------
> http://www.csc.liv.ac.uk/~laurence
>
> ==================================
> Swarm-Support is for discussion of the technical details of the day
> to day usage of Swarm. For list administration needs (esp.
> [un]subscribing), please send a message to <address@hidden>
> with "help" in the body of the message.
> ==================================
--
************************************************************************
* Doug Donalson * Office: (805)
893-2962
* Ecology, Evolution, and Marine Biology * Home: (805) 961-4447
* UC Santa Barbara * email
address@hidden
* Santa Barbara Ca. 93106 *
************************************************************************
*
* The most exciting phrase to hear in science, the one that
* heralds new discoveries, is not "EUREKA" (I have found it) but
* "That's funny ...?"
*
* Isaac Asimov
*
************************************************************************
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
==================================