PHP code example of keypax / glicko2

1. Go to this page and download the library: Download keypax/glicko2 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

keypax / glicko2 example snippets


use Zelenin\Glicko2\Glicko2;
use Zelenin\Glicko2\RatingMatch;
use Zelenin\Glicko2\RatingMatchCollection;
use Zelenin\Glicko2\Player;

$glicko = new Glicko2();

$player1 = new Player(1700, 250, 0.05);
$player2 = new Player();

$ratingMatch = new RatingMatch($player1, $player2, 1, 0);
$glicko->calculateRatingMatch($ratingMatch);

$ratingMatch = new RatingMatch($player1, $player2, 3, 2);
$glicko->calculateRatingMatch($ratingMatch);

// or

$ratingMatchCollection = new RatingMatchCollection();
$ratingMatchCollection->addRatingMatch(new RatingMatch($player1, $player2, 1, 0));
$ratingMatchCollection->addRatingMatch(new RatingMatch($player1, $player2, 3, 2));
$glicko->calculateRatingMatches($ratingMatchCollection);

$newPlayer1R = $player1->getR();
$newPlayer2R = $player2->getR();