swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swarm-Support] Objects on multiple lists


From: Steve Railsback
Subject: Re: [Swarm-Support] Objects on multiple lists
Date: Mon, 17 Feb 2003 20:11:39 -0800

Darold Higa wrote:
> 
> On Monday 17 February 2003 04:13 pm, you wrote:
> 
> Thanks!  This helps a lot.
> 
> > To make a simple answer short, Yes. temporaryAgentList, the way you
> > programmed it, is just another name for the list inside your
> > terrainObject. Instead, you need to make a new list and put the same
> > objects on both (if that's what you want).
> 
> OK, I guess I should have read the manual on collections more clearly.  That
> makes a lot of sense and that explains why it removed all objects from the
> original list.
> 
> > So any object can be on as many lists as you want, each list is just a
> > list of pointers to that object. Just be careful when you go to drop an
> > object that you go through all the lists that it is on and remove it
> > from those lists. (Or you can maintain one master list of objects that
> > still exists, and continually empty and re-build your temporary lists-
> > may not be the fastest code but often it's the fastest way to get your
> > job done.)
> 
> Yes, I learned this one the hard way.  I have tried to be very careful with
> agent deaths.  Since my poor agents can die several ways, I have to be extra
> careful about removing them from every list.

One widely-used trick is to keep a list (yes- another list!) of agents
that are "killed". This is a temporary list of guys that have succumbed
during the current time step (or, anyway, since the last time you
processed the killedList). Then periodically (e.g., during a cleanup
action each time step) you loop through the killedList, and remove any
agent on the killedList from any other lists it might have been on. Then
do a "removeAll" on the killedList. 

> I was reading it but somehow I managed to make myself more confused.  I think
> I am clear now.  Thanks!

One of our long-term goals is to make Swarm's documentation more
complete and easier to get started with...  that's why we need your
membership $$$ http://www.swarm.org/sdg-membership.html

Steve

-- 
Lang Railsback & Assoc.
250 California Ave.
Arcata CA  USA 95521
707-822-0453; fax 822-1868


reply via email to

[Prev in Thread] Current Thread [Next in Thread]