DocsOverview

Overview

Teslo is a lightweight (<1.3 KB minified and gzipped) JavaScript library for calculating elo rating in multiplayer games. It supports various game modes, including player duels, free-for-all, team duels, and team free-for-all. Teslo is compatible with both browser and Node.js environments, and includes built-in type declarations.

Get started with installation.

Quickstart

Install the teslo package.

npm install teslo

Create a Duel and calculate elo ratings.

import { Player, Duel } from 'teslo'
 
// Create a duel between 2 players
const match = new Duel([new Player('1', 1000), new Player('2', 900)])
 
// Calculate elo ratings for player 1 win
const results = match.calculate('1')
 
/*
[
  {
    id: '1',
    elo: 1012
  },
  {
    id: '2',
    elo: 888
  }
]
*/

Elo Calculation

Player elo is calculated based on the rating of their opponents and the results scored. Initially, we calculate the probability of a player winning against their opponent.

Expected Result = 1 / (1 + 10 ^ ((Opponent Elo - Player Elo) / 400))

Once we have the expected result of a player against their opponent, we calculate their new elo with the actual result. Result is either a 1 or 0 based on the player winning or losing respectively.

New Elo = Current Elo + KFactor * (Result - Expected Result)

In a duel, each player either gains or loses elo based on winning or losing. In a free-for-all, elo is calculated by player or team placement; players gain elo from those who placed lower and lose elo to those who placed higher. In a team match, each player’s elo is calculated based on the average elo of the opposing team(s).

You can learn more about the elo rating system via the Wiki.