[Solved] Wins/losses against stronger/weaker opponents, again

I want to play around with player winrates and stronger/weaker opponents. But I struggle to replicate OGS implementation. My numbers are off by a bit. I try to follow this code.

For example, player 650492. Third ranked game in the list (or fourth if we count one unranked game), id 20514424. Both in rating chat and in game history it appears as loss to weaker opponent.


In rating history frankiehiggs the game corresponds to:

1574527015 20514424 0 5 1269.95 96.24 0.060697 655769 1130.47 96.55 0 {ā€œresultā€: ā€œ11.5 pointsā€}

His rating is 1269.95, opponent’s 1130.47. But he played white and gave 5 handicaps. So we need to do this:

effective_opponent_rating += get_handicap_adjustment(effective_opponent_rating, d.handicap);

export function get_handicap_adjustment(rating:number, handicap:number):number {
return rank_to_rating(rating_to_rank(rating) + handicap) - rating;
}

(why it says there ā€œd.handicapā€ instead of ā€œhandicapā€ like two lines above, at line 104?)

We turn opponent’s rating 1130.47 into ranks, we get 8.911012654718443, plus 5 stones is 13.911012654718443, which translates back into rating as 1326.6188343301117 which is more than our player rating 1269.95, so it’s a loss against stronger opponent?

Sorry for being dense, I’m sure there’s easy explanation but I can’t figure it out. I look at the numbers, and look, and look.

5 Likes

It’s a bug. Fix is on the way.

d.handicap is a string, which causes the math to go wrong. (\me courses javascript for not throwing errors when doing string + int)

Your math is right btw.

3 Likes

… and largely avoidable in OGS typescript code if only we typed everything properly eh!

2 Likes

What chumps would properly assign types in typescript? :sweat_smile:

Nice catch.

3 Likes

Mh… I for one play using Handicap almost exclusively, but I’d probably never have noticed because I’m not much into numbers.

I think it possibly also has something to do with people who play handicap possibly care less whether their opponent was stronger or weaker than them, specifically because handicap is designed to render that point moot.

2 Likes