From c18ccd38e2a674f9f60ce3ae700a8acae43bd8e6 Mon Sep 17 00:00:00 2001 From: Jens True Date: Fri, 2 Feb 2024 15:16:11 +0000 Subject: [PATCH] Bunch of generic code standard items. Will need a cleanup. --- .phpcs.xml | 25 +++++++++++++++++++ src/FactorGraphs/FactorGraph.php | 2 ++ src/FactorGraphs/KeyedVariable.php | 2 ++ src/FactorGraphs/Message.php | 2 ++ src/FactorGraphs/Schedule.php | 2 ++ src/Guard.php | 2 ++ src/HashMap.php | 2 ++ src/ISupportPartialPlay.php | 2 ++ src/ISupportPartialUpdate.php | 2 ++ src/Numerics/BasicMath.php | 10 +++++--- src/Numerics/GaussianDistribution.php | 5 +++- src/Numerics/IdentityMatrix.php | 2 ++ src/Numerics/Range.php | 2 ++ src/Numerics/SquareMatrix.php | 4 ++- src/Numerics/Vector.php | 2 ++ src/PairwiseComparison.php | 2 ++ src/PartialPlay.php | 2 ++ src/Player.php | 7 ++++-- src/PlayersRange.php | 2 ++ src/Rating.php | 2 ++ src/RatingContainer.php | 2 ++ src/SkillCalculator.php | 4 +-- src/SkillCalculatorSupportedOptions.php | 2 ++ src/Team.php | 2 ++ .../FactorGraphTrueSkillCalculator.php | 7 +++++- src/TrueSkill/Factors/GaussianFactor.php | 2 ++ .../Factors/GaussianGreaterThanFactor.php | 8 +++--- .../Factors/GaussianLikelihoodFactor.php | 2 ++ src/TrueSkill/Factors/GaussianPriorFactor.php | 2 ++ .../Factors/GaussianWeightedSumFactor.php | 3 ++- .../Factors/GaussianWithinFactor.php | 5 ++-- .../IteratedTeamDifferencesInnerLayer.php | 3 ++- ...ancesToTeamPerformanceDifferencesLayer.php | 3 ++- .../Layers/TrueSkillFactorGraphLayer.php | 2 ++ src/TrueSkill/TrueSkillFactorGraph.php | 6 ++--- .../TruncatedGaussianCorrectionFunctions.php | 3 +-- .../TwoPlayerTrueSkillCalculator.php | 3 ++- src/TrueSkill/TwoTeamTrueSkillCalculator.php | 3 ++- 38 files changed, 117 insertions(+), 26 deletions(-) diff --git a/.phpcs.xml b/.phpcs.xml index bf7a001..103964b 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -13,6 +13,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/FactorGraphs/FactorGraph.php b/src/FactorGraphs/FactorGraph.php index 352ce8e..9a68f59 100644 --- a/src/FactorGraphs/FactorGraph.php +++ b/src/FactorGraphs/FactorGraph.php @@ -1,5 +1,7 @@ Id; + return (string)$this->Id; } } diff --git a/src/PlayersRange.php b/src/PlayersRange.php index 3ceb1ee..81eb919 100644 --- a/src/PlayersRange.php +++ b/src/PlayersRange.php @@ -1,5 +1,7 @@ validateTeamCountAndPlayersCountPerTeam($teams); @@ -124,7 +127,9 @@ class FactorGraphTrueSkillCalculator extends SkillCalculator /** * Helper function that gets a list of values for all player ratings + * * @param Team[] $teamAssignmentsList + * * @return int[] */ private static function getPlayerRatingValues(array $teamAssignmentsList, \Closure $playerRatingFunction): array diff --git a/src/TrueSkill/Factors/GaussianFactor.php b/src/TrueSkill/Factors/GaussianFactor.php index ed5d7cb..c45b44f 100644 --- a/src/TrueSkill/Factors/GaussianFactor.php +++ b/src/TrueSkill/Factors/GaussianFactor.php @@ -1,5 +1,7 @@ $weights */ private array $weights = []; @@ -249,7 +250,7 @@ class GaussianWeightedSumFactor extends GaussianFactor $absValue = sprintf('%.2f', \abs($weights[$i])); // 0.00? $result .= $absValue; $result .= '*['; - $result .= (string) $variablesToSum[$i]; + $result .= (string)$variablesToSum[$i]; $result .= ']'; $isLast = ($i === $totalVars - 1); diff --git a/src/TrueSkill/Factors/GaussianWithinFactor.php b/src/TrueSkill/Factors/GaussianWithinFactor.php index 7b5d56b..73b927c 100644 --- a/src/TrueSkill/Factors/GaussianWithinFactor.php +++ b/src/TrueSkill/Factors/GaussianWithinFactor.php @@ -1,5 +1,7 @@ validateTeamCountAndPlayersCountPerTeam($teams); diff --git a/src/TrueSkill/TwoTeamTrueSkillCalculator.php b/src/TrueSkill/TwoTeamTrueSkillCalculator.php index 7661627..5b611fe 100644 --- a/src/TrueSkill/TwoTeamTrueSkillCalculator.php +++ b/src/TrueSkill/TwoTeamTrueSkillCalculator.php @@ -70,7 +70,8 @@ class TwoTeamTrueSkillCalculator extends SkillCalculator Team $selfTeam, Team $otherTeam, PairwiseComparison $selfToOtherTeamComparison - ): void { + ): void + { $drawMargin = DrawMargin::getDrawMarginFromDrawProbability( $gameInfo->getDrawProbability(), $gameInfo->getBeta()