From 03d26de045ec256e7fb7346af65cdc2adc56491e Mon Sep 17 00:00:00 2001 From: Jens True Date: Thu, 29 Feb 2024 10:16:18 +0000 Subject: [PATCH] Tiny type work --- src/FactorGraphs/FactorGraph.php | 7 ++++++- .../Layers/PlayerPerformancesToTeamPerformancesLayer.php | 3 +++ src/TrueSkill/TrueSkillFactorGraph.php | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/FactorGraphs/FactorGraph.php b/src/FactorGraphs/FactorGraph.php index 8698bb7..c07bc4f 100644 --- a/src/FactorGraphs/FactorGraph.php +++ b/src/FactorGraphs/FactorGraph.php @@ -4,10 +4,15 @@ declare(strict_types=1); namespace DNW\Skills\FactorGraphs; -class FactorGraph +abstract class FactorGraph { private VariableFactory $variableFactory; + protected function __construct() + { + $this->variableFactory = new VariableFactory(fn () => NULL); + } + public function getVariableFactory(): VariableFactory { return $this->variableFactory; diff --git a/src/TrueSkill/Layers/PlayerPerformancesToTeamPerformancesLayer.php b/src/TrueSkill/Layers/PlayerPerformancesToTeamPerformancesLayer.php index 8576477..0ed6f33 100644 --- a/src/TrueSkill/Layers/PlayerPerformancesToTeamPerformancesLayer.php +++ b/src/TrueSkill/Layers/PlayerPerformancesToTeamPerformancesLayer.php @@ -18,6 +18,9 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye public function buildLayer(): void { $inputVariablesGroups = $this->getInputVariablesGroups(); + /** + * @var KeyedVariable[] $currentTeam + */ foreach ($inputVariablesGroups as $currentTeam) { $localCurrentTeam = $currentTeam; $teamPerformance = $this->createOutputVariable($localCurrentTeam); diff --git a/src/TrueSkill/TrueSkillFactorGraph.php b/src/TrueSkill/TrueSkillFactorGraph.php index 495c4ef..0be279c 100644 --- a/src/TrueSkill/TrueSkillFactorGraph.php +++ b/src/TrueSkill/TrueSkillFactorGraph.php @@ -37,6 +37,7 @@ class TrueSkillFactorGraph extends FactorGraph */ public function __construct(private readonly GameInfo $gameInfo, array $teams, array $teamRanks) { + parent::__construct(); $this->priorLayer = new PlayerPriorValuesToSkillsLayer($this, $teams); $newFactory = new VariableFactory( static fn(): GaussianDistribution => GaussianDistribution::fromPrecisionMean(0, 0)