Skip to content
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

Agent.die() #2150

Closed
wants to merge 6 commits into from
Closed

Conversation

catherinedevlin
Copy link
Contributor

Continued from #1354. See also #2149 for the remainder of that PR's methods.

I'm less confident that this PR should me merged, since

  • It only joins together two method calls that already exist anyway
  • It creates a confusing failure mode (if a model is successfully removed from the schedule, but removal from the space fails, should it be added back to the schedule?)
  • If it's called for an Agent in a Model without a Space, perhaps the second failure (to remove the model from space) should not be considered a failure at all? In that case, though, it should really just be a call to self.model.schedule.remove(self)

GaelLucero and others added 6 commits May 27, 2022 17:34
…ion, which calculates the next position the agent will move. move_forward function, which moves the agent forward by specified amount. move_backward function, which moves the agent backwards by specified amount. turn_right function, turns the agent right by specified degree. turn_left function, turns the agent left by specified degree.
…d parameters. set_pos function, sets the current position to the specified pos parameter. distancexy function, gives you the distance of the agent and the given coordinate. distance function, gives you the distance between the agent and another agent.
…he grid. towardsxy function, calculates angle between a given coordinate and horizon as if the current position is the origin. towards function, calculates angle between an agent and horizon as if the current position is the origin. facexy function, makes agent face a given coordinate. face function, makes agent face another agent
Those are included in projectmesa#2149
@EwoutH
Copy link
Member

EwoutH commented May 29, 2024

Thanks for this PR! A convenient, complete and robust method to remove agents is certainly useful.

I'm only wondering if there aren't redundant elements in this PR. @quaquel if I'm correct, the current weakrefs already do a large part of the heavy lifting, right?

Also, we have to make clear how this differs from Agent.remove():

mesa/mesa/agent.py

Lines 67 to 70 in 6507f51

def remove(self) -> None:
"""Remove and delete the agent from the model."""
with contextlib.suppress(KeyError):
self.model.agents_[type(self)].pop(self)

And maybe check if it needs to be removed from AgentSets the agent is part of:

def remove(self, agent: Agent):

@EwoutH
Copy link
Member

EwoutH commented Jul 3, 2024

@catherinedevlin would you like to continue with this PR? If so we can discuss the differences between die and remove.

@EwoutH
Copy link
Member

EwoutH commented Aug 17, 2024

Closing for now due to lack of response. If anyone wants to work further on it, feel free to leave a message here!

@EwoutH EwoutH closed this Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants