Ejemplo n.º 1
0
def get_sales_score(competition_name):
    results = parse_columns(competition_name + "/sales.tsv")
    scores = {}

    for car in results:
        carNum = car["Car Number"] if "Car Number" in car else car["Car No."]
        score = car ['Final Score']
        if carNum not in scores or scores[carNum] < float(score):
            scores[carNum] = float(score)

    return scores
Ejemplo n.º 2
0
def get_design_score(competition_name):
    scores = {}
    path_name = competition_name + "/design.tsv"
    if not os.path.isfile(path_name):
        return scores

    results = parse_columns(path_name)

    for car in results:
        carNum = car["Car Number"] if "Car Number" in car else car["Car No."]
        score = car ['Final Score']
        scores[carNum] = float(score)

    return scores
Ejemplo n.º 3
0
def get_design_score(competition_name):
    scores = {}
    path_name = competition_name + "/design.tsv"
    if not os.path.isfile(path_name):
        return scores

    results = parse_columns(path_name)

    for car in results:
        carNum = car["Car Number"] if "Car Number" in car else car["Car No."]
        score = car['Final Score']
        scores[carNum] = float(score)

    return scores
Ejemplo n.º 4
0
def get_accel_score(competition_name):
    debug = False
    worst = 0
    best = 1000
    results = parse_columns(competition_name + "/accel.tsv")

    #first make sure that only each car's best results are represented
    corrected_results = {}

    for car in results:
        time = float(car['Time'])
        carNum = car["Car Number"] if "Car Number" in car else car["Car No."]
        if carNum in corrected_results:
            if corrected_results[carNum] > time and time > 0:
                corrected_results[carNum] = time

        elif time > 0:
            corrected_results[carNum] = time

    for time in corrected_results.values():
        if time < best:
            best = time

        if time > worst:
            worst = time

    #if the slowest car is really slow, there is a floor on the worst time
    if worst > 1.5 * best:
        worst = 1.5 * best

    if debug:
        print worst
        print best

    scores = {}

    for carNum in corrected_results.keys():
        time = corrected_results[carNum]
        if time > worst:
            scores[carNum] = 0
        else:
            score = 75 * (worst - time) / (worst - best)
            scores[carNum] = score

    if debug:
        print scores['35']

    return scores
Ejemplo n.º 5
0
def get_hill_score(competition_name):
    max_points = 75
    result = {}
    scores = parse_columns(competition_name + "/hill.tsv")
    #first figure out the scores of those who made it
    fastest_complete_time = float("inf")
    max_distance = 0
    max_distance_no_finish = 0
    min_distance_no_finish = float("inf")
    for score in scores:
        time = float(score["Time"])
        if get_distance(score) > max_distance_no_finish:
            max_distance_no_finish = get_distance(score)

        if get_distance(score) < min_distance_no_finish:
            min_distance_no_finish = get_distance(score)

        if time > 0 and time < fastest_complete_time:
            max_distance = get_distance(score)
            fastest_complete_time = time

    for score in scores:
        time = float(score["Time"])
        if time > 0:
            car_number = score[
                "Car Number"] if "Car Number" in score else score["Car No."]
            points = max_points * fastest_complete_time / time
            add_better_score(result, points, car_number)

    lowest_full_complete_score = float("inf")
    for current_points in result.values():
        if current_points < lowest_full_complete_score:
            lowest_full_complete_score = current_points

    #now do everyone else
    for score in scores:
        car_number = score["Car Number"] if "Car Number" in score else score[
            "Car No."]
        if max_distance is 0:
            points = 75 * (get_distance(score) - min_distance_no_finish) / (
                max_distance_no_finish - min_distance_no_finish)
        else:
            points = lowest_full_complete_score * get_distance(
                score) / max_distance

        add_better_score(result, points, car_number)

    return result
Ejemplo n.º 6
0
def get_accel_score(competition_name):
    debug = False
    worst = 0
    best = 1000
    results = parse_columns(competition_name + "/accel.tsv")

    #first make sure that only each car's best results are represented
    corrected_results = {}

    for car in results:
        time = float(car['Time'])
        carNum = car["Car Number"] if "Car Number" in car else car["Car No."]
        if carNum in corrected_results:
            if corrected_results[carNum] > time and time > 0:
                corrected_results[carNum] = time

        elif time > 0:
            corrected_results[carNum] = time

    for time in corrected_results.values():
        if time < best:
            best = time

        if time > worst:
            worst = time

    #if the slowest car is really slow, there is a floor on the worst time
    if worst > 1.5 * best:
        worst = 1.5 * best

    if debug:
        print worst
        print best

    scores = {}

    for carNum in corrected_results.keys():
        time = corrected_results[carNum]
        if time > worst:
            scores[carNum] = 0
        else:
            score = 75 * (worst - time) / (worst - best)
            scores[carNum] = score

    if debug:
        print scores['35']

    return scores
