From 031f3df71a7104b26e07067a054df225f2c41426 Mon Sep 17 00:00:00 2001 From: jurreaserna <105222220+jurreaserna@users.noreply.github.com> Date: Thu, 14 Sep 2023 20:23:12 -0500 Subject: [PATCH] fix: Add count_cops method to the model (#60) --- .../epstein_civil_violence/model.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/examples/epstein_civil_violence/epstein_civil_violence/model.py b/examples/epstein_civil_violence/epstein_civil_violence/model.py index f660ecfa..6bce24eb 100644 --- a/examples/epstein_civil_violence/epstein_civil_violence/model.py +++ b/examples/epstein_civil_violence/epstein_civil_violence/model.py @@ -141,3 +141,14 @@ def count_jailed(model): if agent.breed == "citizen" and agent.jail_sentence > 0: count += 1 return count + + @staticmethod + def count_cops(model): + """ + Helper method to count jailed agents. + """ + count = 0 + for agent in model.schedule.agents: + if agent.breed == "cop": + count += 1 + return count