Library for ELO calculations for game leagues
- Fully configurable starting rating, k-factor, and xi values
- Support for n-sized teams
- "Exhibition" period: first n games can have and adjustment multiplier in order to move a player to their proper rating faster. Other players will get an inverse multiplier.
First, start a league by creating a league object with the configuration for the league:
val league = League(kFactorBase = 32, trialKFactorMultiplier = 2)
You will probably want to persist this information within your application so that you can re-create this object at anytime
Next, build the game information objects:
val game = Game(
id = UUID.randomUUID().toString(),
team1Score = 10,
team2Score = 0,
team1PlayerIds = listOf(player1Id),
team2PlayerIds = listOf(player2Id),
entryDate = Instant.now())
Player ids are an identifier supplied by you. Just make sure that the values are consistent for a given player across all games. Then, you can calculate the ratings:
val output : LeagueState = calculateNewLeague(league = league, games = listOf(game))
view the LeagueState
class for information on the output.
To add more games, you do not need to repeat all of these steps.
Simply use the previously calculated LeagueState
:
val updatedResults : LeagueState = addGameToLeague(leagueState = leagueState, game = newGame)