Ejemplo n.º 1
0
def calculate_third_pick_ability(calculated_data):
    """Calculates the relative third pick score for a team.

    calculated_data is the dictionary of calculated_data calculated for
    a team."""
    # Weights for how much each aspect of the robot is considered for a
    # third pick
    level_1_weight = 0.9
    level_2_weight = 1.1
    level_3_weight = 1.1
    sandstorm_weight = 1.0
    climbing_weight = 0.2

    # Scores for points scored on level 1, 2, and 3.
    level_1_teleop_score = (
        2 * calculated_data['avgPanelsScoredTeleL1'] +
        3 * calculated_data['avgCargoScoredTeleL1']) * level_1_weight
    level_2_teleop_score = (
        2 * calculated_data['avgPanelsScoredTeleL2'] +
        3 * calculated_data['avgCargoScoredTeleL2']) * level_2_weight
    level_3_teleop_score = (
        2 * calculated_data['avgPanelsScoredTeleL3'] +
        3 * calculated_data['avgCargoScoredTeleL3']) * level_3_weight

    # Scores for points gained during sandstorm.
    sand_score = max([
        float(utils.no_none_get(calculated_data, 'habLineSuccessL1', 0)) * 3 /
        100,
        float(utils.no_none_get(calculated_data, 'habLineSuccessL2', 0)) * 6 /
        100
    ])
    sand_score += calculated_data['avgPanelsScoredSandstorm'] * 5
    sand_score += calculated_data['avgCargoScoredSandstorm'] * 3
    sand_score *= sandstorm_weight

    # Scores for points scored in the endgame.
    end_game_score = max([
        3 * float(calculated_data.get('climbSuccessL1', 0)) / 100,
        6 * float(calculated_data.get('climbSuccessL2', 0)) / 100,
        12 * float(calculated_data.get('climbSuccessL3', 0)) / 100
    ])
    end_game_score *= climbing_weight

    # A third pick robot must have a driver ability greater than 0
    # (average) and must score an average of more than 1 cargo per match.
    if (calculated_data['normalizedDriverAbility'] <= 0) or \
        (calculated_data['avgCargoScored'] <= 1):
        return 0

    # Adds all the previous scores together to get a full third pick score.
    return sand_score + level_1_teleop_score + level_2_teleop_score + level_3_teleop_score + end_game_score
Ejemplo n.º 2
0
def calculate_first_pick_ability(calculated_data):
    """Calculates the relative first pick score for a team.

    calculated_data is the dictionary of calculated_data calculated for
    a team."""
    # Weights for how much each aspect of the robot is considered for a
    # first pick.
    level_1_weight = 0.9
    level_2_weight = 1.1
    level_3_weight = 1.1
    sandstorm_weight = 1.0
    climbing_weight = 0.2

    # Scores for points scored on level 1, 2, and 3.
    level_1_teleop_score = (
        2 * calculated_data['avgPanelsScoredTeleL1'] +
        3 * calculated_data['avgCargoScoredTeleL1']) * level_1_weight
    level_2_teleop_score = (
        2 * calculated_data['avgPanelsScoredTeleL2'] +
        3 * calculated_data['avgCargoScoredTeleL2']) * level_2_weight
    level_3_teleop_score = (
        2 * calculated_data['avgPanelsScoredTeleL3'] +
        3 * calculated_data['avgCargoScoredTeleL3']) * level_3_weight

    # Scores for points gained during sandstorm.
    sand_score = max([
        float(utils.no_none_get(calculated_data, 'habLineSuccessL1', 0)) * 3 /
        100,
        float(utils.no_none_get(calculated_data, 'habLineSuccessL2', 0)) * 6 /
        100
    ])
    sand_score += calculated_data['avgPanelsScoredSandstorm'] * 5
    sand_score += calculated_data['avgCargoScoredSandstorm'] * 3
    sand_score *= sandstorm_weight

    # Scores for points scored in the endgame.
    end_game_score = max([
        3 * float(calculated_data.get('climbSuccessL1', 0)) / 100,
        6 * float(calculated_data.get('climbSuccessL2', 0)) / 100,
        12 * float(calculated_data.get('climbSuccessL3', 0)) / 100
    ])
    end_game_score *= climbing_weight

    # Adds all the previous scores together to get a full first pick score.
    return sand_score + level_1_teleop_score + level_2_teleop_score + level_3_teleop_score + end_game_score
Ejemplo n.º 3
0
def calculate_second_pick_ability(calculated_data, max_da, min_da):
    """Calculates the relative second pick score for a team.

    calculated_data is the dictionary of calculated_data calculated for
    a team.
    max_da is the maximum driver ability in the competition, this is
    used to weight driver ability.
    min_da is the minimum driver ability in the competition, this is
    used to weight driver ability."""
    # Weights for how much each aspect of the robot is considered for a
    # second pick.
    climbing_weight = 0.25
    cargo_weight = 0.5
    panels_weight = 1.0
    sandstorm_weight = 1.0
    driving_weight = 18.0
    defense_weight = 3.5

    # Scores for points gained during sandstorm.
    sand_score = max([
        float(utils.no_none_get(calculated_data, 'habLineSuccessL1', 0)) * 3 /
        100,
        float(utils.no_none_get(calculated_data, 'habLineSuccessL2', 0)) * 6 /
        100
    ])
    sand_score += calculated_data['avgPanelsScoredSandstorm'] * 5
    sand_score += calculated_data['avgCargoScoredSandstorm'] * 3
    sand_score *= sandstorm_weight

    # Scores for points scored on level 1.
    level_1_teleop_score = calculated_data[
        'avgPanelsScoredTeleL1'] * 2 * panels_weight
    level_1_teleop_score += calculated_data[
        'avgCargoScoredTeleL1'] * 3 * cargo_weight

    # Scores for points scored in the endgame.
    end_game_score = max([
        3 * float(calculated_data.get('climbSuccessL1', 0)) / 100,
        6 * float(calculated_data.get('climbSuccessL2', 0)) / 100,
        12 * float(calculated_data.get('climbSuccessL3', 0)) / 100
    ])
    end_game_score *= climbing_weight

    # If the max_da is 0.0, all the zscores are equal and there is no
    # point to weighting it.
    if max_da == 0.0:
        driver_ability = 0.0
    else:
        # Otherwise, takes the previously calculated driverAbility and
        # weights it into the pick ability. Scales all driverAbilities
        # between 0 and 'driving_weight'.
        driver_ability = driving_weight * \
            (calculated_data['normalizedDriverAbility'] - min_da)/(max_da - min_da)

    # When the average rank defense is None, the defense_ability should
    # be 0, because the team didn't play defense.
    if calculated_data.get('avgRankDefense') is None:
        defense_ability = 0
    else:
        # Score for defense, based around the lowest being 1, and the
        # highest being 2 times the defense weight + 1. Example: If the
        # weight is 5, the defense ability for an avgRankDefense of 1,
        # 2, and 3 would be 1, 6, and 11 respectively.
        defense_ability = (float(calculated_data['avgRankDefense']) * \
            defense_weight) - (defense_weight - 1)
    return sand_score + level_1_teleop_score + end_game_score + driver_ability + defense_ability