https://github.com/wakingrufus/lib-elo
Library for ELO calculations for a game league
https://github.com/wakingrufus/lib-elo
elo elo-rating kotlin
Last synced: 1 day ago
JSON representation
Library for ELO calculations for a game league
- Host: GitHub
- URL: https://github.com/wakingrufus/lib-elo
- Owner: wakingrufus
- License: mit
- Created: 2017-11-20T13:55:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-02-28T23:13:26.000Z (over 7 years ago)
- Last Synced: 2025-03-05T01:45:27.754Z (about 1 year ago)
- Topics: elo, elo-rating, kotlin
- Language: Kotlin
- Size: 20.5 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lib-elo
Library for ELO calculations for game leagues
[](https://app.shippable.com/github/wakingrufus/lib-elo)
[](https://app.shippable.com/github/wakingrufus/lib-elo)
[](https://maven-badges.herokuapp.com/maven-central/com.github.wakingrufus/lib-elo)
## Features
- 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.
## Usage
First, start a league by creating a league object with the configuration for the league:
```kotlin
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:
```kotlin
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:
```kotlin
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`:
```kotlin
val updatedResults : LeagueState = addGameToLeague(leagueState = leagueState, game = newGame)
```