You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# it keeps track of no. of prey and predators in each step of the simulation for analysis and visualization purposes
63
63
self.datacollector=mesa.DataCollector(
64
64
model_reporters={
65
-
"Prey": lambdam: sum(1forainm.agentsifisinstance(a, Prey)), # it's count the number of prey by checking instances of prey class in the agents
66
-
"Predators": lambdam: sum(1forainm.agentsifisinstance(a, Predator)), # it's count the number of predators by checking instances of predator class in the agents
65
+
"Prey": lambdam: sum(
66
+
1forainm.agentsifisinstance(a, Prey)
67
+
), # it's count the number of prey by checking instances of prey class in the agents
68
+
"Predators": lambdam: sum(
69
+
1forainm.agentsifisinstance(a, Predator)
70
+
), # it's count the number of predators by checking instances of predator class in the agents
67
71
}
68
72
)
69
73
70
74
defstep(self):
71
75
# advancing to next step, model need to collect data before the agents take their actions
72
-
self.datacollector.collect(self) # collect the data for the current step of the simulation
76
+
self.datacollector.collect(
77
+
self
78
+
) # collect the data for the current step of the simulation
73
79
# Mesa 4.0 native agent activation (replaces the old scheduler)
74
-
self.agents.shuffle_do("step") # it step all agents during the scheduling process
80
+
self.agents.shuffle_do(
81
+
"step"
82
+
) # it step all agents during the scheduling process
0 commit comments