Git Product home page Git Product logo

glicko2's Introduction

Glicko2

PHP implementation of the Glicko-2 rating algorithm. This is a PHP port of goochjs/glicko2.

Build Status Scrutinizer Code Quality Code Coverage

Installation

Using Composer, add the package to your require section.

{
	"require": {
		"maartenstaa/glicko2": "dev-master"
	}
}

Run composer update to fetch the new requirement.

Usage

use MaartenStaa\Glicko2\Rating;
use MaartenStaa\Glicko2\RatingCalculator;
use MaartenStaa\Glicko2\RatingPeriodResults;

// Instantiate a RatingCalculator object.
// At instantiation, you can set the default rating for a player's volatility and
// the system constant for your game ("ฯ„", which constrains changes in volatility
// over time) or just accept the defaults.
$calculator = new RatingCalculator(/* $initVolatility, $tau */);

// Instantiate a Rating object for each player.
$player1 = new Rating($calculator/* , $rating, $ratingDeviation, $volatility */);
$player2 = new Rating($calculator/* , $rating, $ratingDeviation, $volatility */);
$player3 = new Rating($calculator/* , $rating, $ratingDeviation, $volatility */);

// Instantiate a RatingPeriodResults object.
$results = new RatingPeriodResults();

// Add game results to the RatingPeriodResults object until you reach the end of your rating period.
// Use addResult($winner, $loser) for games that had an outcome.
$results->addResult($player1, $player2);
// Use addDraw($player1, $player2) for games that resulted in a draw.
$results->addDraw($player1, $player2);
// Use addParticipant($player) to add players that played no games in the rating period.
$results->addParticipant($player3);

// Once you've reached the end of your rating period, call the updateRatings method
// against the RatingCalculator; this takes the RatingPeriodResults object as argument.
//  * Note that the RatingPeriodResults object is cleared down of game results once
//    the new ratings have been calculated.
//  * Participants remain within the RatingPeriodResults object, however, and will
//    have their rating deviations recalculated at the end of future rating periods
//    even if they don't play any games. This is in-line with Glickman's algorithm.
$calculator->updateRatings($results);

// Access the getRating, getRatingDeviation, and getVolatility methods of each
// player's Rating to see the new values.
foreach (array($player1, $player2, $player3) as $index => $player) {
	echo 'Player #', $index, ' values: ', $player->getRating(), ', ',
		$player->getRatingDeviation(), ', ', $player->getVolatility(), PHP_EOL;
}

Contributing

Coding standard

All code is to follow the PSR-2 coding standard.

Unit tests

If you find a bug, feel free to send a pull request to fix it, but make sure to always include a regression test.

glicko2's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

glicko2's Issues

Update Algo

Hello,

Would you be able to update the algo as per recommendation?

Source: http://glicko.net/glicko.html
Update: This document has been revised on March 22, 2022, to replace a "<" with "<=" in item 4(b) of Step 5 (page 3).

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.