You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, at first, I want to express my thanks to this awesome framework!
I want to obtain the neighbors of each agent, i.e., the spacial local view include the observed agents of both group 1 and group 2, I want to obtain the IDs and positions of all it's neighbors.
The text was updated successfully, but these errors were encountered:
This should get you half way there. For a given group, this will return the index positions:
fromscipy.spatial.distanceimportcityblockdefget_neighbors(j,pos_list,r=6):
""" Given [x,y] positions of all agents in `pos_list`, return indices of agents that are within the radius of agent j (i.e. the j'th index in `pos_list`) """neighbors= []
pos_j=pos_list[j]
fori,posinenumerate(pos_list):
ifi==j:
continuedist=cityblock(pos,pos_j)
ifdist<r:
neighbors.append(i)
returnneighbors>>>get_neighbors(5,env.get_pos(team1))
[27, 33, 34, 58]
where team1 is one of the group handles and env is an environment instance. The env.get_pos(...) method returns a list of [x,y] positions for each agent in that group.
Hi, at first, I want to express my thanks to this awesome framework!
I want to obtain the neighbors of each agent, i.e., the spacial local view include the observed agents of both group 1 and group 2, I want to obtain the IDs and positions of all it's neighbors.
The text was updated successfully, but these errors were encountered: