コード例 #1
0
 def test_interval_point_distance(self):
     point_begin = geometry.Point(-1, 0)
     point_end = geometry.Point(1, 0)
     self.assertAlmostEqual(
         geometry.interval_point_distance(point_begin, point_end, geometry.Point(0, 1)),
         1
     )
     self.assertAlmostEqual(
         geometry.interval_point_distance(point_begin, point_end, geometry.Point(2, 0)),
         1
     )
コード例 #2
0
    def pass_condition(self, env, strike_point):
        if env.world.tick - self.history.game_start_tick <= 75:
            return True

        pass_taker = self.count_pass_taker(env)
        if geometry.distance(self.hwp, pass_taker) > 200:
            for oh in shortcuts.opponent_field_hockeyists(env):
                if geometry.interval_point_distance(self.hwp, strike_point, oh) < 60:
                    return True

        if any(geometry.point_in_convex_polygon(self.hwp, p) for p in self.precount.dead_polygons):
            return True

        return False
コード例 #3
0
    def pass_condition(self, env, strike_point):
        if env.world.tick - self.game_start_tick <= 75:
            return True

        collega = filter(lambda h: h.id != env.me.id, shortcuts.my_field_hockeyists(env))[0]
        net_center = shortcuts.net_front_center(env, shortcuts.opponent_player(env))
        if geometry.distance(collega, env.me) > 200:
            for oh in shortcuts.opponent_field_hockeyists(env):
                # my_angle = geometry.ray_ray_angle(env.me, strike_point, net_center)
                # o_angle = geometry.ray_ray_angle(oh, strike_point, net_center)
                # my_distance = geometry.distance(env.me, strike_point)
                # o_distance = geometry.distance(oh, strike_point)

                # if my_angle > o_angle and my_distance > o_distance:
                #     return True

                if geometry.interval_point_distance(env.me, strike_point, oh) < 60:
                    return True

        if any(geometry.point_in_convex_polygon(env.me, p) for p in self.dead_polygons):
            return True

        return False