2017 © Pedro Peláez
 

library elo

Elo calculator library

image

avoo/elo

Elo calculator library

  • Monday, December 7, 2015
  • by avoo
  • Repository
  • 1 Watchers
  • 0 Stars
  • 63 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 2 % Grown

The README.md

Elo

Build Status Scrutinizer Code Quality License, (*1)

This is a PHP library to calculate the Elo rank between two players., (*2)

Documentation

into your composer.json file:, (*3)

``` json { "require": { "avoo/elo": "~0.2" } }, (*4)


Default Usage ------------- You need to implement the class `Avoo\Elo\Model\EloPlayerInterface` on your own player class ``` php use Avoo\Elo\Model\EloPlayerInterface; use Avoo\Elo\Model\EloUserInterface; class EloPlayer implements EloPlayerInterface { /** * @var integer */ protected $elo; /** * @var EloUserInterface $user */ protected $user; /** * {@inheritdoc} */ public function setElo($elo) { $this->elo = $elo; return $this; } /** * {@inheritdoc} */ public function getElo() { return $this->elo; } /** * {@inheritdoc} */ public function setUser(EloUserInterface $user) { $this->user = $user; return $this; } /** * {@inheritdoc} */ public function getUser() { return $this->user; } //... Your own code }

Consider the player A with 2300 elo and the player B 1800, the player A lose., (*5)

The default setup for winner is: - 0 Player A lose - 0.5 Draw - 1 Player A win, (*6)

Example 1

``` php use Avoo\Elo\EloPoint; use Avoo\Elo\EloVersusInterface; use Avoo\Elo\EloAggregagtionInterface;, (*7)

$eloCalculator = new EloPoint();, (*8)

/** @var EloVersusInterface $match */ $eloPoint->calculate($match);, (*9)

/** @var EloAggregationInterface $aggregation */ $aggregation = $eloPoint->getAggregation();, (*10)


Example 2 --------- ``` php use Avoo\Elo\EloPoint; use Avoo\Elo\EloVersusInterface; use Avoo\Elo\EloAggregagtionInterface; /** @var EloVersusInterface $match */ $eloCalculator = new EloPoint($match); $eloPoint->calculate(); /** @var EloAggregationInterface $aggregation */ $aggregation = $eloPoint->getAggregation();

Override configuration

You can override the default configuration for adjust your elo calculator, (*11)

``` php use Avoo\Elo\EloPoint; use Avoo\Elo\EloVersusInterface; use Avoo\Elo\EloAggregagtionInterface; use Avoo\Elo\ConfigurationInterface;, (*12)

/** @var ConfigurationInterface $configuration */ $configuration = new Configuration();, (*13)

/** * Floor is the experience range calculator */ $configuration->setFloor(200);, (*14)

/** * Base range is ratio number for calculate the new elo * In this case between 0 and 1700 elo point the range is 50, over it's 20 * For example with 1500 elo point for both players, with 50 elo range, the new elo will be 18 and -18, * and for 20 elo range, the new elo will be 7 and -7 */ $configuration->setBaseRange(array( 0 => 50 1700 => 20 ));, (*15)

/* * Base elo is the start elo point for a new player */ $configuration->setBaseElo(1000);, (*16)

/** @var EloVersusInterface $match */ $eloCalculator = new EloPoint($match, $configuration); $eloPoint->calculate();, (*17)

/** @var EloAggregationInterface $aggregation */ $aggregation = $eloPoint->getAggregation(); ```, (*18)

The Versions

07/12 2015

dev-master

9999999-dev

Elo calculator library

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Jérémy Jégou

elo rewards competition points rank

07/12 2015

0.2.0

0.2.0.0

Elo calculator library

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Jérémy Jégou

elo rewards competition points rank

01/10 2014

0.1.0

0.1.0.0

Elo calculator library

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Jérémy Jégou

elo rewards competition points rank