Reintroduced supprressed warnings

This commit is contained in:
Jens True 2023-08-02 14:24:19 +00:00
parent 4ddde1e277
commit 50bd2b152a
7 changed files with 24 additions and 11 deletions

@ -3,5 +3,3 @@ parameters:
paths:
- src
# - tests
ignoreErrors:
- '#with no value type specified in iterable type array#'

@ -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;