def update(self):
agents = self.simulation.agents.array
field = self.simulation.field
for target in range(len(field.targets)):
has_target = agents['target'] == target
if not has_target.size:
continue
mgrid, distance_map, direction_map = field.navigation_to_target(
target, self.step, self.radius, self.strength)
# Flip x and y to array index i and j
indices = np.fliplr(mgrid.indicer(agents[has_target]['position']))
new_direction = getdefault(
indices, direction_map, agents[has_target]['target_direction'])
agents['target_direction'][has_target] = new_direction
评论列表
文章目录