Ejemplo n.º 7
0
def get_cost_score(competition_name):
    debug = False
    path_name = competition_name + "/cost.tsv"
    if not os.path.isfile(path_name):
        return {}

    results = parse_columns(path_name)
    scores = {}

    for car in results:
        carNum = car["Car Number"] if "Car Number" in car else car["Car No."]
        score = car ['Final Score']
        scores[carNum] = float(score)

    if debug:
        print scores['1']

    return scores
Ejemplo n.º 8
0
def get_cost_score(competition_name):
    debug = False
    path_name = competition_name + "/cost.tsv"
    if not os.path.isfile(path_name):
        return {}

    results = parse_columns(path_name)
    scores = {}

    for car in results:
        carNum = car["Car Number"] if "Car Number" in car else car["Car No."]
        score = car['Final Score']
        scores[carNum] = float(score)

    if debug:
        print scores['1']

    return scores
Ejemplo n.º 9
0
def get_hill_score(competition_name):
    max_points = 75
    result = {}
    scores = parse_columns(competition_name + "/hill.tsv")
    #first figure out the scores of those who made it
    fastest_complete_time = float("inf")
    max_distance = 0
    max_distance_no_finish = 0
    min_distance_no_finish = float("inf")
    for score in scores:
        time= float(score["Time"])
        if get_distance(score) > max_distance_no_finish:
            max_distance_no_finish = get_distance(score)

        if get_distance(score) < min_distance_no_finish:
            min_distance_no_finish = get_distance(score)

        if time > 0 and time < fastest_complete_time:
            max_distance = get_distance(score)
            fastest_complete_time = time

    for score in scores:
        time= float(score["Time"])
        if time > 0:
            car_number = score["Car Number"] if "Car Number" in score else score["Car No."]
            points = max_points * fastest_complete_time / time
            add_better_score(result, points, car_number)

    lowest_full_complete_score = float("inf")
    for current_points in result.values():
        if current_points < lowest_full_complete_score:
            lowest_full_complete_score = current_points

    #now do everyone else
    for score in scores:
        car_number = score["Car Number"] if "Car Number" in score else score["Car No."]
        if max_distance is 0:
            points = 75 * (get_distance(score) - min_distance_no_finish) / (max_distance_no_finish - min_distance_no_finish)
        else:
            points = lowest_full_complete_score * get_distance(score)  / max_distance

        add_better_score(result, points, car_number)

    return result
Ejemplo n.º 10
0
def get_manuv_score(competition_name, time_column):
    debug = False
    worst = 0
    best = 1000
    results = parse_columns(competition_name + "/manuverability.tsv")
    corrected_results = {}

    for car in results:
        time = float(car[time_column])
        carNum = car["Car Number"] if "Car Number" in car else car["Car No."]
        if carNum in corrected_results:
            if corrected_results[carNum] > time and time > 0:
                corrected_results[carNum] = time

        elif time > 0:
            corrected_results[carNum] = time

    for time in corrected_results.values():
        if time < best and time > 0:
            best = time
        if time > worst:
            worst = time

    if debug:
        print worst
        print best

    if worst > 2.5 * best:
        worst = 2.5 * best

    scores = {}

    for carNum in corrected_results.keys():
        time = float(corrected_results[carNum])
        if time > worst:
            scores[carNum] = 0
        else:
            ratio = (worst - time) / (worst - best)
            scores[carNum] = 75 * ratio

    if debug:
        print scores['35']

    return scores
