Skip to content

Agent spatial methods from GaelLucero#2149

Closed
catherinedevlin wants to merge 10 commits intomesa:mainfrom
catherinedevlin:agent-motion
Closed

Agent spatial methods from GaelLucero#2149
catherinedevlin wants to merge 10 commits intomesa:mainfrom
catherinedevlin:agent-motion

Conversation

@catherinedevlin
Copy link
Copy Markdown
Contributor

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:

- Omitted .setxy, .set_pos as unnecessary setters
- added default arguments 
- raise exception if model has no attached ContinuousSpace
- added tests

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.

GaelLucero and others added 9 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
- Omitted .setxy, .set_pos as unnecessary setters
- added defaults
- raise exception if model has no space
- moved .die to separate PR
- added tests
@EwoutH EwoutH requested review from Corvince, EwoutH and quaquel May 26, 2024 20:53
@EwoutH EwoutH added the feature Release notes label label May 26, 2024
@EwoutH EwoutH added this to the v3.0 milestone May 26, 2024
@EwoutH
Copy link
Copy Markdown
Member

EwoutH commented May 26, 2024

Thanks a lot for reviving this effort!

In In-person conversation with @jackiekazil at PyCon, we decided not move the methods to an Agent subclass.

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

This PR assumes a model with ContinuousSpace, and throws an exception if the methods are called without it

Having methods in a default Agent that only work with a single space is something I might need a bit convincing on.

catherinedevlin pushed a commit to catherinedevlin/mesa that referenced this pull request May 26, 2024
Those are included in mesa#2149
@catherinedevlin catherinedevlin mentioned this pull request May 26, 2024
 interrupts execution;  behavior depends on config

We don't necessarily want failures in agent motion to interrupt overall execution
@EwoutH
Copy link
Copy Markdown
Member

EwoutH commented Jul 3, 2024

I see you made some new commits, does everything now work in continuous and discrete space?

@EwoutH
Copy link
Copy Markdown
Member

EwoutH commented Sep 23, 2024

For reference, some further work on this is being done in

@quaquel
Copy link
Copy Markdown
Member

quaquel commented Dec 18, 2025

Thanks again for this @catherinedevlin,

Closing this as stale, but linked to it from #2967. I want to pick up these ideas again, but using the new space implementation that was added in January of 2025.

@quaquel quaquel closed this Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants