Compare commits

..

3 Commits

Author SHA1 Message Date
5a414b8307 More warnings from Psalm. Reduced Psalm config size 2025-01-28 09:38:14 +00:00
e2620fde53 PHP8.3 style overrides added 2025-01-28 09:20:03 +00:00
22002891c5 Upgrade to PHP8.4 2025-01-28 09:18:50 +00:00
31 changed files with 95 additions and 66 deletions

View File

@ -1,9 +1,9 @@
{ {
"name": "dnw/php-trueskill", "name": "dnw/php-trueskill",
"description": "Trueskill implementation by Moserware updated for PHP 8.2", "description": "Trueskill implementation by Moserware updated for PHP 8.4",
"keywords": ["trueskill", "matchmaking", "ranking", "skill", "elo"], "keywords": ["trueskill", "matchmaking", "ranking", "skill", "elo"],
"require": { "require": {
"php": "^8.2" "php": "^8.4"
}, },
"require-dev": { "require-dev": {
"phpstan/phpstan": "^1.0", "phpstan/phpstan": "^1.0",
@ -51,7 +51,6 @@
"@test", "@test",
"@lint", "@lint",
"@analyze", "@analyze",
"@document",
"@metrics", "@metrics",
"@html" "@html"
] ]

73
composer.lock generated
View File

@ -4,21 +4,21 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "9bcad23ed6b67a87b77c11db92614e65", "content-hash": "b812db257eb7996abdfd76cc1a74431f",
"packages": [], "packages": [],
"packages-dev": [ "packages-dev": [
{ {
"name": "amphp/amp", "name": "amphp/amp",
"version": "v3.0.2", "version": "v3.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/amphp/amp.git", "url": "https://github.com/amphp/amp.git",
"reference": "138801fb68cfc9c329da8a7b39d01ce7291ee4b0" "reference": "7cf7fef3d667bfe4b2560bc87e67d5387a7bcde9"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/amphp/amp/zipball/138801fb68cfc9c329da8a7b39d01ce7291ee4b0", "url": "https://api.github.com/repos/amphp/amp/zipball/7cf7fef3d667bfe4b2560bc87e67d5387a7bcde9",
"reference": "138801fb68cfc9c329da8a7b39d01ce7291ee4b0", "reference": "7cf7fef3d667bfe4b2560bc87e67d5387a7bcde9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -78,7 +78,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/amphp/amp/issues", "issues": "https://github.com/amphp/amp/issues",
"source": "https://github.com/amphp/amp/tree/v3.0.2" "source": "https://github.com/amphp/amp/tree/v3.1.0"
}, },
"funding": [ "funding": [
{ {
@ -86,7 +86,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2024-05-10T21:37:46+00:00" "time": "2025-01-26T16:07:39+00:00"
}, },
{ {
"name": "amphp/byte-stream", "name": "amphp/byte-stream",
@ -227,16 +227,16 @@
}, },
{ {
"name": "amphp/pipeline", "name": "amphp/pipeline",
"version": "v1.2.1", "version": "v1.2.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/amphp/pipeline.git", "url": "https://github.com/amphp/pipeline.git",
"reference": "66c095673aa5b6e689e63b52d19e577459129ab3" "reference": "97cbf289f4d8877acfe58dd90ed5a4370a43caa4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/amphp/pipeline/zipball/66c095673aa5b6e689e63b52d19e577459129ab3", "url": "https://api.github.com/repos/amphp/pipeline/zipball/97cbf289f4d8877acfe58dd90ed5a4370a43caa4",
"reference": "66c095673aa5b6e689e63b52d19e577459129ab3", "reference": "97cbf289f4d8877acfe58dd90ed5a4370a43caa4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -282,7 +282,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/amphp/pipeline/issues", "issues": "https://github.com/amphp/pipeline/issues",
"source": "https://github.com/amphp/pipeline/tree/v1.2.1" "source": "https://github.com/amphp/pipeline/tree/v1.2.2"
}, },
"funding": [ "funding": [
{ {
@ -290,7 +290,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2024-07-04T00:56:47+00:00" "time": "2025-01-19T15:42:46+00:00"
}, },
{ {
"name": "amphp/serialization", "name": "amphp/serialization",
@ -1641,16 +1641,16 @@
}, },
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "1.12.15", "version": "1.12.16",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "c91d4e8bc056f46cf653656e6f71004b254574d1" "reference": "e0bb5cb78545aae631220735aa706eac633a6be9"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/c91d4e8bc056f46cf653656e6f71004b254574d1", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e0bb5cb78545aae631220735aa706eac633a6be9",
"reference": "c91d4e8bc056f46cf653656e6f71004b254574d1", "reference": "e0bb5cb78545aae631220735aa706eac633a6be9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1695,7 +1695,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2025-01-05T16:40:22+00:00" "time": "2025-01-21T14:50:05+00:00"
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
@ -2022,16 +2022,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "11.5.2", "version": "11.5.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "153d0531b9f7e883c5053160cad6dd5ac28140b3" "reference": "30e319e578a7b5da3543073e30002bf82042f701"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/153d0531b9f7e883c5053160cad6dd5ac28140b3", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/30e319e578a7b5da3543073e30002bf82042f701",
"reference": "153d0531b9f7e883c5053160cad6dd5ac28140b3", "reference": "30e319e578a7b5da3543073e30002bf82042f701",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2052,7 +2052,7 @@
"phpunit/php-timer": "^7.0.1", "phpunit/php-timer": "^7.0.1",
"sebastian/cli-parser": "^3.0.2", "sebastian/cli-parser": "^3.0.2",
"sebastian/code-unit": "^3.0.2", "sebastian/code-unit": "^3.0.2",
"sebastian/comparator": "^6.2.1", "sebastian/comparator": "^6.3.0",
"sebastian/diff": "^6.0.2", "sebastian/diff": "^6.0.2",
"sebastian/environment": "^7.2.0", "sebastian/environment": "^7.2.0",
"sebastian/exporter": "^6.3.0", "sebastian/exporter": "^6.3.0",
@ -2103,7 +2103,7 @@
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues", "issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy", "security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.2" "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.3"
}, },
"funding": [ "funding": [
{ {
@ -2119,7 +2119,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-12-21T05:51:08+00:00" "time": "2025-01-13T09:36:00+00:00"
}, },
{ {
"name": "psalm/plugin-phpunit", "name": "psalm/plugin-phpunit",
@ -4231,12 +4231,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/vimeo/psalm.git", "url": "https://github.com/vimeo/psalm.git",
"reference": "765dcbfe43002e52e4808b65561842784fe7bcc7" "reference": "a17fdd709d1322edc47e8fa53c18b1d94ce8bdd8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/vimeo/psalm/zipball/765dcbfe43002e52e4808b65561842784fe7bcc7", "url": "https://api.github.com/repos/vimeo/psalm/zipball/a17fdd709d1322edc47e8fa53c18b1d94ce8bdd8",
"reference": "765dcbfe43002e52e4808b65561842784fe7bcc7", "reference": "a17fdd709d1322edc47e8fa53c18b1d94ce8bdd8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -4254,15 +4254,15 @@
"ext-simplexml": "*", "ext-simplexml": "*",
"ext-tokenizer": "*", "ext-tokenizer": "*",
"felixfbecker/advanced-json-rpc": "^3.1", "felixfbecker/advanced-json-rpc": "^3.1",
"felixfbecker/language-server-protocol": "^1.5.2", "felixfbecker/language-server-protocol": "^1.5.3",
"fidry/cpu-core-counter": "^0.4.1 || ^0.5.1 || ^1.0.0", "fidry/cpu-core-counter": "^0.4.1 || ^0.5.1 || ^1.0.0",
"netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0",
"nikic/php-parser": "^5.0.0", "nikic/php-parser": "^5.0.0",
"php": "~8.1.17 || ~8.2.4 || ~8.3.0 || ~8.4.0", "php": "~8.1.17 || ~8.2.4 || ~8.3.0 || ~8.4.0",
"sebastian/diff": "^4.0 || ^5.0 || ^6.0", "sebastian/diff": "^4.0 || ^5.0 || ^6.0",
"spatie/array-to-xml": "^2.17.0 || ^3.0", "spatie/array-to-xml": "^2.17.0 || ^3.0",
"symfony/console": "^4.1.6 || ^5.0 || ^6.0 || ^7.0", "symfony/console": "^6.0 || ^7.0",
"symfony/filesystem": "^5.4 || ^6.0 || ^7.0" "symfony/filesystem": "^6.0 || ^7.0"
}, },
"provide": { "provide": {
"psalm/psalm": "self.version" "psalm/psalm": "self.version"
@ -4279,10 +4279,10 @@
"phpstan/phpdoc-parser": "^1.6", "phpstan/phpdoc-parser": "^1.6",
"phpunit/phpunit": "^9.6", "phpunit/phpunit": "^9.6",
"psalm/plugin-mockery": "^1.1", "psalm/plugin-mockery": "^1.1",
"psalm/plugin-phpunit": "^0.18", "psalm/plugin-phpunit": "^0.19",
"slevomat/coding-standard": "^8.4", "slevomat/coding-standard": "^8.4",
"squizlabs/php_codesniffer": "^3.6", "squizlabs/php_codesniffer": "^3.6",
"symfony/process": "^4.4 || ^5.0 || ^6.0 || ^7.0" "symfony/process": "^6.0 || ^7.0"
}, },
"suggest": { "suggest": {
"ext-curl": "In order to send data to shepherd", "ext-curl": "In order to send data to shepherd",
@ -4303,7 +4303,8 @@
"dev-3.x": "3.x-dev", "dev-3.x": "3.x-dev",
"dev-4.x": "4.x-dev", "dev-4.x": "4.x-dev",
"dev-5.x": "5.x-dev", "dev-5.x": "5.x-dev",
"dev-master": "6.x-dev" "dev-6.x": "6.x-dev",
"dev-master": "7.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -4332,7 +4333,7 @@
"issues": "https://github.com/vimeo/psalm/issues", "issues": "https://github.com/vimeo/psalm/issues",
"source": "https://github.com/vimeo/psalm" "source": "https://github.com/vimeo/psalm"
}, },
"time": "2024-12-15T08:19:36+00:00" "time": "2025-01-27T10:58:44+00:00"
}, },
{ {
"name": "webmozart/assert", "name": "webmozart/assert",
@ -4402,7 +4403,7 @@
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
"php": "^8.2" "php": "^8.4"
}, },
"platform-dev": {}, "platform-dev": {},
"plugin-api-version": "2.6.0" "plugin-api-version": "2.6.0"

View File

@ -12,11 +12,5 @@
<directory name="src"/> <directory name="src"/>
<directory name="tests"/> <directory name="tests"/>
<directory name="benchmark"/> <directory name="benchmark"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles> </projectFiles>
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
</psalm> </psalm>

View File

@ -10,6 +10,7 @@ class ScheduleLoop extends Schedule
{ {
} }
#[\Override]
public function visit(int $depth = -1, int $maxDepth = 0): float public function visit(int $depth = -1, int $maxDepth = 0): float
{ {
$delta = $this->scheduleToLoop->visit($depth + 1, $maxDepth); $delta = $this->scheduleToLoop->visit($depth + 1, $maxDepth);

View File

@ -13,6 +13,7 @@ class ScheduleSequence extends Schedule
{ {
} }
#[\Override]
public function visit(int $depth = -1, int $maxDepth = 0): float public function visit(int $depth = -1, int $maxDepth = 0): float
{ {
$maxDelta = 0; $maxDelta = 0;

View File

@ -10,6 +10,7 @@ class ScheduleStep extends Schedule
{ {
} }
#[\Override]
public function visit(int $depth = -1, int $maxDepth = 0): float public function visit(int $depth = -1, int $maxDepth = 0): float
{ {
return $this->factor->updateMessageIndex($this->index); return $this->factor->updateMessageIndex($this->index);

View File

@ -12,18 +12,18 @@ class GameInfo
/** /**
* Default initial mean / 6 * Default initial mean / 6
*/ */
private const DEFAULT_BETA = 4.1666666666666666666666666666667; private const float DEFAULT_BETA = 4.1666666666666666666666666666667;
private const DEFAULT_DRAW_PROBABILITY = 0.10; private const float DEFAULT_DRAW_PROBABILITY = 0.10;
/** /**
* Default initial mean / 300 * Default initial mean / 300
*/ */
private const DEFAULT_DYNAMICS_FACTOR = 0.083333333333333333333333333333333; private const float DEFAULT_DYNAMICS_FACTOR = 0.083333333333333333333333333333333;
private const DEFAULT_INITIAL_MEAN = 25.0; private const float DEFAULT_INITIAL_MEAN = 25.0;
private const DEFAULT_INITIAL_STANDARD_DEVIATION = 8.3333333333333333333333333333333; private const float DEFAULT_INITIAL_STANDARD_DEVIATION = 8.3333333333333333333333333333333;
public function __construct( public function __construct(
private readonly float $initialMean = self::DEFAULT_INITIAL_MEAN, private readonly float $initialMean = self::DEFAULT_INITIAL_MEAN,

View File

@ -12,9 +12,9 @@ namespace DNW\Skills\Numerics;
*/ */
class GaussianDistribution class GaussianDistribution
{ {
private const DEFAULT_STANDARD_DEVIATION = 1.0; private const float DEFAULT_STANDARD_DEVIATION = 1.0;
private const DEFAULT_MEAN = 0.0; private const float DEFAULT_MEAN = 0.0;
/** /**
* Square Root 2π. * Square Root 2π.
@ -23,7 +23,7 @@ class GaussianDistribution
* *
* @link https://www.wolframalpha.com/input?i=sqrt%282*pi%29 Source of value * @link https://www.wolframalpha.com/input?i=sqrt%282*pi%29 Source of value
*/ */
private const M_SQRT_2_PI = 2.5066282746310005024157652848110452530069867406099383166299235763; private const float M_SQRT_2_PI = 2.5066282746310005024157652848110452530069867406099383166299235763;
/** /**
* Log of Square Root 2π. * Log of Square Root 2π.
@ -32,7 +32,7 @@ class GaussianDistribution
* *
* @link https://www.wolframalpha.com/input?i=log%28sqrt%282*pi%29%29 Source of value * @link https://www.wolframalpha.com/input?i=log%28sqrt%282*pi%29%29 Source of value
*/ */
private const M_LOG_SQRT_2_PI = 0.9189385332046727417803297364056176398613974736377834128171515404; private const float M_LOG_SQRT_2_PI = 0.9189385332046727417803297364056176398613974736377834128171515404;
// precision and precisionMean are used because they make multiplying and dividing simpler // precision and precisionMean are used because they make multiplying and dividing simpler
// (see the accompanying math paper for more details) // (see the accompanying math paper for more details)

View File

@ -8,7 +8,7 @@ use Exception;
class Matrix class Matrix
{ {
public const ERROR_TOLERANCE = 0.0000000001; public const float ERROR_TOLERANCE = 0.0000000001;
/** /**
* @param array<int,array<int,float>> $matrixRowData * @param array<int,array<int,float>> $matrixRowData

View File

@ -9,9 +9,9 @@ namespace DNW\Skills;
*/ */
class Player implements ISupportPartialPlay, ISupportPartialUpdate class Player implements ISupportPartialPlay, ISupportPartialUpdate
{ {
private const DEFAULT_PARTIAL_PLAY_PERCENTAGE = 1.0; // = 100% play time private const float DEFAULT_PARTIAL_PLAY_PERCENTAGE = 1.0; // = 100% play time
private const DEFAULT_PARTIAL_UPDATE_PERCENTAGE = 1.0; private const float DEFAULT_PARTIAL_UPDATE_PERCENTAGE = 1.0;
private readonly float $PartialPlayPct; private readonly float $PartialPlayPct;
@ -47,6 +47,7 @@ class Player implements ISupportPartialPlay, ISupportPartialUpdate
/** /**
* Indicates the percent of the time the player should be weighted where 0.0 indicates the player didn't play and 1.0 indicates the player played 100% of the time. * Indicates the percent of the time the player should be weighted where 0.0 indicates the player didn't play and 1.0 indicates the player played 100% of the time.
*/ */
#[\Override]
public function getPartialPlayPercentage(): float public function getPartialPlayPercentage(): float
{ {
return $this->PartialPlayPct; return $this->PartialPlayPct;
@ -55,6 +56,7 @@ class Player implements ISupportPartialPlay, ISupportPartialUpdate
/** /**
* Indicated how much of a skill update a player should receive where 0.0 represents no update and 1.0 represents 100% of the update. * Indicated how much of a skill update a player should receive where 0.0 represents no update and 1.0 represents 100% of the update.
*/ */
#[\Override]
public function getPartialUpdatePercentage(): float public function getPartialUpdatePercentage(): float
{ {
return $this->PartialUpdatePct; return $this->PartialUpdatePct;

View File

@ -11,7 +11,7 @@ use DNW\Skills\Numerics\GaussianDistribution;
*/ */
class Rating class Rating
{ {
private const CONSERVATIVE_STANDARD_DEVIATION_MULTIPLIER = 3; private const float CONSERVATIVE_STANDARD_DEVIATION_MULTIPLIER = 3;
/** /**
* Constructs a rating. * Constructs a rating.

View File

@ -11,11 +11,11 @@ use Exception;
*/ */
abstract class SkillCalculator abstract class SkillCalculator
{ {
public const NONE = 0x00; public const int NONE = 0x00;
public const PARTIAL_PLAY = 0x01; public const int PARTIAL_PLAY = 0x01;
public const PARTIAL_UPDATE = 0x02; public const int PARTIAL_UPDATE = 0x02;
protected function __construct( protected function __construct(
private readonly int $supportedOptions, private readonly int $supportedOptions,

View File

@ -6,7 +6,7 @@ namespace DNW\Skills;
class Team extends RatingContainer class Team extends RatingContainer
{ {
public function __construct(Player $player = NULL, Rating $rating = NULL) public function __construct(?Player $player = NULL, ?Rating $rating = NULL)
{ {
parent::__construct(); parent::__construct();
if (! $player instanceof Player) { if (! $player instanceof Player) {

View File

@ -32,6 +32,7 @@ class FactorGraphTrueSkillCalculator extends SkillCalculator
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function calculateNewRatings( public function calculateNewRatings(
GameInfo $gameInfo, GameInfo $gameInfo,
array $teams, array $teams,
@ -54,6 +55,7 @@ class FactorGraphTrueSkillCalculator extends SkillCalculator
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function calculateMatchQuality(GameInfo $gameInfo, array $teams): float public function calculateMatchQuality(GameInfo $gameInfo, array $teams): float
{ {
// We need to create the A matrix which is the player team assigments. // We need to create the A matrix which is the player team assigments.

View File

@ -14,6 +14,7 @@ abstract class GaussianFactor extends Factor
/** /**
* Sends the factor-graph message with and returns the log-normalization constant. * Sends the factor-graph message with and returns the log-normalization constant.
*/ */
#[\Override]
protected function sendMessageVariable(Message $message, Variable $variable): float|int protected function sendMessageVariable(Message $message, Variable $variable): float|int
{ {
$marginal = $variable->getValue(); $marginal = $variable->getValue();
@ -24,6 +25,7 @@ abstract class GaussianFactor extends Factor
return $logZ; return $logZ;
} }
#[\Override]
public function createVariableToMessageBinding(Variable $variable): Message public function createVariableToMessageBinding(Variable $variable): Message
{ {
$newDistribution = GaussianDistribution::fromPrecisionMean(0, 0); $newDistribution = GaussianDistribution::fromPrecisionMean(0, 0);

View File

@ -22,6 +22,7 @@ class GaussianGreaterThanFactor extends GaussianFactor
$this->createVariableToMessageBinding($variable); $this->createVariableToMessageBinding($variable);
} }
#[\Override]
public function getLogNormalization(): float public function getLogNormalization(): float
{ {
$vars = $this->getVariables(); $vars = $this->getVariables();
@ -42,6 +43,7 @@ class GaussianGreaterThanFactor extends GaussianFactor
); );
} }
#[\Override]
protected function updateMessageVariable(Message $message, Variable $variable): float protected function updateMessageVariable(Message $message, Variable $variable): float
{ {
$oldMarginal = clone $variable->getValue(); $oldMarginal = clone $variable->getValue();

View File

@ -28,6 +28,7 @@ class GaussianLikelihoodFactor extends GaussianFactor
$this->createVariableToMessageBinding($variable2); $this->createVariableToMessageBinding($variable2);
} }
#[\Override]
public function getLogNormalization(): float public function getLogNormalization(): float
{ {
/** /**
@ -73,6 +74,7 @@ class GaussianLikelihoodFactor extends GaussianFactor
return GaussianDistribution::subtract($newMarginal, $marginal1); return GaussianDistribution::subtract($newMarginal, $marginal1);
} }
#[\Override]
public function updateMessageIndex(int $messageIndex): float public function updateMessageIndex(int $messageIndex): float
{ {
$messages = $this->getMessages(); $messages = $this->getMessages();

View File

@ -29,6 +29,7 @@ class GaussianPriorFactor extends GaussianFactor
$this->createVariableToMessageBindingWithMessage($variable, $newMessage); $this->createVariableToMessageBindingWithMessage($variable, $newMessage);
} }
#[\Override]
protected function updateMessageVariable(Message $message, Variable $variable): float protected function updateMessageVariable(Message $message, Variable $variable): float
{ {
$oldMarginal = clone $variable->getValue(); $oldMarginal = clone $variable->getValue();

View File

@ -127,6 +127,7 @@ class GaussianWeightedSumFactor extends GaussianFactor
} }
} }
#[\Override]
public function getLogNormalization(): float public function getLogNormalization(): float
{ {
$vars = $this->getVariables(); $vars = $this->getVariables();
@ -197,6 +198,7 @@ class GaussianWeightedSumFactor extends GaussianFactor
return $finalDiff; return $finalDiff;
} }
#[\Override]
public function updateMessageIndex(int $messageIndex): float public function updateMessageIndex(int $messageIndex): float
{ {
$allMessages = $this->getMessages(); $allMessages = $this->getMessages();

View File

@ -23,6 +23,7 @@ class GaussianWithinFactor extends GaussianFactor
$this->createVariableToMessageBinding($variable); $this->createVariableToMessageBinding($variable);
} }
#[\Override]
public function getLogNormalization(): float public function getLogNormalization(): float
{ {
/** /**
@ -46,6 +47,7 @@ class GaussianWithinFactor extends GaussianFactor
return -GaussianDistribution::logProductNormalization($messageFromVariable, $message) + log($z); return -GaussianDistribution::logProductNormalization($messageFromVariable, $message) + log($z);
} }
#[\Override]
protected function updateMessageVariable(Message $message, Variable $variable): float protected function updateMessageVariable(Message $message, Variable $variable): float
{ {
$oldMarginal = clone $variable->getValue(); $oldMarginal = clone $variable->getValue();

View File

@ -22,6 +22,7 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
parent::__construct($parentGraph); parent::__construct($parentGraph);
} }
#[\Override]
public function getLocalFactors(): array public function getLocalFactors(): array
{ {
return array_merge( return array_merge(
@ -30,6 +31,7 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
); );
} }
#[\Override]
public function buildLayer(): void public function buildLayer(): void
{ {
$inputVariablesGroups = $this->getInputVariablesGroups(); $inputVariablesGroups = $this->getInputVariablesGroups();
@ -41,6 +43,7 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
$this->teamDifferencesComparisonLayer->buildLayer(); $this->teamDifferencesComparisonLayer->buildLayer();
} }
#[\Override]
public function createPriorSchedule(): ?ScheduleSequence public function createPriorSchedule(): ?ScheduleSequence
{ {
switch (count($this->getInputVariablesGroups())) { switch (count($this->getInputVariablesGroups())) {

View File

@ -13,6 +13,7 @@ use DNW\Skills\FactorGraphs\KeyedVariable;
class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLayer class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLayer
{ {
#[\Override]
public function buildLayer(): void public function buildLayer(): void
{ {
$inputVariablesGroups = $this->getInputVariablesGroups(); $inputVariablesGroups = $this->getInputVariablesGroups();
@ -32,6 +33,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
} }
} }
#[\Override]
public function createPriorSchedule(): ?ScheduleSequence public function createPriorSchedule(): ?ScheduleSequence
{ {
$localFactors = $this->getLocalFactors(); $localFactors = $this->getLocalFactors();
@ -66,6 +68,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
); );
} }
#[\Override]
public function createPosteriorSchedule(): ?ScheduleSequence public function createPosteriorSchedule(): ?ScheduleSequence
{ {
$allFactors = []; $allFactors = [];

View File

@ -27,6 +27,7 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
parent::__construct($parentGraph); parent::__construct($parentGraph);
} }
#[\Override]
public function buildLayer(): void public function buildLayer(): void
{ {
$teams = $this->teams; $teams = $this->teams;
@ -49,6 +50,7 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
} }
} }
#[\Override]
public function createPriorSchedule(): ?ScheduleSequence public function createPriorSchedule(): ?ScheduleSequence
{ {
$localFactors = $this->getLocalFactors(); $localFactors = $this->getLocalFactors();

View File

@ -13,6 +13,7 @@ use DNW\Skills\FactorGraphs\ScheduleSequence;
class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
{ {
#[\Override]
public function buildLayer(): void public function buildLayer(): void
{ {
$inputVarGroups = $this->getInputVariablesGroups(); $inputVarGroups = $this->getInputVariablesGroups();
@ -51,6 +52,7 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
return $this->getParentFactorGraph()->getVariableFactory()->createKeyedVariable($key); return $this->getParentFactorGraph()->getVariableFactory()->createKeyedVariable($key);
} }
#[\Override]
public function createPriorSchedule(): ?ScheduleSequence public function createPriorSchedule(): ?ScheduleSequence
{ {
$localFactors = $this->getLocalFactors(); $localFactors = $this->getLocalFactors();
@ -65,6 +67,7 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
); );
} }
#[\Override]
public function createPosteriorSchedule(): ?ScheduleSequence public function createPosteriorSchedule(): ?ScheduleSequence
{ {
$localFactors = $this->getLocalFactors(); $localFactors = $this->getLocalFactors();

View File

@ -23,6 +23,7 @@ class TeamDifferencesComparisonLayer extends TrueSkillFactorGraphLayer
$this->epsilon = DrawMargin::getDrawMarginFromDrawProbability($gameInfo->getDrawProbability(), $gameInfo->getBeta()); $this->epsilon = DrawMargin::getDrawMarginFromDrawProbability($gameInfo->getDrawProbability(), $gameInfo->getBeta());
} }
#[\Override]
public function buildLayer(): void public function buildLayer(): void
{ {
$inputVarGroups = $this->getInputVariablesGroups(); $inputVarGroups = $this->getInputVariablesGroups();

View File

@ -9,6 +9,7 @@ use DNW\Skills\TrueSkill\Factors\GaussianWeightedSumFactor;
class TeamPerformancesToTeamPerformanceDifferencesLayer extends TrueSkillFactorGraphLayer class TeamPerformancesToTeamPerformanceDifferencesLayer extends TrueSkillFactorGraphLayer
{ {
#[\Override]
public function buildLayer(): void public function buildLayer(): void
{ {
$inputVariablesGroups = $this->getInputVariablesGroups(); $inputVariablesGroups = $this->getInputVariablesGroups();

View File

@ -31,6 +31,7 @@ class TwoPlayerTrueSkillCalculator extends SkillCalculator
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function calculateNewRatings( public function calculateNewRatings(
GameInfo $gameInfo, GameInfo $gameInfo,
array $teams, array $teams,
@ -138,6 +139,7 @@ class TwoPlayerTrueSkillCalculator extends SkillCalculator
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function calculateMatchQuality(GameInfo $gameInfo, array $teams): float public function calculateMatchQuality(GameInfo $gameInfo, array $teams): float
{ {
$this->validateTeamCountAndPlayersCountPerTeam($teams); $this->validateTeamCountAndPlayersCountPerTeam($teams);

View File

@ -31,6 +31,7 @@ class TwoTeamTrueSkillCalculator extends SkillCalculator
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function calculateNewRatings(GameInfo $gameInfo, array $teams, array $teamRanks): RatingContainer public function calculateNewRatings(GameInfo $gameInfo, array $teams, array $teamRanks): RatingContainer
{ {
$this->validateTeamCountAndPlayersCountPerTeam($teams); $this->validateTeamCountAndPlayersCountPerTeam($teams);
@ -146,6 +147,7 @@ class TwoTeamTrueSkillCalculator extends SkillCalculator
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
#[\Override]
public function calculateMatchQuality(GameInfo $gameInfo, array $teams): float public function calculateMatchQuality(GameInfo $gameInfo, array $teams): float
{ {
$this->validateTeamCountAndPlayersCountPerTeam($teams); $this->validateTeamCountAndPlayersCountPerTeam($teams);

View File

@ -14,7 +14,7 @@ use PHPUnit\Framework\Attributes\UsesClass;
#[UsesClass(BasicMath::class)] #[UsesClass(BasicMath::class)]
class GaussianDistributionTest extends TestCase class GaussianDistributionTest extends TestCase
{ {
private const ERROR_TOLERANCE = 0.000001; private const float ERROR_TOLERANCE = 0.000001;
public function testGetters(): void public function testGetters(): void
{ {

View File

@ -16,7 +16,7 @@ use PHPUnit\Framework\Attributes\UsesClass;
#[UsesClass(GaussianDistribution::class)] #[UsesClass(GaussianDistribution::class)]
class DrawMarginTest extends TestCase class DrawMarginTest extends TestCase
{ {
private const ERROR_TOLERANCE = 0.000001; private const float ERROR_TOLERANCE = 0.000001;
public function testGetDrawMarginFromDrawProbability(): void public function testGetDrawMarginFromDrawProbability(): void
{ {

View File

@ -13,9 +13,9 @@ use PHPUnit\Framework\TestCase;
class TrueSkillCalculatorTests class TrueSkillCalculatorTests
{ {
private const ERROR_TOLERANCE_TRUESKILL = 0.085; private const float ERROR_TOLERANCE_TRUESKILL = 0.085;
private const ERROR_TOLERANCE_MATCH_QUALITY = 0.0005; private const float ERROR_TOLERANCE_MATCH_QUALITY = 0.0005;
// These are the roll-up ones // These are the roll-up ones