An ELO calculation framework for .NET
The easiest way to get started is to add the NuGet package to your project.
Releases are also tagged and downloadable from this repository.
You may build your own copy of the package from the latest code by pulling from this repository. All of the projects are contained within the solution file (EloDotNet.sln
).
The package provides the following classes:
Player
- represents a participant in the Elo ranking system. Typically uniquely identified with aGuid
property.Match
- represents the participation of twoPlayer
s in the system.- Describes the match results (who won/lost, or if the match was a draw).
- A
Match
can only have oneResult
- whether the first or second player won, or if the match was a draw.
RankingSystem
- encapsulates a collection of participatingPlayer
s, and a list ofMatch
es each player has participated in.
Note that for purposes of Elo calculation, all Player
s must be registered via RankingSystem.RegisterPlayer()
, and all Match
es must be recorded via RankingSystem.RecordMatch()
.
All default classes in EloDotNet implement their respective interfaces:
IPlayer<TId>
- interface for a player entity with a unique identifier of typeTId
.- Note that
TId
must implementIEquatable<TId>
.
- Note that
IMatch<TPlayer, TIndex>
- interface for a match entity between twoTPlayer
entities, and where each match can be ordered using theTIndex
property.- Note that
TPlayer
must implementIPlayer<TId>
. TIndex
must implementIComparable<TIndex>
.
- Note that
IRankingSystem<TPlayer, TMatch>
- interface for a ranking system ofTPlayer
entities participating inTMatch
matches.- Note that
TPlayer
must implementIPlayer<TId>
. - Note that
TMatch
must implementIMatch<TPlayer, TIndex>
.
- Note that
Thus, it is possible to roll your own player, match and ranking system implementations.
RankingSystem
also exposes a generic version with a default implementation, e.g.RankingSystem<IPlayer<TId>, IMatch<TId, TIndex>>
.- This allows you to replace the player and match types while keeping the default Elo calculation algorithm, for instance.
Please check the test project EloDotNet.Tests
to see sample snippets on how to use the default RankingSystem
, as well as creating your custom IMatch
and IPlayer
implementations, and integrating them into a custom IRankingSystem
implementation, with its own Elo calculation algorithm.
As more projects adapt EloDotNet, they'll be featured here for reference!