Пример #1
0
 def __init__(self, env):
     op = shortcuts.opponent_player(env)
     mp = shortcuts.my_player(env)
     self.attack_polygons = experiments.count_optimistic_attack_polygons(
         env, op)
     self.target_polygons = [
         experiments.count_target_up_attack_polygon(env, op),
         experiments.count_target_down_attack_polygon(env, op),
     ]
     self.defence_point = experiments.count_defence_point(env)
     self.weak_polygons = experiments.count_cautious_attack_polygons(
         env, mp)
     self.dead_polygons = experiments.count_dead_polygons(env, op)
Пример #2
0
    def move(self, me, world, game, move):

        env = environment.Environment(me, world, game, move)

        if world.tick == 0:
            op = shortcuts.opponent_player(env)
            mp = shortcuts.my_player(env)
            self.attack_polygons = experiments.count_optimistic_attack_polygons(env, op)
            self.target_polygons = [
                experiments.count_target_up_attack_polygon(env, op),
                experiments.count_target_down_attack_polygon(env, op),
            ]
            self.defence_point = experiments.count_defence_point(env)
            self.weak_polygons = experiments.count_cautious_attack_polygons(env, mp)
            self.dead_polygons = experiments.count_dead_polygons(env, op)

            self.last_puck_owner_player_id = None

        self.save_last_puck_owner(env)
        self.save_start_game_tick(env)

        if env.me.state == HockeyistState.SWINGING:
            if self.swing_condition(env):
                env.move.action = ActionType.SWING

            if self.strike_condition(env):
                env.move.action = ActionType.STRIKE

            return

        hockeyist_with_puck = shortcuts.hockeyist_with_puck(env)
        my_nearest_hockeyist = min(
            shortcuts.my_field_hockeyists(env), key=lambda h: assessments.ticks_to_reach_point(env, h, env.world.puck)
        )
        if hockeyist_with_puck is None or hockeyist_with_puck.player_id != env.me.player_id:
            if my_nearest_hockeyist.id == me.id:
                self.do_get_puck_actions(env)
            else:
                self.do_protect_goal_actions(env)
        elif hockeyist_with_puck.player_id == env.me.player_id:
            if hockeyist_with_puck.id == env.me.id:
                self.attack_with_puck(env)
            else:
                self.do_protect_goal_actions(env)