ctftime / ctftime.org

meta repository for ctftime.org issues, feature-requests etc
68 stars 1 forks source link

The denominator is not calculated in the ctf rating formula #354

Open 1nfim opened 7 months ago

1nfim commented 7 months ago

Hello, after the CTF, I wrote the rating formula in code to calculate it in advance.

However, it was different from the actual applied point, and when I calculated it, the denominator 1/(1 + team_place/total_teams) was not calculated.

Is there a reason why the denominator 1/(1 + team_place/total_teams) is not calculated?

N04M1st3r commented 7 months ago

Hello, I also saw this issue and just to make things easier to check and fix here is the script to do so: Currently calcualte2 is used, which is different from what is written in https://ctftime.org/rating-formula/ (2017+)

def calculate1(team_points, team_place, best_points, weight, total_teams):
    rating = 0.0

    points_coef = float(team_points) / best_points
    place_coef = float(1) / team_place

    if points_coef > 0:
        rating = ((points_coef + place_coef) * weight) / (1/(1+(team_place/total_teams)))

    return round(rating, 3)

def calculate2(team_points, team_place, best_points, weight, total_teams):
    rating = 0.0

    points_coef = float(team_points) / best_points
    place_coef = float(1) / team_place

    if points_coef > 0:
        rating = (points_coef + place_coef) * weight
    return round(rating, 3)

'''
For example:
In the ctf "pingCTF 2023"
Url: https://ctftime.org/event/1987
Team: C0d3 Bre4k3rs
'''
rating1 = calculate1(team_points=2193.000, team_place=18, best_points=5217.000, weight=24.29, total_teams=517)
rating2 = calculate2(team_points=2193.000, team_place=18, best_points=5217.000, weight=24.29, total_teams=517)

ctftime_rating = 11.560
print(rating1) #11.962
print(rating2) #11.56