mirror of
				https://github.com/furyfire/trueskill.git
				synced 2025-11-04 10:12:28 +01:00 
			
		
		
		
	Added more header stuff (requires and uses) along with a forgotten PartialPlay
This commit is contained in:
		@@ -1,6 +1,14 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace Moserware\Skills\Elo;
 | 
			
		||||
 | 
			
		||||
require_once(dirname(__FILE__) . "/../GameInfo.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "/../Numerics/GaussianDistribution.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "/KFactor.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "/TwoPlayerEloCalculator.php");
 | 
			
		||||
 | 
			
		||||
use Moserware\Skills\GameInfo;
 | 
			
		||||
use Moserware\Numerics\GaussianDistribution;
 | 
			
		||||
 | 
			
		||||
class GaussianEloCalculator extends TwoPlayerEloCalculator
 | 
			
		||||
{
 | 
			
		||||
    // From the paper
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace Moserware\Skills\FactorGraphs;
 | 
			
		||||
 | 
			
		||||
require_once(dirname(__FILE__) . "Schedule.php");
 | 
			
		||||
 | 
			
		||||
abstract class FactorGraphLayer
 | 
			
		||||
{
 | 
			
		||||
    private $_localFactors = array();
 | 
			
		||||
@@ -63,5 +65,4 @@ abstract class FactorGraphLayer
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,8 @@
 | 
			
		||||
 | 
			
		||||
namespace Moserware\Skills\FactorGraphs;
 | 
			
		||||
 | 
			
		||||
require_once(dirname(__FILE__) . "Factor.php");
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Helper class for computing the factor graph's normalization constant.
 | 
			
		||||
/// </summary>
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,8 @@
 | 
			
		||||
 | 
			
		||||
namespace Moserware\Skills\FactorGraphs;
 | 
			
		||||
 | 
			
		||||
require_once(dirname(__FILE__) . "Variable.php");
 | 
			
		||||
 | 
			
		||||
class VariableFactory
 | 
			
		||||
{
 | 
			
		||||
    // using a Func<TValue> to encourage fresh copies in case it's overwritten
 | 
			
		||||
@@ -23,6 +25,6 @@ class VariableFactory
 | 
			
		||||
        $newVar = new KeyedVariable($key, $this->_variablePriorInitializer());
 | 
			
		||||
        return $newVar;
 | 
			
		||||
    }
 | 
			
		||||
}s
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Calculates TrueSkill using a full factor graph.
 | 
			
		||||
/// </summary>
 | 
			
		||||
@@ -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();
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,16 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace Moserware\Skills\TrueSkill\Layers;
 | 
			
		||||
 | 
			
		||||
require_once(dirname(__FILE__) . "../../FactorGraphs/Schedule.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "../TrueSkillFactorGraph.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "TrueSkillFactorGraphLayer.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "TeamPerformancesToTeamPerformanceDifferencesLayer.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "TeamDifferencesComparisonLayer.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "../../FactorGraphs/Schedule.php");
 | 
			
		||||
 | 
			
		||||
use Moserware\Skills\FactorGraphs\ScheduleLoop;
 | 
			
		||||
use Moserware\Skills\FactorGraphs\ScheduleSequence;
 | 
			
		||||
use Moserware\Skills\FactorGraphs\ScheduleStep;
 | 
			
		||||
use Moserware\Skills\TrueSkill\TrueSkillFactorGraph;
 | 
			
		||||
 | 
			
		||||
// The whole purpose of this is to do a loop on the bottom
 | 
			
		||||
class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,16 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace Moserware\Skills\TrueSkill\Layers;
 | 
			
		||||
 | 
			
		||||
require_once(dirname(__FILE__) . "../../FactorGraphs/Schedule.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "../TrueSkillFactorGraph.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "TrueSkillFactorGraphLayer.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "TeamPerformancesToTeamPerformanceDifferencesLayer.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "TeamDifferencesComparisonLayer.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "../../FactorGraphs/Schedule.php");
 | 
			
		||||
 | 
			
		||||
use Moserware\Skills\FactorGraphs\ScheduleLoop;
 | 
			
		||||
use Moserware\Skills\FactorGraphs\ScheduleSequence;
 | 
			
		||||
use Moserware\Skills\FactorGraphs\ScheduleStep;
 | 
			
		||||
use Moserware\Skills\TrueSkill\TrueSkillFactorGraph;
 | 
			
		||||
 | 
			
		||||
class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,18 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Moserware\Skills\TrueSkill\Layers;
 | 
			
		||||
 | 
			
		||||
require_once(dirname(__FILE__) . "../../FactorGraphs/Schedule.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "../../Numerics/BasicMath.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "../TrueSkillFactorGraph.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "../Factors/GaussianPriorFactor.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "TrueSkillFactorGraphLayer.php");
 | 
			
		||||
 | 
			
		||||
use Moserware\Skills\FactorGraphs\ScheduleLoop;
 | 
			
		||||
use Moserware\Skills\FactorGraphs\ScheduleSequence;
 | 
			
		||||
use Moserware\Skills\FactorGraphs\ScheduleStep;
 | 
			
		||||
use Moserware\Skills\TrueSkill\TrueSkillFactorGraph;
 | 
			
		||||
use Moserware\Skills\TrueSkill\Factors\GaussianPriorFactor;
 | 
			
		||||
 | 
			
		||||
// We intentionally have no Posterior schedule since the only purpose here is to
 | 
			
		||||
class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
{
 | 
			
		||||
@@ -26,7 +37,8 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
                $currentTeamSkills[] = $playerSkill;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            OutputVariablesGroups.Add(currentTeamSkills);
 | 
			
		||||
            $outputVariablesGroups = $this->getOutputVariablesGroups();
 | 
			
		||||
            $outputVariablesGroups[] = $currentTeamSkills;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,16 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Moserware\Skills\TrueSkill\Layers;
 | 
			
		||||
 | 
			
		||||
require_once(dirname(__FILE__) . "../../FactorGraphs/Schedule.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "../../Numerics/BasicMath.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "../TrueSkillFactorGraph.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "../Factors/GaussianLikelihoodFactor.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "TrueSkillFactorGraphLayer.php");
 | 
			
		||||
 | 
			
		||||
use Moserware\Skills\FactorGraphs\ScheduleStep;
 | 
			
		||||
use Moserware\Skills\TrueSkill\TrueSkillFactorGraph;
 | 
			
		||||
use Moserware\Skills\TrueSkill\Factors\GaussianLikelihoodFactor;
 | 
			
		||||
 | 
			
		||||
class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(TrueSkillFactorGraph $parentGraph)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,17 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Moserware\Skills\TrueSkill\Layers;
 | 
			
		||||
 | 
			
		||||
require_once(dirname(__FILE__) . "../DrawMargin.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "../TrueSkillFactorGraph.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "../Factors/GaussianGreaterThanFactor.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "../Factors/GaussianWithinFactor.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "TrueSkillFactorGraphLayer.php");
 | 
			
		||||
 | 
			
		||||
use Moserware\Skills\TrueSkill\DrawMargin;
 | 
			
		||||
use Moserware\Skills\TrueSkill\TrueSkillFactorGraph;
 | 
			
		||||
use Moserware\Skills\TrueSkill\Factors\GaussianGreaterThanFactor;
 | 
			
		||||
use Moserware\Skills\TrueSkill\Factors\GaussianWithinFactor;
 | 
			
		||||
 | 
			
		||||
class TeamDifferencesComparisonLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
{
 | 
			
		||||
    private $_epsilon;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,16 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Moserware\Skills\TrueSkill\Layers;
 | 
			
		||||
 | 
			
		||||
require_once(dirname(__FILE__) . "../../FactorGraphs/Variable.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "../TrueSkillFactorGraph.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "../Factors/GaussianWeightedSumFactor.php");
 | 
			
		||||
require_once(dirname(__FILE__) . "TrueSkillFactorGraphLayer.php");
 | 
			
		||||
 | 
			
		||||
use Moserware\Skills\FactorGraphs\Variable;
 | 
			
		||||
use Moserware\Skills\TrueSkill\DrawMargin;
 | 
			
		||||
use Moserware\Skills\TrueSkill\TrueSkillFactorGraph;
 | 
			
		||||
use Moserware\Skills\TrueSkill\Factors\GaussianWeightedSumFactor;
 | 
			
		||||
 | 
			
		||||
class TeamPerformancesToTeamPerformanceDifferencesLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(TrueSkillFactorGraph $parentGraph)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,10 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Moserware\Skills\TrueSkill\Layers;
 | 
			
		||||
 | 
			
		||||
require_once(dirname(__FILE__) . "../../FactorGraphs/FactorGraphLayer.php");
 | 
			
		||||
 | 
			
		||||
use Moserware\Skills\FactorGraphs\FactorGraphLayer;
 | 
			
		||||
 | 
			
		||||
abstract class TrueSkillFactorGraphLayer extends FactorGraphLayer
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(TrueSkillFactorGraph $parentGraph)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user