shummiev50-1-9.py 文件源码

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

项目:Halite 作者: shummie 项目源码 文件源码
def update_value_maps(self):
        base_value_map = np.divide(self.production_map_01, self.strength_map_1) * (self.is_neutral_map - self.combat_zone_map)
        # Each neutral cell gets assigned to the closest border non-combat cell
        global_targets_indices = np.transpose(np.nonzero(self.is_neutral_map - self.combat_zone_map))
        global_targets = [self.squares[c[0], c[1]] for c in global_targets_indices]
        # border_squares_indices = np.transpose(np.nonzero(self.border_map - self.combat_zone_map))
        # border_squares = [self.squares[c[0], c[1]] for c in border_squares_indices]
        global_border_map = np.zeros((self.w, self.h))

        for g in global_targets:
            # Find the closest border square that routes to g
            gb_map = self.dij_recov_distance_map[g.x, g.y] * (self.border_map - self.combat_zone_map)
            gb_map[gb_map == 0] = 9999
            tx, ty = np.unravel_index(gb_map.argmin(), (self.w, self.h))
            global_border_map[tx, ty] += base_value_map[g.x, g.y] / self.dij_recov_distance_map[g.x, g.y, tx, ty]

        self.value_map = 1 / np.maximum(base_value_map + global_border_map * 1, 0.001)
        print_map(global_border_map, "global_border_")
        print_map(base_value_map, "base_value_")
        print_map(self.value_map, "value_map_")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号