Пример #1
0
    def attack_with_puck(self, env):
        def f(point):
            nfc = shortcuts.net_front_center(env, shortcuts.opponent_player(env))
            angles = [
                min(geometry.degree_to_rad(110), geometry.ray_ray_angle(oh, env.me, point))
                for oh in shortcuts.opponent_field_hockeyists(env)
                if geometry.distance(oh, nfc) > 300
            ]
            ticks_to_reach_point = assessments.ticks_to_reach_point(env, env.me, point)
            if not angles:
                return -ticks_to_reach_point
            return geometry.rad_to_degree(min(angles)) - ticks_to_reach_point / 100

        strike_point = algorithm.best_point_for_polynoms(self.target_polygons, f=f)

        if any(geometry.point_in_convex_polygon(env.me, p) for p in self.attack_polygons):
            goal_point = experiments.get_goal_point(env)
            basic_actions.turn_to_unit(env, goal_point)

            if basic_actions.turned_to_unit(env, goal_point, eps=geometry.degree_to_rad(1.0)):
                env.move.speed_up = 1.0

            if self.swing_condition(env):
                env.move.action = ActionType.SWING

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

        if self.pass_condition(env, strike_point):
            self.do_pass(env)
            return

        experiments.fast_move_to_point_forward(env, strike_point)
Пример #2
0
    def attack_with_puck(self, env, gstrategy):
        strike_point = gstrategy.strike_point

        if any(geometry.point_in_convex_polygon(env.me, p) for p in self.precount.attack_polygons):
            goal_point = experiments.get_goal_point(env)
            basic_actions.turn_to_unit(env, goal_point)

            if basic_actions.turned_to_unit(env, goal_point, eps=geometry.degree_to_rad(1.0)):
                env.move.speed_up = 1.

            if self.swing_condition(env):
                env.move.action = ActionType.SWING

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

        experiments.fast_move_to_point_forward(env, strike_point)
Пример #3
0
 def attack_without_puck(self, env, gstrategy):
     strike_point = gstrategy.strike_point
     strike_point = geometry.mirror_x(strike_point, shortcuts.rink_center(env).x)
     strike_point = geometry.mirror_y(strike_point, shortcuts.rink_center(env).y)
     experiments.fast_move_to_point_forward(env, strike_point)