File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
examples/basic/boid_flockers Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,8 @@ def __init__(
5858
5959 def step (self ):
6060 """Get the Boid's neighbors, compute the new vector, and move accordingly."""
61- self .neighbors = self .model .space .get_neighbors (self .pos , self .vision , False )
61+ neighbors = self .model .space .get_neighbors (self .pos , self .vision , True )
62+ self .neighbors = [n for n in neighbors if n is not self ]
6263
6364 # If no neighbors, maintain current direction
6465 if not self .neighbors :
Original file line number Diff line number Diff line change @@ -1415,6 +1415,13 @@ def get_neighbors(
14151415 coordinates. i.e. if you are searching for the
14161416 neighbors of a given agent, True will include that
14171417 agent in the results.
1418+
1419+ Notes:
1420+ If 1 or more agents are located on pos, include_center=False will remove all these agents
1421+ from the results. So, if you really want to get the neighbors of a given agent,
1422+ you should set include_center=True, and then filter the list of agents to remove
1423+ the given agent (i.e., self when calling it from an agent).
1424+
14181425 """
14191426 if self ._agent_points is None :
14201427 self ._build_agent_cache ()
You can’t perform that action at this time.
0 commit comments