コード例 #1
0
ファイル: tasks.py プロジェクト: samuelpmish/RLBot-Beast
 def resolve(self, prev_status, car, packet: GameTickPacket):
     point = self.pointFunc(car, packet)
     controller = moves.go_towards_point(car,
                                         packet,
                                         point,
                                         slide=self.slide,
                                         boost=self.boost)
     return (ACTION, self.parent, controller)
コード例 #2
0
    def execute(self, data):
        car_to_ball = data.ball_when_hit.location - data.car.location

        # Check dodge. A dodge happens after 0.18 sec
        ball_soon = predict.move_ball(data.ball.copy(), 0.15).location
        car_soon = predict.move_ball(datalibs.Ball().set(data.car), 0.25).location
        car_to_ball_soon = ball_soon - car_soon
        # Aim cone was calculated in utility
        if car_to_ball_soon.length() < 240+92 and self.aim_cone.contains_direction(car_to_ball_soon):
            if data.agent.dodge_control.can_dodge(data):
                data.agent.dodge_control.begin_dodge(data, lambda d: d.ball.location, True)
                data.agent.dodge_control.continue_dodge(data)

        goto, goto_time = self.aim_cone.get_goto_point(data, data.ball_when_hit.location)
        dist = car_to_ball.length()

        self.aim_cone.draw(data.renderer, data.ball_when_hit.location, b=0)
        if goto is None or dist < 450:
            # Avoid enemy corners. Just wait
            if data.ball_when_hit.location.y * datalibs.team_sign(data.enemy.team) > 4400 and abs(data.ball_when_hit.location.x) > 900 and not dist < 450:
                wait_point = data.ball_when_hit.location * 0.5  # a point 50% closer to the center of the field
                wait_point = wait_point.lerp(data.ball.location + Vec3(y=datalibs.team_sign(data.car.team) * 3000), 0.5)
                data.renderer.draw_line_3d(data.car.location.tuple(), wait_point.tuple(), self.color(data.renderer))
                return moves.go_towards_point_with_timing(data, wait_point, 1, True)

            if datalibs.is_point_closer_to_goal(data.car.location, data.ball.location, data.car.team):

                # return home
                enemy_goal = datalibs.get_goal_location(data.enemy.team)
                goal_to_ball = (data.ball_when_hit.location - enemy_goal).normalized()
                offset_ball = data.ball_when_hit.location + goal_to_ball * 92
                data.renderer.draw_line_3d(data.car.location.tuple(), offset_ball.tuple(), self.color(data.renderer))
                return moves.go_towards_point(data, offset_ball, False, True)
            else:
                own_goal = datalibs.get_goal_location(data.car.team)
                if moves.consider_dodge(data, own_goal):
                    return data.agent.dodge_control.continue_dodge(data)
                return moves.go_towards_point(data, own_goal, True, False)
        else:
            if moves.consider_dodge(data, goto):
                return data.agent.dodge_control.continue_dodge(data)
            return moves.go_towards_point_with_timing(data, goto, data.time_till_hit * goto_time * 0.95, True)
コード例 #3
0
    def execute(self, data):
        data.renderer.draw_line_3d(data.car.location.tuple(), (0, 0, 0), data.renderer.create_color(255, 255, 255, 255))

        car_to_ball = -1 * data.car.location
        dist = car_to_ball.length()
        vel_f = data.car.velocity.proj_onto_size(car_to_ball)

        # a dodge is strong around 0.25 secs in
        if dist - 190 < vel_f * 0.3 and data.agent.dodge_control.can_dodge(data):
            data.agent.dodge_control.begin_dodge(data, Vec3(), True)
            return data.agent.dodge_control.continue_dodge(data)
        # make two dodges when spawning far back
        elif dist > 3900 and vel_f > 730 and data.agent.dodge_control.can_dodge(data):
            data.agent.dodge_control.begin_dodge(data, Vec3(), True)
            return data.agent.dodge_control.continue_dodge(data)
        # pickup boost when spawning back corner
        elif abs(data.car.location.x) > 200 and abs(data.car.location.y) > 2880:
            # The pads exact location is (0, 2816)
            pad_loc = Vec3(0, datalibs.team_sign(data.car.team) * 2790, 0)
            return moves.go_towards_point(data, pad_loc, False, True)

        return moves.go_towards_point(data, Vec3(), False, True)
コード例 #4
0
ファイル: tasks.py プロジェクト: samuelpmish/RLBot-Beast
    def resolve(self, prev_status, car, packet: GameTickPacket):
        car_location = Vec3(car.physics.location.x, car.physics.location.y)
        ball_location = Vec3(packet.game_ball.physics.location.x,
                             packet.game_ball.physics.location.y,
                             packet.game_ball.physics.location.z)
        ball_velocity = Vec3(packet.game_ball.physics.velocity.x,
                             packet.game_ball.physics.velocity.y,
                             packet.game_ball.physics.velocity.z)

        own_goal_direction = datalibs.get_goal_direction(car, packet)
        ball_predicted = ball_location + 0.08 * ball_velocity + Vec3(
            y=own_goal_direction * 50)

        dist = (car_location - ball_predicted.flat()).length()
        shouldBoost = dist > 500

        controller = moves.go_towards_point(car,
                                            packet,
                                            ball_predicted,
                                            slide=True,
                                            boost=shouldBoost)
        return (ACTION, self.parent, controller)
コード例 #5
0
 def execute(self, data):
     data.renderer.draw_line_3d(data.car.location.tuple(), self.location.tuple(), data.renderer.create_color(255, 0, 180, 0))
     return moves.go_towards_point(data, self.location, True, self.info.is_full_boost)