mirror of
				https://github.com/furyfire/trueskill.git
				synced 2025-11-04 10:12:28 +01:00 
			
		
		
		
	Reintroduced supprressed warnings
This commit is contained in:
		@@ -20,8 +20,8 @@ abstract class SkillCalculator
 | 
			
		||||
     * Calculates new ratings based on the prior ratings and team ranks.
 | 
			
		||||
     *
 | 
			
		||||
     * @param  GameInfo $gameInfo               Parameters for the game.
 | 
			
		||||
     * @param  array    $teamsOfPlayerToRatings A mapping of team players and their ratings.
 | 
			
		||||
     * @param  array    $teamRanks              The ranks of the teams where 1 is first place. For a tie, repeat the number (e.g. 1, 2, 2).
 | 
			
		||||
     * @param  Team[]   $teamsOfPlayerToRatings A mapping of team players and their ratings.
 | 
			
		||||
     * @param  int[]    $teamRanks              The ranks of the teams where 1 is first place. For a tie, repeat the number (e.g. 1, 2, 2).
 | 
			
		||||
     * @return RatingContainer All the players and their new ratings.
 | 
			
		||||
     */
 | 
			
		||||
    abstract public function calculateNewRatings(
 | 
			
		||||
@@ -34,7 +34,7 @@ abstract class SkillCalculator
 | 
			
		||||
     * Calculates the match quality as the likelihood of all teams drawing.
 | 
			
		||||
     *
 | 
			
		||||
     * @param  GameInfo $gameInfo               Parameters for the game.
 | 
			
		||||
     * @param  array    $teamsOfPlayerToRatings A mapping of team players and their ratings.
 | 
			
		||||
     * @param  Team[]    $teamsOfPlayerToRatings A mapping of team players and their ratings.
 | 
			
		||||
     * @return float The quality of the match between the teams as a percentage (0% = bad, 100% = well matched).
 | 
			
		||||
     */
 | 
			
		||||
    abstract public function calculateMatchQuality(GameInfo $gameInfo, array $teamsOfPlayerToRatings): float;
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,9 @@ class FactorGraphTrueSkillCalculator extends SkillCalculator
 | 
			
		||||
    {
 | 
			
		||||
        parent::__construct(SkillCalculatorSupportedOptions::PARTIAL_PLAY | SkillCalculatorSupportedOptions::PARTIAL_UPDATE, TeamsRange::atLeast(2), PlayersRange::atLeast(1));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function calculateNewRatings(
 | 
			
		||||
        GameInfo $gameInfo,
 | 
			
		||||
        array $teams,
 | 
			
		||||
@@ -45,7 +47,9 @@ class FactorGraphTrueSkillCalculator extends SkillCalculator
 | 
			
		||||
 | 
			
		||||
        return $factorGraph->getUpdatedRatings();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function calculateMatchQuality(GameInfo $gameInfo, array $teams): float
 | 
			
		||||
    {
 | 
			
		||||
        // We need to create the A matrix which is the player team assigments.
 | 
			
		||||
 
 | 
			
		||||
@@ -217,7 +217,7 @@ class GaussianWeightedSumFactor extends GaussianFactor
 | 
			
		||||
        $result = (string) $sumVariable;
 | 
			
		||||
        $result .= ' = ';
 | 
			
		||||
 | 
			
		||||
        $totalVars = is_countable($variablesToSum) ? count($variablesToSum) : 0;
 | 
			
		||||
        $totalVars = count($variablesToSum);
 | 
			
		||||
        for ($i = 0; $i < $totalVars; $i++) {
 | 
			
		||||
            $isFirst = ($i == 0);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,11 @@ class TrueSkillFactorGraph extends FactorGraph
 | 
			
		||||
 | 
			
		||||
    private PlayerPriorValuesToSkillsLayer $priorLayer;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param  GameInfo $gameInfo               Parameters for the game.
 | 
			
		||||
     * @param  Team[]   $teamsOfPlayerToRatings A mapping of team players and their ratings.
 | 
			
		||||
     * @param  int[]    $teamRanks              The ranks of the teams where 1 is first place. For a tie, repeat the number (e.g. 1, 2, 2).
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(private readonly GameInfo $gameInfo, array $teams, array $teamRanks)
 | 
			
		||||
    {
 | 
			
		||||
        $this->priorLayer = new PlayerPriorValuesToSkillsLayer($this, $teams);
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@ use DNW\Skills\RatingContainer;
 | 
			
		||||
use DNW\Skills\SkillCalculator;
 | 
			
		||||
use DNW\Skills\SkillCalculatorSupportedOptions;
 | 
			
		||||
use DNW\Skills\TeamsRange;
 | 
			
		||||
use DNW\Skills\Team;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Calculates the new ratings for only two players.
 | 
			
		||||
@@ -27,6 +28,9 @@ class TwoPlayerTrueSkillCalculator extends SkillCalculator
 | 
			
		||||
        parent::__construct(SkillCalculatorSupportedOptions::NONE, TeamsRange::exactly(2), PlayersRange::exactly(1));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function calculateNewRatings(
 | 
			
		||||
        GameInfo $gameInfo,
 | 
			
		||||
        array $teams,
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,9 @@ class TwoTeamTrueSkillCalculator extends SkillCalculator
 | 
			
		||||
    {
 | 
			
		||||
        parent::__construct(SkillCalculatorSupportedOptions::NONE, TeamsRange::exactly(2), PlayersRange::atLeast(1));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     */
 | 
			
		||||
    public function calculateNewRatings(GameInfo $gameInfo, array $teams, array $teamRanks): RatingContainer
 | 
			
		||||
    {
 | 
			
		||||
        Guard::argumentNotNull($gameInfo, 'gameInfo');
 | 
			
		||||
@@ -149,10 +151,10 @@ class TwoTeamTrueSkillCalculator extends SkillCalculator
 | 
			
		||||
 | 
			
		||||
        // We've verified that there's just two teams
 | 
			
		||||
        $team1Ratings = $teams[0]->getAllRatings();
 | 
			
		||||
        $team1Count = is_countable($team1Ratings) ? count($team1Ratings) : 0;
 | 
			
		||||
        $team1Count = count($team1Ratings);
 | 
			
		||||
 | 
			
		||||
        $team2Ratings = $teams[1]->getAllRatings();
 | 
			
		||||
        $team2Count = is_countable($team2Ratings) ? count($team2Ratings) : 0;
 | 
			
		||||
        $team2Count = count($team2Ratings);
 | 
			
		||||
 | 
			
		||||
        $totalPlayers = $team1Count + $team2Count;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user