diff --git a/PHPSkills/FactorGraphs/VariableFactory.php b/PHPSkills/FactorGraphs/VariableFactory.php index 79226ab..74cb315 100644 --- a/PHPSkills/FactorGraphs/VariableFactory.php +++ b/PHPSkills/FactorGraphs/VariableFactory.php @@ -16,7 +16,8 @@ class VariableFactory public function createBasicVariable() { - $newVar = new Variable($this->_variablePriorInitializer()); + $initializer = $this->_variablePriorInitializer; + $newVar = new Variable("variable", $initializer()); return $newVar; } diff --git a/PHPSkills/PartialPlay.php b/PHPSkills/PartialPlay.php index c1d6c73..4d193e7 100644 --- a/PHPSkills/PartialPlay.php +++ b/PHPSkills/PartialPlay.php @@ -14,7 +14,7 @@ class PartialPlay return 1.0; } - $partialPlayPercentage = $partialPlay->getPartialPlayPercentage(); + $partialPlayPercentage = $player->getPartialPlayPercentage(); // HACK to get around bug near 0 $smallestPercentage = 0.0001; diff --git a/PHPSkills/TrueSkill/Layers/PlayerPerformancesToTeamPerformancesLayer.php b/PHPSkills/TrueSkill/Layers/PlayerPerformancesToTeamPerformancesLayer.php index 30578ae..3f50550 100644 --- a/PHPSkills/TrueSkill/Layers/PlayerPerformancesToTeamPerformancesLayer.php +++ b/PHPSkills/TrueSkill/Layers/PlayerPerformancesToTeamPerformancesLayer.php @@ -1,15 +1,19 @@ getKey()); }, - $teamMembers)); + $teamMembers); + + return new GaussianWeightedSumFactor( + $sumVariable, + $teamMembers, + $weights); } diff --git a/PHPSkills/TrueSkill/Layers/PlayerSkillsToPerformancesLayer.php b/PHPSkills/TrueSkill/Layers/PlayerSkillsToPerformancesLayer.php index 6318d46..261fd2b 100644 --- a/PHPSkills/TrueSkill/Layers/PlayerSkillsToPerformancesLayer.php +++ b/PHPSkills/TrueSkill/Layers/PlayerSkillsToPerformancesLayer.php @@ -28,11 +28,11 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer { $playerPerformance = $this->createOutputVariable($playerSkillVariable->getKey()); $this->addLayerFactor($this->createLikelihood($playerSkillVariable, $playerPerformance)); - $currentTeamPlayerPerformances[] = $playerPerformance; + $currentTeamPlayerPerformances[] = &$playerPerformance; } - $outputVariablesGroups = $this->getOutputVariablesGroups(); - $outputVariablesGroups[] = $currentTeamPlayerPerformances; + $outputVariablesGroups = &$this->getOutputVariablesGroups(); + $outputVariablesGroups[] = &$currentTeamPlayerPerformances; } } diff --git a/PHPSkills/TrueSkill/TrueSkillFactorGraph.php b/PHPSkills/TrueSkill/TrueSkillFactorGraph.php index f484aea..640c23c 100644 --- a/PHPSkills/TrueSkill/TrueSkillFactorGraph.php +++ b/PHPSkills/TrueSkill/TrueSkillFactorGraph.php @@ -75,7 +75,7 @@ class TrueSkillFactorGraph extends FactorGraph $currentLayer->buildLayer(); - $lastOutput = $currentLayer->getOutputVariablesGroups(); + $lastOutput = &$currentLayer->getOutputVariablesGroups(); } }