5

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.

EDIT:

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.

Thomas Owens
  • 79,623
  • 18
  • 192
  • 283
  • 1
    Check out http://amix.dk/blog/post/19588 (Reddit ranking algorithm) – Matthew Jan 02 '14 at 22:05
  • 4
    Something like Elo rating might be appropriate http://en.wikipedia.org/wiki/Elo_rating_system – Dirk Holsopple Jan 02 '14 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 Jan 02 '14 at 22:12
  • Most ranking systems base their result on the strength of the player you beat. Elo is a really primitive but popular system, [Whole-History Rating](http://remi.coulom.free.fr/WHR/WHR.pdf) is a nice advanced one. – CodesInChaos Jan 02 '14 at 22:18
  • And you may also want to look at [Glicko rating system](http://en.wikipedia.org/wiki/Glicko_rating_system) which in addition to the strength of the player, also maintains information about the confidence of that rating. Someone 1-0, you don't have a confident score, while 20-3 player would have more confidence about that rating. –  Jan 02 '14 at 22:25
  • 5
    Isnt the correct answer to give 10 pts per win, and -2 for a loss? :-) – GrandmasterB Jan 02 '14 at 22:54
  • ya know, I think I can make that work. altho it would have to be more like 10 -5to7 I'd think. Cause a record of 100/50 is 900. where as a record of 90-0 is 900. Think the 90-0 is better, but I think I can work off this. – user3130423 Jan 02 '14 at 23:24
  • I edited my answer a little bit. If you still have problems to understand it, please write a comment which point is unclear and I will try to improve my explanation. – Doc Brown Jan 03 '14 at 06:44
  • 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 Jan 03 '14 at 08:11
  • 1
    @GrandmasterB [Where did you get that idea for scoring](http://programmers.stackexchange.com/help/whats-reputation)? –  Jun 30 '15 at 02:46

5 Answers5

10

http://www.evanmiller.org/how-not-to-sort-by-average-rating.html

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.

Austin
  • 716
  • 1
  • 5
  • 7
  • 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 Apr 28 '21 at 16:32
5

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

f(k)=10-k 

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.

Doc Brown
  • 199,015
  • 33
  • 367
  • 565
  • 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 Jan 03 '14 at 08: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 Jan 03 '14 at 09:13
1

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.

Blrfl
  • 20,235
  • 2
  • 49
  • 75
  • 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? –  Jan 03 '14 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 Jan 03 '14 at 23:12
0

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.

ptyx
  • 5,851
  • 2
  • 22
  • 21
  • Someone with 100 losses is going to rank better than someone with 30 wins... Not a good system at all. – Izkata Jan 09 '14 at 00: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 Jan 09 '14 at 17:01
0

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.

James Snell
  • 3,168
  • 14
  • 17