2017 © Pedro Peláez
 

library elo

Elo system with a reliability purpose

image

alcalyn/elo

Elo system with a reliability purpose

  • Monday, November 7, 2016
  • by alcalyn
  • Repository
  • 2 Watchers
  • 5 Stars
  • 628 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Elo system

Another Elo implementation in PHP ! But this one introduce a reliability purpose., (*1)

Scrutinizer Code Quality Build Status License, (*2)

Reliability purpose

A history: You have a good player A which played many games and have a score of 2100 Elo. A new player B subscribe to the game website, so his Elo score is initialized to 1500. But in fact, he is a very good player, better than A, and beat him like crushing an ant., (*3)

The problem: New player B will win many Elo because he won against a 2100 Elo player. That's ok. But player A (2100 Elo) will lose many Elo because he lost against a 1500 Elo player, but in fact strongest., (*4)

The fact is that the new player Elo score is not reliable, so it should not impact others players Elo scores., (*5)

The solution: This library. It introduces a reliability coefficient (decimal between 0.0 and 1.0) for Elo A and Elo B., (*6)

Composer

Install via composer, (*7)

``` js { "require": { "alcalyn/elo": "1.x" } }, (*8)


*Or download the library manually if you don't use composer.* ## Usage - Instantiate a standard Elo system ``` php use Alcalyn/Elo/EloSystem; $eloSystem = new EloSystem();
  • Calculate updated Elo scores from old Elo

``` php /** * A player with 1650 Elo beat another with 1920 */ $updatedElos = $eloSystem->calculate(1650, 1920, 1);, (*9)

print_r($updatedElos); /* Output: Array ( [0] => 1663.2084157978 [1] => 1906.7915842022 ) */, (*10)


- Set **reliability** coefficient to Elo scores ``` php /** * A player with 1907 Elo (1.0 reliability) * lose against a new player with 1500 (and reliability to 0.0) */ $updatedElos = $eloSystem->calculate(1907, 1500, 0, 1.0, 0.0); print_r($updatedElos); /* Output: Array ( [0] => 1907 [1] => 1514.5978664353 ) */
  • Using method aliases for win, lose or draw

``` php /** * Method Aliases */ $elo->win(2100, 1500, 1.0, 0.0); $elo->lose(2100, 1500, 1.0, 0.0); $elo->draw(2100, 1500, 1.0, 0.0);, (*11)


- Instanciate a system with a different K factor (default is 16) ``` php /** * Use a different K factor in your Elo system */ $eloSystemK32 = new EloSystem(32);

Detailled examples

A new player:, (*12)

Player A has 2100 Elo, reliability 1.0
Player B has 1500 Elo, reliability 0.0
, (*13)

A wins: Expected result, so B loses a small amount of Elo, and A win nothing.
B wins: NOT expected result, so B wins a BIG amount of Elo, and A lose nothing.
, (*14)

A Elo score will not be updated when he plays versus a new player with an unreliable Elo score., (*15)

(And new player B should have its Elo reliability increased by something like 1/10 after every games until his reliability reaches 1), (*16)

``` php $elo = new EloSystem();, (*17)

/** * Result without reliability */ print_r($elo->lose(2100, 1500));, (*18)

/* Output: Array ( [0] => 2084.4904548805 // lose -16 Elo [1] => 1515.5095451195 // win +16 Elo ) */, (*19)

/** * Result with reliability */ print_r($elo->lose(2100, 1500, 1.0, 0.0));, (*20)

/* Output: Array ( [0] => 2100 // don't lose Elo against new player [1] => 1515.5095451195 // win +16 Elo vs reliable Elo score ) */ ```, (*21)

Another example: two newbies players:, (*22)

Player A has 1500 Elo, reliability 0.0
Player B has 1500 Elo, reliability 0.0
, (*23)

There is two new players, so their reliabilities are both 0.0: the algorithm takes them like if they were both 1.0., (*24)

And if player A had an Elo reliability equal to 0.4, and player B equal to 0.0, the algorithm adds them +0.6 so one of reliabilities reaches 1.0., (*25)

License

This project is under MIT Lisense, (*26)

The Versions

07/11 2016

dev-test

dev-test https://github.com/alcalyn/elo

Elo system with a reliability purpose

  Sources   Download

MIT

php elo

26/11 2014

dev-master

9999999-dev https://github.com/alcalyn/elo

Elo system with a reliability purpose

  Sources   Download

MIT

php elo

26/11 2014

v1.0

1.0.0.0 https://github.com/alcalyn/elo

Elo system with a reliability purpose

  Sources   Download

MIT

php elo

26/11 2014

dev-dev

dev-dev https://github.com/alcalyn/elo

Elo system with a reliability purpose

  Sources   Download

MIT

php elo