mirror of
				https://github.com/furyfire/trueskill.git
				synced 2025-11-04 10:12:28 +01: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()));
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
?>
 |