Agent Death

Enabling Agent Death

By default in FLAMEGPU2 agents do not die. To enable death for a particular agent function, use the setAllowAgentDeath method of the AgentFunctionDescription object:

# Allow agent_fn1 to kill agents

Agent Death

To have an agent die, simply return DEAD; instead of return ALIVE; at the end of a death-enabled agent function. You can use conditionals to only have agents die according to a certain condition:

FLAMEGPU_AGENT_FUNCTION(agent_fn1, MsgNone, MsgNone) {
    // Get the 'x' variable of the agent
    int x = FLAMEGPU->getVariable<int>("x");

    // Kill any agents with x < 25
    if (x < 25) {
        return DEAD;
    } else {
        return ALIVE;

More Info