swarm-support
[Top][All Lists]
Advanced

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

Re: Agent Death in Java


From: Benedikt Stefansson
Subject: Re: Agent Death in Java
Date: Wed, 19 Jul 2000 10:46:47 -0600

Jason,

Your message repeatedly says you want to kill an agent, but the syntax you use 
is for dropping activities. I.e. the drop
message is not going to the agent but to a schedule or even the underlying 
activity.

If killing an agent is what you want you need to send the agent a drop message 
and remove him from the linked list -
otherwise when the schedule iterates over the collection it will hit a null; do 
the drop before the beginning of a time
step, it is often easiest to create a 'reaper list' which collects the agents 
due to die during a timestep and then
drops them all in an orderly fashion.

However you also use the term 'swarm death'. I suggest you look at the 
'ExperSwarm' part of the simplebug tutorial to
see how one goes about dropping entire Swarms, which is straightforward. Note 
that if each Swarm you want to drop has
many agents and objects associated with it you should create all those objects 
in the Swarm's memory zone (i.e. passing
in the Swarm's memory zone at the create stage as in [object create: self]). 
Then the memory held by this collection of
objects should be dropped when the Swarm is.

--Benedikt

Jason York wrote:

> Hello, I am relatively new swarm user who has thus far been working only
> in Java.  I am working on a program involving swarm death and birth, but
> I am having trouble killing off my agents.  I'm using a simple schedule
> taken from the Java Tutorial:
>
>   schedule = new ScheduleImpl (thZone, 1);
>   try {
>    schedule.at$createActionTo$message (0, this,
>       new Selector (getClass (), "takeStep", false));
>   }
>   catch (Exception e) {
>    e.printStackTrace (System.err);
>    System.exit (1);
>   }
>
> If I try to kill the agent during takeStep () with (getActivity
> ()).terminate (), the program crashes during the next timestep, giving
> me the error AlreadyAtEnd.  If I try to drop () the agent, either before
> or after the terminate (), I get the error SourceMessage and am told
> "can only drop a top-level activity or terminated activity that is not
> currently running."  I guess I don't know how to get the activity into a
> state in which it is "not currently running."  I've tried creating a
> function in modelswarm to drop all dead agents each timestep, but I get
> the same error message.  By the way, the only List in which these guys
> are found is a LinkedList in the modelswarm, and I've found that
> removing a dead agent from this list doesn't help with any of the error
> messages.
> I'm sorry, but I haven't yet subscribed to swarm-support (I should do
> that next), so please email me at address@hidden with any help you
> can provide.
>
> Thanks,
> Andrew Lovett
> address@hidden
>
>                   ==================================
>    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.

--
Benedikt Stefansson      | address@hidden
HNC Software (CASA)      | Ph : (505) 988-8807 x101
Santa Fe, NM             | Fax: (505) 988-3440




                  ==================================
   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.



reply via email to

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