Print

Print


Greetings all:
I am trying to get an agent to "kill" itself based on some feature of the
agent.

In my example it is when the agent walks "too far" over the edge of the
world.
https://github.com/thesteve0/startmason/blob/master/src/org/thesteve0/steptwo/Animal.java#L135

But this doesn't work. I suspect because the Agent still lives on and all I
am doing is removing it from being displayed on the grid.

I have read the docs and looked at the asteroid example. It seems like I
need to action kill the agent from the SimState. If this is true then it
seems like I should set a flag on the agent like "dead=true" and then at
the start of each step iterate through all the agents and Stop() all that
are dead.

Is this correct or is there a way to "kill" an agent from within an agent?
I will need to do this in the future if the animal does not eat enough or
walks through too much bad habitat.

Thanks again for all the help!
Steve