-
Notifications
You must be signed in to change notification settings - Fork 14
[Feature]: adding abstraction of optimal agent movement #108
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
Comments
hi @adamamer20, I tried to understand this issue, if I am correct this feature aims to write a function which upon calling would solve the issue of multiple agents trying to move on the same grid at the same time which will prevent us from dealing with those edge cases everytime. |
@suryanshgargbpgc You're correct in your understanding! I recommend checking out the sugarscape example for polars to get a clear picture of these concurrency conditions. You can see it here: In this example, the best move might be the same for multiple agents at the same time. Since we're moving all ants simultaneously in a vectorized way, it's important to address this issue. I handled it this way in sugarscape, and I believe the same reasoning can be generalized to accommodate various agent attribute objectives, removing the burden of the implementation on the user |
Hi @adamamer20, sorry I had my exams, I was thinking the function could look something like First, the function gathers all possible moves for each agent into a list. Each move records the candidate grids’ attribute value (like sugar) and a random number when conflict occurs. Next, the list is sorted so that grids with the best sugar value comes first (with the random number resolving ties). Then, the function iterates through the sorted moves and assigns each agent to the target grid if that agent hasn’t been assigned a move yet and the grid is still free. If an agent doesn’t secure a new grid, it remains in its original position. Finally, the agents’ positions are updated accordingly. does it look fine? |
Hey @suryanshgargbpgc! Thanks for sharing the idea—it’s definitely an interesting approach. I have a few considerations that might help refine it:
If you’d like to try building this out, feel free to open a PR! I’d be happy to help if you get stuck. It’s not the easiest problem to implement, but it’s definitely one of the more interesting ones. Good luck! |
It would be beneficial to have a function in the DiscreteSpaceDF (and AgentContainer) for moving agents based on attributes:
For example:
move_to('sugar', 'max')
. This would abstract the code for handling sequential conflicts, making it easier than handling them from scratch each time.The text was updated successfully, but these errors were encountered: