Agents vs Agents_By_Type #1883
-
Folks, Your help in improving my understanding would be appreciated. If I use: for agent in self.schedule.agents: I get an iteration where "agent" is an agent in the scheduler as one would imagine. But if I use: for agent in self.schedule.agents_by_type[Sheep]: I instead get "agent" as an integer. The difference seems odd to me. I've used the first case and then a filter to get to sheep, say, but is there a more direct route? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
for agent_id, agent in self.schedule.agents_by_type[Sheep].items(): |
Beta Was this translation helpful? Give feedback.
-
For future reference, extensive work has been done on Agent management in Mesa. This should be a lot easier from the next release. See: |
Beta Was this translation helpful? Give feedback.
schedule.agents_by_type
is a dictionary of dictionaries. You will have to do this instead