swarm-support
[Top][All Lists]
Advanced

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

Re: [Swarm-Support] How to prevent sending a message to a dropped object


From: Paul Johnson
Subject: Re: [Swarm-Support] How to prevent sending a message to a dropped object?
Date: Mon, 01 Aug 2005 11:43:59 -0500
User-agent: Mozilla Thunderbird 1.0.6-1.1.fc4 (X11/20050720)

I think I'd redesign it so that dead mothers were never sent messages. That is, remove the dead ones from the lists being processed.

But I think you can brute force fix this like so. Instead of having this message put "haveChild" with target "mother__" on schedule, have it aime the message at something you are sure exists, say model swarm.

[lifeMutationSchedulw at: (time + (int) (0.25* DPY*MPD)) createActionTo: self message: M(considerChildbirth):mother];


Then in that method

(void)considerChildbirth: mother
{
   if (mother) [mother haveChild];
else fprintf(stderr,"you just tried to give birth from the dead, silly!");
}

If "mother" is a pointer to nil, then this will prevent the seg fault.

Won't it?

pj

martijn cox wrote:
Hi,

Im new here so if I break any form of etiquette, please forgive me :)

I've been working on a (very simple) swarm-based simulation of evolution,
and have come accross the following problem. Female animals can have babies,
after impregnation by a male. This impregnation is a combining of the neural
networks of the parents, and this new neural network is stored in the
female. during here. During her pregnancy, the female can die, and carry her
unborn child with her (*sob*).

The problem is, that I'd like to have the pregnancy scheduled by the model
by the following ActionCreateTo:
--------------------------------------------
-scheduleBirthFromMother: (id) mother__
{
*snip*
[lifeMutationSchedule at: (time + (int) ( 0.25 * DAYSPERYEAR *
MINUTESPERDAY ))
   createActionTo: mother__
   message: M(haveChild)];
*snip*
}
--------------------------------------------
and if the female dies somewhere between impregnation and giving birth, this
message is send to a voided reference (because the female has long and gone
been dispatched of by a reaperQueue).
The final result is that every call subsequent call to create sends my
program crashing to its segmentation faulty damnedness, I presume because a
method has been called on with self = nil and as a consequence, the stack
has become corrupt.

A short term solution I've been using so far, is to not wipe the
reaperqueue, but keep all agents in cryostatis for the length of the
simulation (so the speak). Another solution would be to undo the
ActionCreateTo, but I see no way in all documentation I've searched through
how this can be done.

If no one can help me, I will probably resort to waiting untill after the
message has been sent to the dead agent before I wipe it from memory, but I
don't think that would be a very clean solution.

Kind regards,

Martijn Cox

ps: my gratitude for supplying the incredibly usefull environment to anyone
who has ever contributed to swarm! :)
_______________________________________________
Support mailing list
address@hidden
http://www.swarm.org/mailman/listinfo/support


--
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ku.edu/~pauljohn
1541 Lilac Lane, Rm 504
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66044-3177           FAX: (785) 864-5700


reply via email to

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