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.
Description
This PR adds the possibility to access a raw proximity map for each agent. Proximity maps are stored in
AgentState.proximity_map_dist
andAgentState.proximity_map_theta
, which are both of shape(max_agents, max_entities)
. (edit: actually I think it is(max_agents, nb_neighbors)
, which is the same if neighbor_radius is the size of the map, to check). The first one indicates the relative distances from all agents to all entities, the second one indicates the relative orientations. For example,AgentState.proximity_map_theta[i, j]
is the orientation of entity j relative to agent i (i.e. as perceived by agent i, therefore depending on its current front direction).This is propagated to the client side in the Configs. For example, using the NotebookController, you can access the proximity maps of agent
i
withcontroller.agents[i].proximity_map_dist
andcontroller.agents[i].proximity_map_theta
. Here, both maps are of shape(n_entities,)
, because they are relative a single agenti
. For example,controller.agents[i].proximity_map_dist[j]
is the distance of agent i to entity j.The proximity maps will be useful for:
However it might introduce a scaling issue, see #78
Related Issue (if applicable)
Closes #7
Opens #77 #78
How to Test
Launch the server
Launch the Panel interface
Check that agents behaves as expected, because now the prox activations are computed from these proximity maps. I.e. check that aggression, fear, shy, love works correctly.
Then, in a Jupyter notebook, check that the proximity map values are consistent wrt to the relative agent positions. For this, you can first set the behavior of agents to
noop
, so that they don't move. Then you can use this code in the notebook:Check that values in the distance and orientation maps are consistent with the relative positions of the agents in the interface. For example, if entity j is on the left of agent i, then
controller.agents[i].proximity_map_theta[j]
should be roughly equal topi / 4
(modulo 2.pi).I haven't tested how it behave if some agents/entities do not exist, please check this as well.
Will be also useful to test with a smaller
simualtor_state.neighbor_radius
to see if rebuilding the neigbor matrix doesn't break it.Screenshots (if applicable)