-
Notifications
You must be signed in to change notification settings - Fork 927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a common interface to all spaces for getting agents #2416
Comments
Do you want only the agents, or also an identifier/coordinate in this iterator in a tuple or dict form? In the former case I’m curious how this would differ from model.agents in most cases, and in the latter, we should think a bit about its structure. |
I thought about having an iterator that would return I deliberately did not want to go the |
What about returning an iterator with I agree multiple grid support should be designed for. |
You know what, I’m pivoting on this. If we want to add something with coordinates/identifiers we can always do that separately. |
I am still not convinced. At a minimum, it would imply a weird mismatch between the name of the property # if you need the coordinates
for agent in space.agents:
match agent:
case CellAgent():
pos = agent.cell.coordinate
case _:
pos = agent.pos
# some other purpose
agents = AgentSet(space.agents, random=self.random) and move on depending on what you are trying to achieve. |
in both location can be space specific, either a coordinate or a identifier. |
Fair point. I'll give that a go. I was hesitant about this in the first place because of performance concerns based on some tests I have done on
I like the general idea of this but I want to hold of on that for now. In preperation for 3.1, I would like to refactor ContinuousSpace and add the agent movement as mixins analous to how its done with |
What's the problem this feature will solve?
Depending on the type of space, how you have to get the agents in the space differs. This is shown below with pseudo code and represents my current best guess. This makes the plotting of spaces much more complicated than it needs to be because it requires you to write custom agent getters for at least 4 cases.
Describe the solution you'd like
I propose to add an
agents
property to all spaces (new and old) that returns an iterator over the agents in the space. This would enable cleaning up the matplotlib and altair code for plotting spaces quite a bit. Implementing this would be a stepping stone in in addressing #2401.The text was updated successfully, but these errors were encountered: