Skip to content

The ELO System

LFS Rank implements a Multi-player ELO System tailored for racing and written in Python.

The Exact Source Code Formula

Unlike Chess (1 vs 1), a race involves multiple drivers simultaneously (n). The system breaks down the race by interpolating positions across the entire grid.

Here is the exact validation code block used on the server:

python
def calculate_elo(results: list):
    n = len(results)
    if n < 2: return
    K_FACTOR = 32
    
    for p_i in results:
        # Actual Performance
        actual = (n - p_i['position']) / (n - 1)
        
        # Expected Performance (Average 1v1 win probability against the lobby)
        expected = sum(1 / (1 + 10 ** ((p_j['elo'] - p_i['elo']) / 400)) for p_j in results if p_j != p_i) / (n - 1)
        
        # Score Change
        change = K_FACTOR * (actual - expected)
        p_i['new_elo'] = round(p_i['elo'] + change)
        p_i['elo_change'] = p_i['new_elo'] - p_i['elo']

Variables Breakdown

  • K_FACTOR: Locked at 32. This is the maximum oscillation.
  • Actual: If you finish 1st out of 5, your Actual score is (5 - 1) / 4 = 1.0. If you finish last, it is 0.0.
  • Expected: Algorithmic win probability based on the ELO difference. If your ELO is very high compared to the grid, this will be close to 1.0.

NOTE

Beating highly-ranked rivals grants you up to 32 points, while beating low-ranked opponents yields minimal gain, yet brings massive penalties if you disconnect (DNF) or perform poorly.

Released under the MIT License.