mirror of
https://github.com/furyfire/trueskill.git
synced 2025-04-18 20:04:28 +00:00
Compare commits
3 Commits
2212d45f61
...
5a414b8307
Author | SHA1 | Date | |
---|---|---|---|
5a414b8307 | |||
e2620fde53 | |||
22002891c5 |
@ -1,9 +1,9 @@
|
||||
{
|
||||
"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"],
|
||||
"require": {
|
||||
"php": "^8.2"
|
||||
"php": "^8.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "^1.0",
|
||||
@ -51,7 +51,6 @@
|
||||
"@test",
|
||||
"@lint",
|
||||
"@analyze",
|
||||
"@document",
|
||||
"@metrics",
|
||||
"@html"
|
||||
]
|
||||
|
73
composer.lock
generated
73
composer.lock
generated
@ -4,21 +4,21 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "9bcad23ed6b67a87b77c11db92614e65",
|
||||
"content-hash": "b812db257eb7996abdfd76cc1a74431f",
|
||||
"packages": [],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "amphp/amp",
|
||||
"version": "v3.0.2",
|
||||
"version": "v3.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/amphp/amp.git",
|
||||
"reference": "138801fb68cfc9c329da8a7b39d01ce7291ee4b0"
|
||||
"reference": "7cf7fef3d667bfe4b2560bc87e67d5387a7bcde9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/amphp/amp/zipball/138801fb68cfc9c329da8a7b39d01ce7291ee4b0",
|
||||
"reference": "138801fb68cfc9c329da8a7b39d01ce7291ee4b0",
|
||||
"url": "https://api.github.com/repos/amphp/amp/zipball/7cf7fef3d667bfe4b2560bc87e67d5387a7bcde9",
|
||||
"reference": "7cf7fef3d667bfe4b2560bc87e67d5387a7bcde9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -78,7 +78,7 @@
|
||||
],
|
||||
"support": {
|
||||
"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": [
|
||||
{
|
||||
@ -86,7 +86,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2024-05-10T21:37:46+00:00"
|
||||
"time": "2025-01-26T16:07:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "amphp/byte-stream",
|
||||
@ -227,16 +227,16 @@
|
||||
},
|
||||
{
|
||||
"name": "amphp/pipeline",
|
||||
"version": "v1.2.1",
|
||||
"version": "v1.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/amphp/pipeline.git",
|
||||
"reference": "66c095673aa5b6e689e63b52d19e577459129ab3"
|
||||
"reference": "97cbf289f4d8877acfe58dd90ed5a4370a43caa4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/amphp/pipeline/zipball/66c095673aa5b6e689e63b52d19e577459129ab3",
|
||||
"reference": "66c095673aa5b6e689e63b52d19e577459129ab3",
|
||||
"url": "https://api.github.com/repos/amphp/pipeline/zipball/97cbf289f4d8877acfe58dd90ed5a4370a43caa4",
|
||||
"reference": "97cbf289f4d8877acfe58dd90ed5a4370a43caa4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -282,7 +282,7 @@
|
||||
],
|
||||
"support": {
|
||||
"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": [
|
||||
{
|
||||
@ -290,7 +290,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2024-07-04T00:56:47+00:00"
|
||||
"time": "2025-01-19T15:42:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "amphp/serialization",
|
||||
@ -1641,16 +1641,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan",
|
||||
"version": "1.12.15",
|
||||
"version": "1.12.16",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan.git",
|
||||
"reference": "c91d4e8bc056f46cf653656e6f71004b254574d1"
|
||||
"reference": "e0bb5cb78545aae631220735aa706eac633a6be9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/c91d4e8bc056f46cf653656e6f71004b254574d1",
|
||||
"reference": "c91d4e8bc056f46cf653656e6f71004b254574d1",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/e0bb5cb78545aae631220735aa706eac633a6be9",
|
||||
"reference": "e0bb5cb78545aae631220735aa706eac633a6be9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1695,7 +1695,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2025-01-05T16:40:22+00:00"
|
||||
"time": "2025-01-21T14:50:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
@ -2022,16 +2022,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "11.5.2",
|
||||
"version": "11.5.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "153d0531b9f7e883c5053160cad6dd5ac28140b3"
|
||||
"reference": "30e319e578a7b5da3543073e30002bf82042f701"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/153d0531b9f7e883c5053160cad6dd5ac28140b3",
|
||||
"reference": "153d0531b9f7e883c5053160cad6dd5ac28140b3",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/30e319e578a7b5da3543073e30002bf82042f701",
|
||||
"reference": "30e319e578a7b5da3543073e30002bf82042f701",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2052,7 +2052,7 @@
|
||||
"phpunit/php-timer": "^7.0.1",
|
||||
"sebastian/cli-parser": "^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/environment": "^7.2.0",
|
||||
"sebastian/exporter": "^6.3.0",
|
||||
@ -2103,7 +2103,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.2"
|
||||
"source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.3"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -2119,7 +2119,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-12-21T05:51:08+00:00"
|
||||
"time": "2025-01-13T09:36:00+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psalm/plugin-phpunit",
|
||||
@ -4231,12 +4231,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/vimeo/psalm.git",
|
||||
"reference": "765dcbfe43002e52e4808b65561842784fe7bcc7"
|
||||
"reference": "a17fdd709d1322edc47e8fa53c18b1d94ce8bdd8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/vimeo/psalm/zipball/765dcbfe43002e52e4808b65561842784fe7bcc7",
|
||||
"reference": "765dcbfe43002e52e4808b65561842784fe7bcc7",
|
||||
"url": "https://api.github.com/repos/vimeo/psalm/zipball/a17fdd709d1322edc47e8fa53c18b1d94ce8bdd8",
|
||||
"reference": "a17fdd709d1322edc47e8fa53c18b1d94ce8bdd8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -4254,15 +4254,15 @@
|
||||
"ext-simplexml": "*",
|
||||
"ext-tokenizer": "*",
|
||||
"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",
|
||||
"netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0",
|
||||
"nikic/php-parser": "^5.0.0",
|
||||
"php": "~8.1.17 || ~8.2.4 || ~8.3.0 || ~8.4.0",
|
||||
"sebastian/diff": "^4.0 || ^5.0 || ^6.0",
|
||||
"spatie/array-to-xml": "^2.17.0 || ^3.0",
|
||||
"symfony/console": "^4.1.6 || ^5.0 || ^6.0 || ^7.0",
|
||||
"symfony/filesystem": "^5.4 || ^6.0 || ^7.0"
|
||||
"symfony/console": "^6.0 || ^7.0",
|
||||
"symfony/filesystem": "^6.0 || ^7.0"
|
||||
},
|
||||
"provide": {
|
||||
"psalm/psalm": "self.version"
|
||||
@ -4279,10 +4279,10 @@
|
||||
"phpstan/phpdoc-parser": "^1.6",
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"psalm/plugin-mockery": "^1.1",
|
||||
"psalm/plugin-phpunit": "^0.18",
|
||||
"psalm/plugin-phpunit": "^0.19",
|
||||
"slevomat/coding-standard": "^8.4",
|
||||
"squizlabs/php_codesniffer": "^3.6",
|
||||
"symfony/process": "^4.4 || ^5.0 || ^6.0 || ^7.0"
|
||||
"symfony/process": "^6.0 || ^7.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-curl": "In order to send data to shepherd",
|
||||
@ -4303,7 +4303,8 @@
|
||||
"dev-3.x": "3.x-dev",
|
||||
"dev-4.x": "4.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": {
|
||||
@ -4332,7 +4333,7 @@
|
||||
"issues": "https://github.com/vimeo/psalm/issues",
|
||||
"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",
|
||||
@ -4402,7 +4403,7 @@
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
"php": "^8.2"
|
||||
"php": "^8.4"
|
||||
},
|
||||
"platform-dev": {},
|
||||
"plugin-api-version": "2.6.0"
|
||||
|
@ -12,11 +12,5 @@
|
||||
<directory name="src"/>
|
||||
<directory name="tests"/>
|
||||
<directory name="benchmark"/>
|
||||
<ignoreFiles>
|
||||
<directory name="vendor"/>
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
|
||||
</plugins>
|
||||
</psalm>
|
||||
|
@ -10,6 +10,7 @@ class ScheduleLoop extends Schedule
|
||||
{
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function visit(int $depth = -1, int $maxDepth = 0): float
|
||||
{
|
||||
$delta = $this->scheduleToLoop->visit($depth + 1, $maxDepth);
|
||||
|
@ -13,6 +13,7 @@ class ScheduleSequence extends Schedule
|
||||
{
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function visit(int $depth = -1, int $maxDepth = 0): float
|
||||
{
|
||||
$maxDelta = 0;
|
||||
|
@ -10,6 +10,7 @@ class ScheduleStep extends Schedule
|
||||
{
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function visit(int $depth = -1, int $maxDepth = 0): float
|
||||
{
|
||||
return $this->factor->updateMessageIndex($this->index);
|
||||
|
@ -12,18 +12,18 @@ class GameInfo
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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(
|
||||
private readonly float $initialMean = self::DEFAULT_INITIAL_MEAN,
|
||||
|
@ -12,9 +12,9 @@ namespace DNW\Skills\Numerics;
|
||||
*/
|
||||
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π.
|
||||
@ -23,7 +23,7 @@ class GaussianDistribution
|
||||
*
|
||||
* @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π.
|
||||
@ -32,7 +32,7 @@ class GaussianDistribution
|
||||
*
|
||||
* @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
|
||||
// (see the accompanying math paper for more details)
|
||||
|
@ -8,7 +8,7 @@ use Exception;
|
||||
|
||||
class Matrix
|
||||
{
|
||||
public const ERROR_TOLERANCE = 0.0000000001;
|
||||
public const float ERROR_TOLERANCE = 0.0000000001;
|
||||
|
||||
/**
|
||||
* @param array<int,array<int,float>> $matrixRowData
|
||||
|
@ -9,9 +9,9 @@ namespace DNW\Skills;
|
||||
*/
|
||||
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;
|
||||
|
||||
@ -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.
|
||||
*/
|
||||
#[\Override]
|
||||
public function getPartialPlayPercentage(): float
|
||||
{
|
||||
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.
|
||||
*/
|
||||
#[\Override]
|
||||
public function getPartialUpdatePercentage(): float
|
||||
{
|
||||
return $this->PartialUpdatePct;
|
||||
|
@ -11,7 +11,7 @@ use DNW\Skills\Numerics\GaussianDistribution;
|
||||
*/
|
||||
class Rating
|
||||
{
|
||||
private const CONSERVATIVE_STANDARD_DEVIATION_MULTIPLIER = 3;
|
||||
private const float CONSERVATIVE_STANDARD_DEVIATION_MULTIPLIER = 3;
|
||||
|
||||
/**
|
||||
* Constructs a rating.
|
||||
|
@ -11,11 +11,11 @@ use Exception;
|
||||
*/
|
||||
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(
|
||||
private readonly int $supportedOptions,
|
||||
|
@ -6,7 +6,7 @@ namespace DNW\Skills;
|
||||
|
||||
class Team extends RatingContainer
|
||||
{
|
||||
public function __construct(Player $player = NULL, Rating $rating = NULL)
|
||||
public function __construct(?Player $player = NULL, ?Rating $rating = NULL)
|
||||
{
|
||||
parent::__construct();
|
||||
if (! $player instanceof Player) {
|
||||
|
@ -32,6 +32,7 @@ class FactorGraphTrueSkillCalculator extends SkillCalculator
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
#[\Override]
|
||||
public function calculateNewRatings(
|
||||
GameInfo $gameInfo,
|
||||
array $teams,
|
||||
@ -54,6 +55,7 @@ class FactorGraphTrueSkillCalculator extends SkillCalculator
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
#[\Override]
|
||||
public function calculateMatchQuality(GameInfo $gameInfo, array $teams): float
|
||||
{
|
||||
// We need to create the A matrix which is the player team assigments.
|
||||
|
@ -14,6 +14,7 @@ abstract class GaussianFactor extends Factor
|
||||
/**
|
||||
* Sends the factor-graph message with and returns the log-normalization constant.
|
||||
*/
|
||||
#[\Override]
|
||||
protected function sendMessageVariable(Message $message, Variable $variable): float|int
|
||||
{
|
||||
$marginal = $variable->getValue();
|
||||
@ -24,6 +25,7 @@ abstract class GaussianFactor extends Factor
|
||||
return $logZ;
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function createVariableToMessageBinding(Variable $variable): Message
|
||||
{
|
||||
$newDistribution = GaussianDistribution::fromPrecisionMean(0, 0);
|
||||
|
@ -22,6 +22,7 @@ class GaussianGreaterThanFactor extends GaussianFactor
|
||||
$this->createVariableToMessageBinding($variable);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getLogNormalization(): float
|
||||
{
|
||||
$vars = $this->getVariables();
|
||||
@ -42,6 +43,7 @@ class GaussianGreaterThanFactor extends GaussianFactor
|
||||
);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
protected function updateMessageVariable(Message $message, Variable $variable): float
|
||||
{
|
||||
$oldMarginal = clone $variable->getValue();
|
||||
|
@ -28,6 +28,7 @@ class GaussianLikelihoodFactor extends GaussianFactor
|
||||
$this->createVariableToMessageBinding($variable2);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getLogNormalization(): float
|
||||
{
|
||||
/**
|
||||
@ -73,6 +74,7 @@ class GaussianLikelihoodFactor extends GaussianFactor
|
||||
return GaussianDistribution::subtract($newMarginal, $marginal1);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function updateMessageIndex(int $messageIndex): float
|
||||
{
|
||||
$messages = $this->getMessages();
|
||||
|
@ -29,6 +29,7 @@ class GaussianPriorFactor extends GaussianFactor
|
||||
$this->createVariableToMessageBindingWithMessage($variable, $newMessage);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
protected function updateMessageVariable(Message $message, Variable $variable): float
|
||||
{
|
||||
$oldMarginal = clone $variable->getValue();
|
||||
|
@ -127,6 +127,7 @@ class GaussianWeightedSumFactor extends GaussianFactor
|
||||
}
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getLogNormalization(): float
|
||||
{
|
||||
$vars = $this->getVariables();
|
||||
@ -197,6 +198,7 @@ class GaussianWeightedSumFactor extends GaussianFactor
|
||||
return $finalDiff;
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function updateMessageIndex(int $messageIndex): float
|
||||
{
|
||||
$allMessages = $this->getMessages();
|
||||
|
@ -23,6 +23,7 @@ class GaussianWithinFactor extends GaussianFactor
|
||||
$this->createVariableToMessageBinding($variable);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getLogNormalization(): float
|
||||
{
|
||||
/**
|
||||
@ -46,6 +47,7 @@ class GaussianWithinFactor extends GaussianFactor
|
||||
return -GaussianDistribution::logProductNormalization($messageFromVariable, $message) + log($z);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
protected function updateMessageVariable(Message $message, Variable $variable): float
|
||||
{
|
||||
$oldMarginal = clone $variable->getValue();
|
||||
|
@ -22,6 +22,7 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
|
||||
parent::__construct($parentGraph);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getLocalFactors(): array
|
||||
{
|
||||
return array_merge(
|
||||
@ -30,6 +31,7 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
|
||||
);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function buildLayer(): void
|
||||
{
|
||||
$inputVariablesGroups = $this->getInputVariablesGroups();
|
||||
@ -41,6 +43,7 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
|
||||
$this->teamDifferencesComparisonLayer->buildLayer();
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function createPriorSchedule(): ?ScheduleSequence
|
||||
{
|
||||
switch (count($this->getInputVariablesGroups())) {
|
||||
|
@ -13,6 +13,7 @@ use DNW\Skills\FactorGraphs\KeyedVariable;
|
||||
|
||||
class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLayer
|
||||
{
|
||||
#[\Override]
|
||||
public function buildLayer(): void
|
||||
{
|
||||
$inputVariablesGroups = $this->getInputVariablesGroups();
|
||||
@ -32,6 +33,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
|
||||
}
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function createPriorSchedule(): ?ScheduleSequence
|
||||
{
|
||||
$localFactors = $this->getLocalFactors();
|
||||
@ -66,6 +68,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
|
||||
);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function createPosteriorSchedule(): ?ScheduleSequence
|
||||
{
|
||||
$allFactors = [];
|
||||
|
@ -27,6 +27,7 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
|
||||
parent::__construct($parentGraph);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function buildLayer(): void
|
||||
{
|
||||
$teams = $this->teams;
|
||||
@ -49,6 +50,7 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
|
||||
}
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function createPriorSchedule(): ?ScheduleSequence
|
||||
{
|
||||
$localFactors = $this->getLocalFactors();
|
||||
|
@ -13,6 +13,7 @@ use DNW\Skills\FactorGraphs\ScheduleSequence;
|
||||
|
||||
class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
|
||||
{
|
||||
#[\Override]
|
||||
public function buildLayer(): void
|
||||
{
|
||||
$inputVarGroups = $this->getInputVariablesGroups();
|
||||
@ -51,6 +52,7 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
|
||||
return $this->getParentFactorGraph()->getVariableFactory()->createKeyedVariable($key);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function createPriorSchedule(): ?ScheduleSequence
|
||||
{
|
||||
$localFactors = $this->getLocalFactors();
|
||||
@ -65,6 +67,7 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
|
||||
);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function createPosteriorSchedule(): ?ScheduleSequence
|
||||
{
|
||||
$localFactors = $this->getLocalFactors();
|
||||
|
@ -23,6 +23,7 @@ class TeamDifferencesComparisonLayer extends TrueSkillFactorGraphLayer
|
||||
$this->epsilon = DrawMargin::getDrawMarginFromDrawProbability($gameInfo->getDrawProbability(), $gameInfo->getBeta());
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function buildLayer(): void
|
||||
{
|
||||
$inputVarGroups = $this->getInputVariablesGroups();
|
||||
|
@ -9,6 +9,7 @@ use DNW\Skills\TrueSkill\Factors\GaussianWeightedSumFactor;
|
||||
|
||||
class TeamPerformancesToTeamPerformanceDifferencesLayer extends TrueSkillFactorGraphLayer
|
||||
{
|
||||
#[\Override]
|
||||
public function buildLayer(): void
|
||||
{
|
||||
$inputVariablesGroups = $this->getInputVariablesGroups();
|
||||
|
@ -31,6 +31,7 @@ class TwoPlayerTrueSkillCalculator extends SkillCalculator
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
#[\Override]
|
||||
public function calculateNewRatings(
|
||||
GameInfo $gameInfo,
|
||||
array $teams,
|
||||
@ -138,6 +139,7 @@ class TwoPlayerTrueSkillCalculator extends SkillCalculator
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
#[\Override]
|
||||
public function calculateMatchQuality(GameInfo $gameInfo, array $teams): float
|
||||
{
|
||||
$this->validateTeamCountAndPlayersCountPerTeam($teams);
|
||||
|
@ -31,6 +31,7 @@ class TwoTeamTrueSkillCalculator extends SkillCalculator
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
#[\Override]
|
||||
public function calculateNewRatings(GameInfo $gameInfo, array $teams, array $teamRanks): RatingContainer
|
||||
{
|
||||
$this->validateTeamCountAndPlayersCountPerTeam($teams);
|
||||
@ -146,6 +147,7 @@ class TwoTeamTrueSkillCalculator extends SkillCalculator
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
#[\Override]
|
||||
public function calculateMatchQuality(GameInfo $gameInfo, array $teams): float
|
||||
{
|
||||
$this->validateTeamCountAndPlayersCountPerTeam($teams);
|
||||
|
@ -14,7 +14,7 @@ use PHPUnit\Framework\Attributes\UsesClass;
|
||||
#[UsesClass(BasicMath::class)]
|
||||
class GaussianDistributionTest extends TestCase
|
||||
{
|
||||
private const ERROR_TOLERANCE = 0.000001;
|
||||
private const float ERROR_TOLERANCE = 0.000001;
|
||||
|
||||
public function testGetters(): void
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ use PHPUnit\Framework\Attributes\UsesClass;
|
||||
#[UsesClass(GaussianDistribution::class)]
|
||||
class DrawMarginTest extends TestCase
|
||||
{
|
||||
private const ERROR_TOLERANCE = 0.000001;
|
||||
private const float ERROR_TOLERANCE = 0.000001;
|
||||
|
||||
public function testGetDrawMarginFromDrawProbability(): void
|
||||
{
|
||||
|
@ -13,9 +13,9 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
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
|
||||
|
||||
|
Reference in New Issue
Block a user