Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces feature to delete agents by their agent id.
To use this feature, you can call
sim.deleteAgents(world_to_agent_dict)
. The dict structure is{world_idx: [agent_ids]}
. Sample code:We set an array
deletedAgents
with agent ids. We reuse functionality ofsetMaps
where we destroy all agents and reinitialize them. But we ignore the agents specified indeletedAgents
. So the agents are not initialized. Remember, because of this the indexing will change. For eg an agent at idx 5 will be at idx 4 after an agent is deleted.Also, the
deletedAgents
array is permanent. You can reset this tensor with -1 values to reinitialize all the agents again. However, I reset thedeletedAgents
array when you callsetMaps
to change the map on runtime because the agent ids will have changed.