-
Notifications
You must be signed in to change notification settings - Fork 997
Fixed move_agent_to_one_of to handle empty positions correctly #2732
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
Fixed move_agent_to_one_of to handle empty positions correctly #2732
Conversation
Performance benchmarks:
|
Thanks for the PR! You made an improvement to the old space, which is currently maintenance only. So I don’t know if we can accept it, but I will let the other maintainers weigh in. With older issues it’s always worth checking in if they are still relevant. The PR looks well structured by the way! |
Hey @EwoutH Thanks for your feedback! I understand that the old space is in maintenance mode. Should I check if a similar improvement is needed in the newer implementation? Looking forward to hearing from the other maintainers! Thanks again! |
It happens to the best of us :)
@quaquel I think this feature is already covered by the new API, or is it not yet? |
Depends a bit on how you define "this feature". CellCollection has a |
Thanks! @aarav-shukla07 you could study the current discrete space API, and if you come up with an idea to improve/extend it, propose it to us :) |
Hey @EwoutH @quaquel , I'll study the current discrete space API in more detail and see if I can come up with any ideas to improve or extend it. If I find a meaningful improvement, I'll propose it to you for discussion before implementing it. Thanks again for your guidance! Looking forward to contributing further. |
Perfect, I’m closing this PR, looking forward to your future work! |
Summary
This PR improves the move_agent_to_one_of method in space.py by ensuring that agents do not move when no valid positions are available. Previously, if an empty list was provided, the agent would still move unpredictably, leading to incorrect behavior.
Bug / Issue
Fixes part of issue #1903.
Issue Details:
Expected Behavior:
Implementation
Added an early return condition to move_agent_to_one_of when pos is empty.
If handle_empty is "warning", it logs a warning but does not move the agent.
If handle_empty is "error", it raises an exception instead of moving the agent randomly.
Ensured that the agent only moves when a valid target position exists.
Testing
Re-ran full test suite:
Additional Notes