Ejemplo n.º 11
0
def get_manuv_score(competition_name, time_column):
    debug = False
    worst = 0
    best = 1000
    results = parse_columns(competition_name + "/manuverability.tsv")
    corrected_results = {}

    for car in results:
        time = float(car[time_column])
        carNum = car["Car Number"] if "Car Number" in car else car["Car No."]
        if carNum in corrected_results:
            if corrected_results[carNum] > time and time > 0:
                corrected_results[carNum] = time

        elif time > 0:
            corrected_results[carNum] = time

    for time in corrected_results.values():
        if time < best and time > 0:
            best = time
        if time > worst:
            worst = time

    if debug:
        print worst
        print best

    if worst > 2.5 * best:
        worst = 2.5 * best

    scores = {}

    for carNum in corrected_results.keys():
        time = float(corrected_results[carNum])
        if time > worst:
            scores[carNum] = 0
        else :
            ratio = (worst-time)/(worst-best)
            scores[carNum] = 75*ratio

    if debug:
        print scores['35']

    return scores
Ejemplo n.º 12
0
def get_st_score(competition_name, time_column):
    debug = False
    max_points = 75
    result = {}
    scores = parse_columns(competition_name + "/suspTraction.tsv")
    #first figure out the scores of those who made it
    fastest_complete_time = float("inf")
    max_distance = 0
    for score in scores:
        time = float(score[time_column])
        if time > 0 and time < fastest_complete_time:
            max_distance = get_distance(score)
            fastest_complete_time = time

    if (debug):
        print("Fastest complete time: " + str(fastest_complete_time))
        print("Max distance: " + str(max_distance))

    for score in scores:
        time = float(score[time_column])
        if time > 0:
            car_number = score[
                "Car Number"] if "Car Number" in score else score["Car No."]
            points = max_points * fastest_complete_time / time
            add_better_score(result, points, car_number)

    lowest_full_complete_score = float("inf")
    for current_points in result.values():
        if current_points < lowest_full_complete_score:
            lowest_full_complete_score = current_points

    if (debug):
        print("Lowest complete score: " + str(lowest_full_complete_score))

    #now do everyone else
    for score in scores:
        car_number = score["Car Number"] if "Car Number" in score else score[
            "Car No."]
        points = lowest_full_complete_score * get_distance(
            score) / max_distance
        add_better_score(result, points, car_number)

    return result
Ejemplo n.º 13
0
def get_st_score(competition_name, time_column):
    debug = False
    max_points = 75
    result = {}
    scores = parse_columns(competition_name + "/suspTraction.tsv")
    #first figure out the scores of those who made it
    fastest_complete_time = float("inf")
    max_distance = 0
    for score in scores:
        time= float(score[time_column])
        if time > 0 and time < fastest_complete_time:
            max_distance = get_distance(score)
            fastest_complete_time = time

    if(debug):
        print("Fastest complete time: " + str(fastest_complete_time))
        print("Max distance: " + str(max_distance))

    for score in scores:
        time= float(score[time_column])
        if time > 0:
            car_number= score["Car Number"] if "Car Number" in score else score["Car No."]
            points = max_points * fastest_complete_time / time
            add_better_score(result, points, car_number)

    lowest_full_complete_score = float("inf")
    for current_points in result.values():
        if current_points < lowest_full_complete_score:
            lowest_full_complete_score = current_points

    if(debug):
        print("Lowest complete score: " + str(lowest_full_complete_score))

    #now do everyone else
    for score in scores:
        car_number= score["Car Number"] if "Car Number" in score else score["Car No."]
        points = lowest_full_complete_score * get_distance(score)  / max_distance
        add_better_score(result, points, car_number)

    return result
Ejemplo n.º 14
0
def get_endurance_score(competition_name):
    debug = False
    path_name = competition_name + "/endurance.tsv"
    if not os.path.isfile(path_name):
        return {}

    results = parse_columns(path_name)
    scores = {}
    max_laps = 0
    min_laps = float("inf")
    carsOnLeadLap = 0
    for car in results:
        laps = int(car['# of Laps'])
        if laps > max_laps:
            max_laps = laps
        if laps < min_laps and laps > 0:
            min_laps = laps

    #figure out bonus points
    for car in results:
        laps = int(car['# of Laps'])
        if laps == max_laps:
            carsOnLeadLap += 1

    if debug:
        print("Number of cars on lead lap: " + str(carsOnLeadLap))

    for car in results:
        carNum = car["Car Number"] if "Car Number" in car else car["Car No."]
        laps = float(car['# of Laps'])
        if laps < min_laps:
            scores[carNum] = 0
        else:
            scores[carNum] = 400 * (laps - min_laps) / (
                max_laps - min_laps) + calc_bonus(car, carsOnLeadLap)

    return scores