# How to sort leaderboards, given wins and total games played?

The game is card game. The only results I get is wins and TGP (total games played). Losses = TGP - wins. I want to rank the players in the most fair way without making it too complex. What I have considered for now:

1. Sort by wins only: This does not work very well, as players who have played more games will be always on top, even if they lose most of the time.

2. Sort by wins / TGP: This is better, but still has flaws. A player who has 1 win and 1 game will be in front of player who has 99 wins and 100 games. What seems absurd.

3. Use 2 but limit leaderboards to players with at least X games: This will still give non fair results for players who have exceeded the limit by far.

• Do you have access to history? Like has won % of last 100 games? May 16, 2022 at 11:19
• @Zibelas nope I don't have it May 16, 2022 at 11:22
• Does it has to be one leaderboard or can it be a few of them, grouped by total games played? Like newby board with 10 or less games, beginner with 50 or less, etc. Additional it might be possible to group it location based. With only 2 metrics are is only so much you can do May 16, 2022 at 11:25
• I has to be one board :/ . Did not get the location idea. May 16, 2022 at 11:32
• Location based user data, means you would not display all players from the world in one leader board but usually by region. May 16, 2022 at 11:35

One option is to add a constant to both values:

RankScore = (Wins + Inertia) / (Total + 2 * Inertia)


I called this constant "Inertia" because it creates a resistance to moving up and down the ranks, especially for players who have not played many games yet. You can tune the constant up or down to control how strong the effect is.

Effectively, this models some number of past games played at a perfect 50/50 win rate. So a new player who wins their first match enters the leaderboard only a little above halfway up, instead of at the top.

As the player increases their total games played, their true wins and games played come to dominate the equation, so a player who goes on a winning streak will gradually approach the upper bound score of 1 (asymptotically — they'll never reach it, but the more games they win, the closer they'll get).

You could also make this not a constant, but a function of total games played, something like:

NewPlayerBias = Max(0, TrialPeriod - Total)
RankScore = (Wins + NewPlayerBias) / (Total + 2 * NewPlayerBias)


This way, the bias goes away entirely once the player has played at least TrialPeriod games. In this form, it's saying "we have too little data on you to accurately assess your rank, so we're going to hedge our bets on the assumption that you're about average, statistically". And then smoothly falling back to a simple win percentage once you're satisfied you've collected enough data to have a fair assessment.

Just to double-check that this bias hasn't made our score behave unintuitively in any cases:

• Winning during the trial period doesn't change the numerator (+1 win, -1 bias), but it does reduce the denominator by 1 (+1 game, -2 bias), so you're guaranteed your score strictly improves when you win.

• Losing during the trial period makes both numerator and denominator reduce by one. A little algebra will show that as long as the numerator and denominator are positive, and the numerator is less than or equal to the denominator, both of which are true by construction here, the score strictly decreases in this case.

So we never get a paradoxical result where losing a match makes our score go up or winning a match makes our score go down, because of the way the bias fades out.

Here's a graph showing how the rank score smooths out the wild fluctuations of a new player, for random patterns of wins and losses, converging to a regular win rate measure at the end of the trial period:

• Thanks man. You are the god here. May 16, 2022 at 14:01