ok, am just looking for a win loss code example. This can be for any language, just wanting the outline. Fairly new to programming, so dummy it up for me :)

I can do (win-loss/total of win loss). Guessing that is a good standard win loss ratio, but I don't want a new person that has 1-0 to be ranked higher than someone that has 20-3.

Any help is appreciated and thank you.


The chess styles are a little more than needed. Just want a ranking system with win/loss. so lest say 20-3 is top in league right now. he is, say 23 weeks in so far. if one guy comes in and wins first match against anyone, I don't want him to take #1 spot over people thats been there longer and have a great winning record. To respond to ampt... maybe he will be best in league, but I don't want him instantly there cause he had one good match. Not sure if that clarify any more. Didn't really follow Doc all the way. Looks as if he is hindered in list up to his 11th game. Not sure if thats what you ment there. Thanks again for all reasponses.

  • 1
    Check out amix.dk/blog/post/19588 (Reddit ranking algorithm)
    – Matthew
    Commented Jan 2, 2014 at 22:05
  • 4
    Something like Elo rating might be appropriate en.wikipedia.org/wiki/Elo_rating_system Commented Jan 2, 2014 at 22:07
  • 1
    How do you know that person who is 1-0 isn't better than the 20-3? 1-0 could go on to be 100-0 but 20-3 could never get rid of those 3 losses, even after a thousand games, giving them a worse rank.
    – Ampt
    Commented Jan 2, 2014 at 22:12
  • 5
    Isnt the correct answer to give 10 pts per win, and -2 for a loss? :-) Commented Jan 2, 2014 at 22:54
  • 3
    If you want to see the quality of a player, it's about what players he beats, not about total amount of wins/losses. A 100/50 record against world class players would certainly be better then a 1000/0 record against beginners.
    – Pieter B
    Commented Jan 3, 2014 at 8:11

5 Answers 5



The math is a bit advanced, but the idea is to calculate a confidence interval for the win percentage, and then use the lower bound to rank.

95% confidence intervals for your examples:

20-3: 0.68-0.95
 1-0: 0.21-1.00

Since the 20-3's lower bound is higher (0.68 vs 0.21), it would rank higher.

  • This is a great solution when you want to sort based on ratings. But here we're talking about the result of match-ups... I'm not sure it applies in this case.
    – Joe Strout
    Commented Apr 28, 2021 at 16:32

Here is a very simple solution, not so sophisticated as the chess rating systems suggested in the comments, but easier to implement: divide your current score value (win-loss)/(# of games played) by a "factor of uncertainty f", where f is a high value if the total number of games played is small, and f converges to 1 the more games a player has played. For example, you can choose


after k games as long as k<10, and

f(k)=1 if k>=10

Or, if you want to double the confidence with each game played, choose

f(k) = 2^(5/k)

(the ^ means here "to the power of", translate this to your favorite programming language).

The values 5 or 10 are just arbitrary choosen, reflecting the confidence you want to assign to the a player after one game, and the point where you want to reach (almost) full confidence. Choose your own values accordingly.

  • This method promotes playing against bad players and "farming" wins. With for instance a lot of rating systems, win/loss ratio will converge to 50/50 because the more you play, the more your rating will be accurate and the more you will play against players of the same skill-level.
    – Pieter B
    Commented Jan 3, 2014 at 8:59
  • 1
    @PieterB: as I wrote, its a very simple (I should have wrote simplistic) solution. And who says this is a game where you can arbitrarily choose your opponents?
    – Doc Brown
    Commented Jan 3, 2014 at 9:13

Just want a ranking system with win/loss. so lest say 20-3 is top in league right now. he is, say 23 weeks in so far. if one guy comes in and wins first match against anyone, I don't want him to take #1 spot over people thats been there longer and have a great winning record.

If you want to do it uniformly, temper the win fraction with the amount of participation. The more games a player plays, the more his win fraction counts in the rankings.

An established player with a 20-3 (0.869) record who's played all 23 (1.000) of the possible games has a ranking of 0.869 x 1.000 = 0.869. He loses nothing because of his high participation.

A new player plays one game and wins it (1.000) but is cut back by the fact that he's played only one of the 23 (0.043). His ranking is 1.000 x 0.043 = 0.043. This puts him at the same level as someone who's played all 23 and won only one.

  • If the 1-0 player goes with wins in the next 5 weeks 6-0, how would that compare with someone who was 1-23 at the start and also wins the next 5 games to be 6-23?
    – user40980
    Commented Jan 3, 2014 at 20:40
  • @MichaelT: Both players would be ranked the same because their win fractions and participation factors are identical but backwards (1.000 x 0.206 vs. 0.206 x 1.000). I could come up with other ways to make a new player who does well show up differently in the rankings like making the participation factor logarithmic instead of linear. Whether or not the OP wants to do something like that depends on how complex he wants to make it.
    – Blrfl
    Commented Jan 3, 2014 at 23:12

A very simple solution is to give points for any game played, lost or won.

Score = 3 * win + loss

A new player won't appear in the top ranks until he has a number of matches comparable with other players. This can be good, or bad - if your number of games isn't bound new players might have no practical chance to ever get to the top.

  • Someone with 100 losses is going to rank better than someone with 30 wins... Not a good system at all.
    – Izkata
    Commented Jan 9, 2014 at 0:59
  • Depends what you want to achieve. If number of games is bounded to 100 for instance (seasons?), winner will catch up. It also rewards just playing, which might be desirable. But I agree, extreme simplicity means that it's not going to handle a lot of cases well.
    – ptyx
    Commented Jan 9, 2014 at 17:01

Since you've dismissed the tried and tested option of an ELO style ranking system then you have to re-examine your needs.

[if a player] wins first match against anyone, I don't want him to take #1 spot

... seems to sum things up best. It suggests that a crude win/loss ratio seems to be adequate and that the only requirement is to stop new players from appearing on the leaderboard.

To do that really you just need a minimum game count.

Something like:-

winRatio = win / math.max(win + loss, minMatches)

...would mean that someone would have to win minMatches in order to get that 100% win rate and after that many games they should be starting to find their level anyway.

Ultimately the fairest system for unmatched competitors is more along the ELO lines and you'll find you will want that in the end unless all your players are very evenly matched - I would suggest you code for it now, start using it in the backend and then when they complain that the scoring system is still unfair you can look responsive to user demands when in fact you knew it was coming all along... sometimes our game is all about perception.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.