atomflunder / skillratings

Rust library for popular skill rating algorithms like Elo, Glicko-2, TrueSkill and many more.
https://docs.rs/skillratings/
Apache License 2.0
38 stars 4 forks source link

[feat. req.] Inverse update (undo)? #2

Open cyqsimon opened 1 year ago

cyqsimon commented 1 year ago

In some cases the user may wish to retroactively invalidate a game and reverse the effects it had on the ratings of the players involved. For example when:

So I think it would be a good idea to provide the inverse of an "update" function, an "undo" if you will.

As far as I know the update algorithm for Elo is invertible, but I'm not sure about other rating systems. Do you think this is something that can be implemented without substantial effort?

atomflunder commented 1 year ago

Hi, thanks for the feature request!

I am by no means a maths expert, but I think since the Elo algorithm uses the previous values to calculate the expected score for the new ratings it would be non-trivial to revert the calculations as far as I know.
As for some of the other algorithms that are not based on Elo I am fairly pessimistic, just off the top of my head the volatility calculations for Glicko-2 will probably be an issue, and the general complexity of the TrueSkill calculations will certainly not be easy.

But if you can find anything please do let me know. I would like to be proven wrong here since I do think this would be a nice addition.

I also run a leaderboard using TrueSkill calculations and the way I revert matches there is to store the ratings and deviations before the game happened in a database to revert back to those values. But this is only an option if both players have not played additional matches, or you would need to re-calculate the games afterwards.
I know this is not the most practical solution.

Again, I do really like the solution and I am open to work on this, if it does prove to be doable. If you want to contribute that would of course be greatly appreciated as well!

marcospb19 commented 5 months ago

I also run a leaderboard using TrueSkill calculations and the way I revert matches there is to store the ratings and deviations before the game happened in a database to revert back to those values.

After invalidating one game, do you re-run calculations for all matches that happened after, or do you just subtract the diff?

atomflunder commented 5 months ago

@marcospb19 Yes, you would need to re-run the calculations for every match affected by it, unfortunately. Subtracting would yield inaccurate results

Maybe we should add a sort of "bulk match calculation" function for this scenario 🤔

marcospb19 commented 5 months ago

I think I'd rather do a for-loop instead :smiley:.