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
41 stars 4 forks source link

Add `TeamRatingSystem` and `Rating` traits #10

Closed jspspike closed 1 year ago

jspspike commented 1 year ago

Each rating system has gone through the trouble having a similar or same interface so I thought it would be beneficial to add traits for the rating system and rating type. This way users could use the crate without having to specify the rating system and easily switch between different ones.

This PR only impls for trueskill at the moment

atomflunder commented 1 year ago

Hi, thanks for your PR!

This makes a lot of sense to me, one of the main features of this crate is supposed to be switching and comparing between rating systems easily and fast.

I think it looks quite good so far, and I would be happy to merge, but I think if we were to do it, we should probably implement it for every rating system and also every type of algorithm (1v1, Team v Team, etc.). This means to also include RatingSystem (1v1), RatingPeriodSystem and MultiTeamRatingSystem (names are obviously not set in stone) and of course implementing all of those for every algorithm currently available.

I would be more than happy to work on doing that, but I can only start working on it properly this weekend. So please feel free to add to this in whichever way you like in the meantime.

atomflunder commented 1 year ago

@jspspike Would you be okay with me adding the traits I described above to this existing PR?
While implementing those I did have some thoughts about the method names, for example the rating method should probably be called something like rate, in my opinion. Also I think it does make sense to add an uncertainty to the Rating trait, as most algorithms included have some form of this in their rating. For edge cases like volatility with Glicko-2 this would obviously not make sense to include those.

jspspike commented 1 year ago

@atomflunder Sure feel free to implement them, you could add directly to this branch. I think your proposals make sense, I guess the concern would be for edge cases where there isn't an uncertainty how to handle those cases. My opinion would be to omit uncertanity unless all implementations could use it but it's your decision on what you think the traits should be like

atomflunder commented 1 year ago

I guess the concern would be for edge cases where there isn't an uncertainty how to handle those cases. My opinion would be to omit uncertanity unless all implementations could use it but it's your decision on what you think the traits should be like

My thought process on this was to add a disclaimer in the documentation, and just return 0 for the cases where there is no uncertainty value.
I thought this would be better for the algorithms that rely heavily on the uncertainty value, for example TrueSkill where the original "display rank" is rating - 3* uncertainty.

To be honest I think both approaches are not 100% optimal, but I personally would prefer adding it. We can always change that later though, if it does end up confusing.

atomflunder commented 1 year ago

@jspspike I added the traits, let me know what you think and if you spot any mistakes. This should be fairly straightforward to add to the other algorithms from here on out, the hardest part is probably the design choices.
There is also still some documentation and new tests missing, but that won't be a big deal to add.

Edit: Oh and ignore that code coverage report obviously for now.

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage has no change and project coverage change: -5.73 :warning:

Comparison is base (398d621) 100.00% compared to head (73ecde9) 94.27%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #10 +/- ## =========================================== - Coverage 100.00% 94.27% -5.73% =========================================== Files 13 13 Lines 7533 7987 +454 =========================================== - Hits 7533 7530 -3 - Misses 0 457 +457 ``` | [Impacted Files](https://app.codecov.io/gh/atomflunder/skillratings/pull/10?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [src/dwz.rs](https://app.codecov.io/gh/atomflunder/skillratings/pull/10?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2R3ei5ycw==) | `95.64% <0.00%> (-4.36%)` | :arrow_down: | | [src/egf.rs](https://app.codecov.io/gh/atomflunder/skillratings/pull/10?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2VnZi5ycw==) | `88.09% <0.00%> (-11.91%)` | :arrow_down: | | [src/elo.rs](https://app.codecov.io/gh/atomflunder/skillratings/pull/10?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2Vsby5ycw==) | `88.96% <0.00%> (-11.04%)` | :arrow_down: | | [src/fifa.rs](https://app.codecov.io/gh/atomflunder/skillratings/pull/10?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2ZpZmEucnM=) | `89.06% <0.00%> (-10.94%)` | :arrow_down: | | [src/glicko.rs](https://app.codecov.io/gh/atomflunder/skillratings/pull/10?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2dsaWNrby5ycw==) | `94.05% <0.00%> (-5.95%)` | :arrow_down: | | [src/glicko2.rs](https://app.codecov.io/gh/atomflunder/skillratings/pull/10?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2dsaWNrbzIucnM=) | `95.89% <0.00%> (-4.11%)` | :arrow_down: | | [src/glicko\_boost.rs](https://app.codecov.io/gh/atomflunder/skillratings/pull/10?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2dsaWNrb19ib29zdC5ycw==) | `94.57% <0.00%> (-5.43%)` | :arrow_down: | | [src/ingo.rs](https://app.codecov.io/gh/atomflunder/skillratings/pull/10?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2luZ28ucnM=) | `90.56% <0.00%> (-9.44%)` | :arrow_down: | | [src/lib.rs](https://app.codecov.io/gh/atomflunder/skillratings/pull/10?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2xpYi5ycw==) | `100.00% <ø> (ø)` | | | [src/sticko.rs](https://app.codecov.io/gh/atomflunder/skillratings/pull/10?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL3N0aWNrby5ycw==) | `94.61% <0.00%> (-5.39%)` | :arrow_down: | | ... and [3 more](https://app.codecov.io/gh/atomflunder/skillratings/pull/10?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

atomflunder commented 1 year ago

@jspspike So if you are okay with it, I would merge this, probably add some more tests and then make a new release for it.

Thank you again for your contribution!

jspspike commented 1 year ago

@atomflunder Looks good to me, thanks for taking the time and adding these traits