A lightweight, dependency-free ELO rating library for Java, with support for score-based rating updates
Overview · Features · Quick Start · API · How It Works · Contributing
The ELO rating system calculates the relative skill levels of players as numeric values. After every match, both players' ratings are updated based on the result and on how likely each player was to win beforehand.
Beating a much stronger opponent earns far more rating than beating a much weaker one. That is what makes ELO fair, and it is what this library implements.
This project goes one step beyond the original system: it can also factor in points scored, so a dominant 5-1 win is rewarded more than a narrow 2-1 win.
- ♟️ Classic ELO: updates ratings from the match outcome (win, loss, or draw)
- 🎯 Score-aware updates: three selectable methods that account for points scored
- ⚙️ Fully configurable: tune the K factor, the scale constant
c, and the bonus factorLper league or competition - 📦 Zero dependencies: plain Java, no external libraries
ELO rating = new ELO(32, 400, 16); // adjust to match your package layout
// Outcome only: 0 = draw, 1 = player A won, 2 = player B won
double[] result = rating.elo(1400.0, 1550.0, 1);
// result ≈ { 1422.5, 1527.5 }
// With points scored (method 2 is the default)
double[] scored = rating.elo_with_points(1400.0, 1550.0, 5, 1, 2);Note
The class and package names here are illustrative. Adjust them to match where the ELO class lives in your project.
Creates a rating calculator. Create one instance per league, arena, or competition if they use different settings.
| Parameter | Type | Default | Description |
|---|---|---|---|
k_factor |
int | 32 |
Scaling factor K: how much a single match can move a rating |
c_value |
int | 400 |
Scale constant c used in the expected-score formula |
l_factor |
int | 16 |
Second scaling factor L: bonus weight for points scored (method 2) |
Updates ratings using only the match outcome.
| Parameter | Type | Description |
|---|---|---|
rating_a |
float | Current rating of player A |
rating_b |
float | Current rating of player B |
outcome |
int | 0 = draw · 1 = A won · 2 = B won |
Returns: the new ratings as an array of floating-point numbers, e.g. {1400.0, 1550.0}.
Updates ratings while also considering the points scored by each player.
| Parameter | Type | Description |
|---|---|---|
rating_a |
float | Current rating of player A |
rating_b |
float | Current rating of player B |
points_a |
float | Points scored by player A |
points_b |
float | Points scored by player B |
method |
int | 0 = outcome only · 1 = points fraction replaces S_a · 2 = bonus using L (default) |
Returns: the new ratings as an array of floating-point numbers.
| Symbol | Meaning |
|---|---|
| New rating of player A | |
| Original rating of player A | |
Scaling factor (generally 32) |
|
Actual score: 1 for a win, 0.5 for a draw, 0 for a loss |
|
| Expected score: the probability that player A wins |
The expected score is computed from the two ratings:
Which simplifies to:
Since
A new player typically starts at 1000. The starting rating should be much larger than
When the margin of victory matters, outcome-only ELO treats very different wins the same:
- Game 1: player A beats player B 5-1
- Game 2: player C beats player B 2-1
Player A had a far more dominant win, so should gain more rating than player C. The two score-aware methods below handle this.
| Method | Behavior | Trade-off |
|---|---|---|
| 0 | Outcome only (original ELO) | Ignores margin of victory |
| 1 | Replaces |
Intuitive and needs no formula change, but offers less control and predictability |
| 2 | Keeps |
Less intuitive, but gives much more control and predictability |
Method 1
Method 2
where 16), and:
With method 2, the maximum rating change per match is
None. The library uses only the Java standard library.
Contributions are welcome and appreciated.
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -m "Add your feature" - Push the branch:
git push origin feature/your-feature - Open a Pull Request
Good first contributions: unit tests (e.g. JUnit), Maven or Gradle packaging, and usage examples.
Found a bug or have a suggestion? Open an issue and include the inputs you used (ratings, outcome or points, and method) and the output you expected.
Add a LICENSE file and update this section with your chosen license. Open-source projects without a license are not legally reusable by others. choosealicense.com can help you pick one.