From f2eca28f299bea4eabeb47c191a6d69d64730a11 Mon Sep 17 00:00:00 2001 From: Jeff Moser Date: Sat, 18 Sep 2010 21:19:51 -0400 Subject: [PATCH] Added more header stuff (requires and uses) along with a forgotten PartialPlay --- PHPSkills/Elo/GaussianEloCalculator.php | 8 +++++ PHPSkills/FactorGraphs/FactorGraphLayer.php | 3 +- PHPSkills/FactorGraphs/FactorList.php | 2 ++ PHPSkills/FactorGraphs/VariableFactory.php | 4 ++- .../FactorGraphTrueSkillCalculator.php | 31 +++++++++++++++++-- .../IteratedTeamDifferencesInnerLayer.php | 4 ++- ...yerPerformancesToTeamPerformancesLayer.php | 4 ++- .../Layers/PlayerPriorValuesToSkillsLayer.php | 16 ++++++++-- .../PlayerSkillsToPerformancesLayer.php | 11 ++++++- .../Layers/TeamDifferencesComparisonLayer.php | 12 ++++++- ...ancesToTeamPerformanceDifferencesLayer.php | 11 ++++++- .../Layers/TrueSkillFactorGraphLayer.php | 5 ++- PartialPlay.php | 30 ++++++++++++++++++ 13 files changed, 129 insertions(+), 12 deletions(-) create mode 100644 PartialPlay.php diff --git a/PHPSkills/Elo/GaussianEloCalculator.php b/PHPSkills/Elo/GaussianEloCalculator.php index ff16154..717e3e3 100644 --- a/PHPSkills/Elo/GaussianEloCalculator.php +++ b/PHPSkills/Elo/GaussianEloCalculator.php @@ -1,6 +1,14 @@ diff --git a/PHPSkills/FactorGraphs/FactorList.php b/PHPSkills/FactorGraphs/FactorList.php index a875e5f..97d9d99 100644 --- a/PHPSkills/FactorGraphs/FactorList.php +++ b/PHPSkills/FactorGraphs/FactorList.php @@ -2,6 +2,8 @@ namespace Moserware\Skills\FactorGraphs; +require_once(dirname(__FILE__) . "Factor.php"); + /// /// Helper class for computing the factor graph's normalization constant. /// diff --git a/PHPSkills/FactorGraphs/VariableFactory.php b/PHPSkills/FactorGraphs/VariableFactory.php index 08c4900..0f13683 100644 --- a/PHPSkills/FactorGraphs/VariableFactory.php +++ b/PHPSkills/FactorGraphs/VariableFactory.php @@ -2,6 +2,8 @@ namespace Moserware\Skills\FactorGraphs; +require_once(dirname(__FILE__) . "Variable.php"); + class VariableFactory { // using a Func to encourage fresh copies in case it's overwritten @@ -23,6 +25,6 @@ class VariableFactory $newVar = new KeyedVariable($key, $this->_variablePriorInitializer()); return $newVar; } -}s +} ?> diff --git a/PHPSkills/TrueSkill/FactorGraphTrueSkillCalculator.php b/PHPSkills/TrueSkill/FactorGraphTrueSkillCalculator.php index 2765c62..695867e 100644 --- a/PHPSkills/TrueSkill/FactorGraphTrueSkillCalculator.php +++ b/PHPSkills/TrueSkill/FactorGraphTrueSkillCalculator.php @@ -2,6 +2,34 @@ namespace Moserware\Skills\TrueSkill; +require_once(dirname(__FILE__) . "/../GameInfo.php"); +require_once(dirname(__FILE__) . "/../Guard.php"); +require_once(dirname(__FILE__) . "/../ISupportPartialPlay.php"); +require_once(dirname(__FILE__) . "/../ISupportPartialUpdate.php"); +require_once(dirname(__FILE__) . "/../PartialPlay.php"); +require_once(dirname(__FILE__) . "/../PlayersRange.php"); +require_once(dirname(__FILE__) . "/../RankSorter.php"); +require_once(dirname(__FILE__) . "/../SkillCalculator.php"); +require_once(dirname(__FILE__) . "/../TeamsRange.php"); +require_once(dirname(__FILE__) . "/../Numerics/BasicMath.php"); +require_once(dirname(__FILE__) . "/../Numerics/Matrix.php"); +require_once(dirname(__FILE__) . "/TrueSkillFactorGraph.php"); + +use Moserware\Numerics\DiagonalMatrix; +use Moserware\Numerics\Matrix; +use Moserware\Numerics\Vector; + +use Moserware\Skills\GameInfo; +use Moserware\Skills\Guard; +use Moserware\Skills\ISupportPartialPlay; +use Moserware\Skills\ISupportPartialUpdate; +use Moserware\Skills\PartialPlay; +use Moserware\Skills\PlayersRange; +use Moserware\Skills\RankSorter; +use Moserware\Skills\SkillCalculator; +use Moserware\Skills\SkillCalculatorSupportedOptions; +use Moserware\Skills\TeamsRange; + /// /// Calculates TrueSkill using a full factor graph. /// @@ -30,12 +58,11 @@ class FactorGraphTrueSkillCalculator extends SkillCalculator return $factorGraph->getUpdatedRatings(); } - public function calculateMatchQuality(GameInfo $gameInfo, array $teams) { // We need to create the A matrix which is the player team assigments. - $teamAssignmentsList = $teams.ToList(); + $teamAssignmentsList = $teams; $skillsMatrix = $this->getPlayerCovarianceMatrix($teamAssignmentsList); $meanVector = $this->getPlayerMeansVector($teamAssignmentsList); $meanVectorTranspose = $meanVector->getTranspose(); diff --git a/PHPSkills/TrueSkill/Layers/IteratedTeamDifferencesInnerLayer.php b/PHPSkills/TrueSkill/Layers/IteratedTeamDifferencesInnerLayer.php index b427617..b830381 100644 --- a/PHPSkills/TrueSkill/Layers/IteratedTeamDifferencesInnerLayer.php +++ b/PHPSkills/TrueSkill/Layers/IteratedTeamDifferencesInnerLayer.php @@ -1,14 +1,16 @@ getOutputVariablesGroups(); + $outputVariablesGroups[] = $currentTeamSkills; } } diff --git a/PHPSkills/TrueSkill/Layers/PlayerSkillsToPerformancesLayer.php b/PHPSkills/TrueSkill/Layers/PlayerSkillsToPerformancesLayer.php index 9e52fb6..95e40b4 100644 --- a/PHPSkills/TrueSkill/Layers/PlayerSkillsToPerformancesLayer.php +++ b/PHPSkills/TrueSkill/Layers/PlayerSkillsToPerformancesLayer.php @@ -1,7 +1,16 @@ getPartialPlayPercentage(); + + // HACK to get around bug near 0 + $smallestPercentage = 0.0001; + if ($partialPlayPercentage < $smallestPercentage) + { + $partialPlayPercentage = $smallestPercentage; + } + + return $partialPlayPercentage; + } +} + +?>