mirror of
https://github.com/furyfire/trueskill.git
synced 2025-06-27 15:21:31 +00:00
Compare commits
2 Commits
55656b7889
...
d729caac1f
Author | SHA1 | Date | |
---|---|---|---|
d729caac1f | |||
bd9fccb87b |
@ -2,10 +2,11 @@
|
||||
<phive xmlns="https://phar.io/phive">
|
||||
<phar name="phpmd" version="^2.15.0" installed="2.15.0" location="./tools/phpmd" copy="false"/>
|
||||
<phar name="overtrue/phplint" version="^9.6.2" installed="9.6.2" location="./tools/phplint" copy="false"/>
|
||||
<phar name="phpstan" version="^2.1.12" installed="2.1.12" location="./tools/phpstan" copy="false"/>
|
||||
<phar name="psalm" version="^7.0.0-beta6" installed="7.0.0-beta6" location="./tools/psalm" copy="false"/>
|
||||
<phar name="phpcs" version="^3.12.2" installed="3.12.2" location="./tools/phpcs" copy="false"/>
|
||||
<phar name="phpcbf" version="^3.12.2" installed="3.12.2" location="./tools/phpcbf" copy="false"/>
|
||||
<phar name="phpstan" version="^2.1.12" installed="2.1.14" location="./tools/phpstan" copy="false"/>
|
||||
<phar name="psalm" version="^7.0.0-beta6" installed="7.0.0-beta7" location="./tools/psalm" copy="false"/>
|
||||
<phar name="phpcs" version="^3.12.2" installed="3.13.0" location="./tools/phpcs" copy="false"/>
|
||||
<phar name="phpcbf" version="^3.12.2" installed="3.13.0" location="./tools/phpcbf" copy="false"/>
|
||||
<phar name="phpdocumentor" version="^3.7.1" installed="3.7.1" location="./tools/phpdocumentor" copy="false"/>
|
||||
<phar name="phpbench" version="^1.4.1" installed="1.4.1" location="./tools/phpbench" copy="false"/>
|
||||
<phar name="infection" version="^0.29.14" installed="0.29.14" location="./tools/infection" copy="false"/>
|
||||
</phive>
|
||||
|
14
composer.lock
generated
14
composer.lock
generated
@ -837,16 +837,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "11.5.18",
|
||||
"version": "11.5.20",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "fc3e887c7f3f9917e1bf61e523413d753db00a17"
|
||||
"reference": "e6bdea63ecb7a8287d2cdab25bdde3126e0cfe6f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fc3e887c7f3f9917e1bf61e523413d753db00a17",
|
||||
"reference": "fc3e887c7f3f9917e1bf61e523413d753db00a17",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e6bdea63ecb7a8287d2cdab25bdde3126e0cfe6f",
|
||||
"reference": "e6bdea63ecb7a8287d2cdab25bdde3126e0cfe6f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -856,7 +856,7 @@
|
||||
"ext-mbstring": "*",
|
||||
"ext-xml": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"myclabs/deep-copy": "^1.13.0",
|
||||
"myclabs/deep-copy": "^1.13.1",
|
||||
"phar-io/manifest": "^2.0.4",
|
||||
"phar-io/version": "^3.2.1",
|
||||
"php": ">=8.2",
|
||||
@ -918,7 +918,7 @@
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
|
||||
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.18"
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.20"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -942,7 +942,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2025-04-22T06:09:49+00:00"
|
||||
"time": "2025-05-11T06:39:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "rector/rector",
|
||||
|
@ -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];
|
||||
@ -130,10 +130,10 @@ class Matrix
|
||||
// | a b |
|
||||
// | c d |
|
||||
// The determinant is ad - bc
|
||||
$a = (float)$this->getValue(0, 0);
|
||||
$b = (float)$this->getValue(0, 1);
|
||||
$c = (float)$this->getValue(1, 0);
|
||||
$d = (float)$this->getValue(1, 1);
|
||||
$a = $this->getValue(0, 0);
|
||||
$b = $this->getValue(0, 1);
|
||||
$c = $this->getValue(1, 0);
|
||||
$d = $this->getValue(1, 1);
|
||||
|
||||
return $a * $d - $b * $c;
|
||||
}
|
||||
@ -148,7 +148,7 @@ class Matrix
|
||||
|
||||
// I expand along the first row
|
||||
for ($currentColumn = 0; $currentColumn < $this->columnCount; ++$currentColumn) {
|
||||
$firstRowColValue = (float)$this->getValue(0, $currentColumn);
|
||||
$firstRowColValue = $this->getValue(0, $currentColumn);
|
||||
$cofactor = $this->getCofactor(0, $currentColumn);
|
||||
$itemToAdd = $firstRowColValue * $cofactor;
|
||||
$result += $itemToAdd;
|
||||
@ -201,7 +201,7 @@ class Matrix
|
||||
public function getInverse(): Matrix|SquareMatrix
|
||||
{
|
||||
if (($this->rowCount == 1) && ($this->columnCount == 1)) {
|
||||
return new SquareMatrix(1.0 / (float)$this->getValue(0, 0));
|
||||
return new SquareMatrix(1.0 / $this->getValue(0, 0));
|
||||
}
|
||||
|
||||
// Take the simple approach:
|
||||
@ -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();
|
||||
@ -240,9 +240,9 @@ class Matrix
|
||||
for ($currentRow = 0; $currentRow < $left->getRowCount(); ++$currentRow) {
|
||||
for ($currentColumn = 0; $currentColumn < $right->getColumnCount(); ++$currentColumn) {
|
||||
$resultMatrix[$currentRow][$currentColumn] =
|
||||
(float)$left->getValue($currentRow, $currentColumn)
|
||||
$left->getValue($currentRow, $currentColumn)
|
||||
+
|
||||
(float)$right->getValue($currentRow, $currentColumn);
|
||||
$right->getValue($currentRow, $currentColumn);
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,11 +265,11 @@ 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);
|
||||
$rightValue = (float)$right->getValue($vectorIndex, $currentColumn);
|
||||
$leftValue = $left->getValue($currentRow, $vectorIndex);
|
||||
$rightValue = $right->getValue($vectorIndex, $currentColumn);
|
||||
$vectorIndexProduct = $leftValue * $rightValue;
|
||||
$productValue += $vectorIndexProduct;
|
||||
}
|
||||
@ -339,8 +339,8 @@ class Matrix
|
||||
for ($currentColumn = 0; $currentColumn < $this->columnCount; ++$currentColumn) {
|
||||
$delta =
|
||||
abs(
|
||||
(float)$this->getValue($currentRow, $currentColumn) -
|
||||
(float)$otherMatrix->getValue($currentRow, $currentColumn)
|
||||
$this->getValue($currentRow, $currentColumn) -
|
||||
$otherMatrix->getValue($currentRow, $currentColumn)
|
||||
);
|
||||
|
||||
if ($delta > self::ERROR_TOLERANCE) {
|
||||
|
@ -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;
|
||||
@ -112,7 +112,7 @@ final class GaussianWeightedSumFactor extends GaussianFactor
|
||||
|
||||
$currentWeights[$currentDestinationWeightIndex] = $finalWeight;
|
||||
$currentWeightsSquared[$currentDestinationWeightIndex] = BasicMath::square($finalWeight);
|
||||
$variableIndices[count($variableWeights)] = 0;
|
||||
$variableIndices[count($variableWeights)] = 0.0;
|
||||
$this->varIndexOrdersForWeights[] = $variableIndices;
|
||||
|
||||
$this->weights[$weightsIndex] = $currentWeights;
|
||||
|
@ -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