Skip to content

Commit 031f3df

Browse files
authored
fix: Add count_cops method to the model (#60)
1 parent 6f3e077 commit 031f3df

File tree

1 file changed

+11
-0
lines changed
  • examples/epstein_civil_violence/epstein_civil_violence

1 file changed

+11
-0
lines changed

examples/epstein_civil_violence/epstein_civil_violence/model.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,14 @@ def count_jailed(model):
141141
if agent.breed == "citizen" and agent.jail_sentence > 0:
142142
count += 1
143143
return count
144+
145+
@staticmethod
146+
def count_cops(model):
147+
"""
148+
Helper method to count jailed agents.
149+
"""
150+
count = 0
151+
for agent in model.schedule.agents:
152+
if agent.breed == "cop":
153+
count += 1
154+
return count

0 commit comments

Comments
 (0)