예제 #1
0
def smart_drive_to(bot, target: Vec3) -> Turn:
    """
    Find a turn that will get us to the target position and avoid creating short line segments
    """
    car = bot.info.my_car
    speed = min(2295, norm(car.vel) * 1.4)
    next_turn_pos = car.pos if bot.can_turn(
    ) else car.pos + car.forward * speed * bot.time_till_turn()
    line_seg_min_len = speed * TURN_COOLDOWN
    # local.x: how far in front of my car
    # local.y: how far to the left of my car
    # local.z: how far above my car
    delta_local = dot(target - next_turn_pos, car.rot)
    SOME_SMALL_VALUE = 20
    if delta_local.x < 0:
        delta_local.x = -delta_local.x
    if SOME_SMALL_VALUE < delta_local.x < line_seg_min_len:
        # Turning now results in a miss later
        return Turn.no_turn(car)
    else:
        return drive_to(bot, target)