logic.py 文件源码

python
阅读 45 收藏 0 点赞 0 评论 0

项目:crowddynamics 作者: jaantollander 项目源码 文件源码
def update(self):
        agents = self.simulation.agents.array
        field = self.simulation.field

        # FIXME: virtual obstacles add too much computational overhead
        # obstacles = geom_to_linear_obstacles(
        #     field.obstacles.buffer(0.3, resolution=3))
        obstacles = geom_to_linear_obstacles(field.obstacles)
        direction_herding = leader_follower_with_herding_interaction(
            agents, obstacles, self.sight_follower, self.size_nearest_other)
        is_follower = agents['is_follower']
        agents['target_direction'][is_follower] = direction_herding[is_follower]

        # Set target direction for herding agents that do not have a target
        # if field.obstacles is None:
        #     agents['target_direction'][is_follower] = direction_herding[is_follower]
        # else:
        #     # Obstacle avoidance
        #     mgrid = field.meshgrid(self.step)
        #     dir_map_obs, dmap_obs = field.direction_map_obstacles(self.step)
        #     indices = np.fliplr(mgrid.indicer(agents['position'][is_follower]))
        #     direction = obstacle_handling_continuous(
        #         dmap_obs, dir_map_obs, direction_herding[is_follower], indices,
        #         self.radius, self.strength)
        #     agents['target_direction'][is_follower] = direction
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号