mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-16 01:47:39 +00:00
26 lines
645 B
PHP
26 lines
645 B
PHP
|
<?php
|
||
|
namespace Moserware\Skills\Elo;
|
||
|
|
||
|
class GaussianEloCalculator extends TwoPlayerEloCalculator
|
||
|
{
|
||
|
// From the paper
|
||
|
const STABLE_KFACTOR = 24;
|
||
|
|
||
|
public function __construct()
|
||
|
{
|
||
|
parent::__construct(new KFactor(self::STABLE_KFACTOR));
|
||
|
}
|
||
|
|
||
|
public function getPlayerWinProbability(GameInfo $gameInfo, $playerRating, $opponentRating)
|
||
|
{
|
||
|
$ratingDifference = $playerRating - $opponentRating;
|
||
|
|
||
|
// See equation 1.1 in the TrueSkill paper
|
||
|
return GaussianDistribution::cumulativeTo(
|
||
|
$ratingDifference
|
||
|
/
|
||
|
(sqrt(2) * $gameInfo->getBeta()));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
?>
|