9. Stopping condition
This step adds a reflex that pauses the current experiment when either population reaches zero.
Formulation​
- Addition of a stopping condition for the simulation: when there is no more prey or predator agents, the simulation stops
Model Definition​
The model derives each population count from its species, then calls experiment.pause() when either count reaches zero.
global {
int nb_preys -> length(prey);
int nb_predators -> length(predator);
reflex stop_simulation when: (nb_preys = 0) or (nb_predators = 0) {
experiment.pause();
}
}
Complete Model​
gama.library/models/Tutorials/Predator%20Prey%20Tutorial/models/Model%2009.gaml
loading...