mirror of
https://github.com/furyfire/trueskill.git
synced 2025-06-27 15:21:31 +00:00
Regular updates and fixing static analysis findings
This commit is contained in:
@ -79,7 +79,7 @@ class Matrix
|
||||
}
|
||||
}
|
||||
|
||||
public function getValue(int $row, int $col): float|int
|
||||
public function getValue(int $row, int $col): float
|
||||
{
|
||||
$this->checkRowCol($row, $col);
|
||||
return $this->matrixRowData[$row][$col];
|
||||
@ -212,7 +212,7 @@ class Matrix
|
||||
return self::scalarMultiply($determinantInverse, $adjugate);
|
||||
}
|
||||
|
||||
public static function scalarMultiply(float|int $scalarValue, Matrix $matrix): Matrix
|
||||
public static function scalarMultiply(float $scalarValue, Matrix $matrix): Matrix
|
||||
{
|
||||
$rows = $matrix->getRowCount();
|
||||
$columns = $matrix->getColumnCount();
|
||||
@ -265,7 +265,7 @@ class Matrix
|
||||
|
||||
for ($currentRow = 0; $currentRow < $resultRows; ++$currentRow) {
|
||||
for ($currentColumn = 0; $currentColumn < $resultColumns; ++$currentColumn) {
|
||||
$productValue = 0;
|
||||
$productValue = 0.0;
|
||||
|
||||
for ($vectorIndex = 0; $vectorIndex < $left->getColumnCount(); ++$vectorIndex) {
|
||||
$leftValue = (float)$left->getValue($currentRow, $vectorIndex);
|
||||
|
@ -192,7 +192,7 @@ final class FactorGraphTrueSkillCalculator extends SkillCalculator
|
||||
$nextTeam = $teamAssignmentsList[$i + 1];
|
||||
foreach ($nextTeam->getAllPlayers() as $nextTeamPlayer) {
|
||||
// Add a -1 * playing time to represent the difference
|
||||
$playerAssignments[$currentColumn][] = -1 * PartialPlay::getPartialPlayPercentage($nextTeamPlayer);
|
||||
$playerAssignments[$currentColumn][] = -1.0 * PartialPlay::getPartialPlayPercentage($nextTeamPlayer);
|
||||
--$rowsRemaining;
|
||||
}
|
||||
|
||||
|
@ -72,12 +72,12 @@ final class GaussianWeightedSumFactor extends GaussianFactor
|
||||
|
||||
$weightsLength = $variableWeightsLength + 1;
|
||||
for ($weightsIndex = 1; $weightsIndex < $weightsLength; ++$weightsIndex) {
|
||||
$currentWeights = \array_fill(0, $variableWeightsLength, 0);
|
||||
$currentWeights = \array_fill(0, $variableWeightsLength, 0.0);
|
||||
|
||||
$variableIndices = \array_fill(0, $variableWeightsLength + 1, 0);
|
||||
$variableIndices = \array_fill(0, $variableWeightsLength + 1, 0.0);
|
||||
$variableIndices[0] = $weightsIndex;
|
||||
|
||||
$currentWeightsSquared = \array_fill(0, $variableWeightsLength, 0);
|
||||
$currentWeightsSquared = \array_fill(0, $variableWeightsLength, 0.0);
|
||||
|
||||
// keep a single variable to keep track of where we are in the array.
|
||||
// This is helpful since we skip over one of the spots
|
||||
@ -90,9 +90,9 @@ final class GaussianWeightedSumFactor extends GaussianFactor
|
||||
|
||||
$currentWeight = (-$variableWeights[$currentWeightSourceIndex] / $variableWeights[$weightsIndex - 1]);
|
||||
|
||||
if ($variableWeights[$weightsIndex - 1] == 0) {
|
||||
if ($variableWeights[$weightsIndex - 1] == 0.0) {
|
||||
// HACK: Getting around division by zero
|
||||
$currentWeight = 0;
|
||||
$currentWeight = 0.0;
|
||||
}
|
||||
|
||||
$currentWeights[$currentDestinationWeightIndex] = $currentWeight;
|
||||
|
@ -118,11 +118,11 @@ final class TwoPlayerTrueSkillCalculator extends SkillCalculator
|
||||
// non-draw case
|
||||
$v = TruncatedGaussianCorrectionFunctions::vExceedsMarginScaled($meanDelta, $drawMargin, $c);
|
||||
$w = TruncatedGaussianCorrectionFunctions::wExceedsMarginScaled($meanDelta, $drawMargin, $c);
|
||||
$rankMultiplier = $comparison->value;
|
||||
$rankMultiplier = (float)$comparison->value;
|
||||
} else {
|
||||
$v = TruncatedGaussianCorrectionFunctions::vWithinMarginScaled($meanDelta, $drawMargin, $c);
|
||||
$w = TruncatedGaussianCorrectionFunctions::wWithinMarginScaled($meanDelta, $drawMargin, $c);
|
||||
$rankMultiplier = 1;
|
||||
$rankMultiplier = 1.0;
|
||||
}
|
||||
|
||||
$meanMultiplier = (BasicMath::square($selfRating->getStandardDeviation()) + BasicMath::square($gameInfo->getDynamicsFactor())) / $c;
|
||||
|
@ -94,7 +94,7 @@ final class TwoTeamTrueSkillCalculator extends SkillCalculator
|
||||
+
|
||||
BasicMath::sum($otherTeam->getAllRatings(), $varianceGetter)
|
||||
+
|
||||
$totalPlayers * $betaSquared
|
||||
(float)$totalPlayers * $betaSquared
|
||||
);
|
||||
|
||||
$winningMean = $selfMeanSum;
|
||||
@ -117,7 +117,7 @@ final class TwoTeamTrueSkillCalculator extends SkillCalculator
|
||||
// non-draw case
|
||||
$v = TruncatedGaussianCorrectionFunctions::vExceedsMarginScaled($meanDelta, $drawMargin, $c);
|
||||
$w = TruncatedGaussianCorrectionFunctions::wExceedsMarginScaled($meanDelta, $drawMargin, $c);
|
||||
$rankMultiplier = $selfToOtherTeamComparison->value;
|
||||
$rankMultiplier = (float)$selfToOtherTeamComparison->value;
|
||||
} else {
|
||||
// assume draw
|
||||
$v = TruncatedGaussianCorrectionFunctions::vWithinMarginScaled($meanDelta, $drawMargin, $c);
|
||||
|
Reference in New Issue
Block a user