Death in predator/prey

The simulation calls act() on every Agent that it can find in the grid (model). So an Agent will cease to act if it is replaced in the grid, by either another Agent (that's what happens when a Rabbit eats a Clover) or by nothing (null).

When an Agent is killed by another Agent, it simply won't be asked to act again. But when an Agent dies during its act(), you need to take care that it does not continue to act after its death (as a ghost or zombie). So it probably makes sense to have a dying Agent exit its act() method promptly (or perhaps after carrying out its dying wishes).


Cary Gray
Last modified: Mon Oct 31 15:19:06 CDT 2011