-
Notifications
You must be signed in to change notification settings - Fork 892
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 spatial methods from GaelLucero #2149
base: main
Are you sure you want to change the base?
Conversation
…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
- Omitted .setxy, .set_pos as unnecessary setters - added defaults - raise exception if model has no space - moved .die to separate PR - added tests
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Thanks a lot for reviving this effort!
I would love to hear a little bit more about this. Another question I would have is if this would work with the new experimental Cell Space. Edit
Having methods in a default Agent that only work with a single space is something I might need a bit convincing on. |
Those are included in projectmesa#2149
interrupts execution; behavior depends on config We don't necessarily want failures in agent motion to interrupt overall execution
I see you made some new commits, does everything now work in continuous and discrete space? |
For reference, some further work on this is being done in |
Adapted from #1354
In In-person conversation with @jackiekazil at PyCon, we decided not move the methods to an Agent subclass. The burden of carrying along sometimes-irrelevant methods seemed smaller than the cognitive load of making end users choose which Agent class to use.
Suggesting several changes to GL's code:
Removed .die from this PR since it's different in theme, and it deserves a discussion about how necessary it is.
This PR assumes a model with ContinuousSpace, and throws an exception if the methods are called without it. We might want a follow-up PR that would implement the methods for grids, but we would have to decide whether headings and positions should be limited to those that fit neatly into the grid (only headings of 0, 45, 90, 135... for square grids, for instance), or whether to permit non-aligned headings and positions and then round off positions after each move.