More debugging and realizing how PHP does references

This commit is contained in:
Jeff Moser
2010-09-25 15:46:23 -04:00
parent e8d444e7da
commit 086d94865f
21 changed files with 77 additions and 72 deletions

View File

@ -18,9 +18,9 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
private $_TeamDifferencesComparisonLayer;
private $_TeamPerformancesToTeamPerformanceDifferencesLayer;
public function __construct(TrueSkillFactorGraph $parentGraph,
TeamPerformancesToTeamPerformanceDifferencesLayer $teamPerformancesToPerformanceDifferences,
TeamDifferencesComparisonLayer $teamDifferencesComparisonLayer)
public function __construct(TrueSkillFactorGraph &$parentGraph,
TeamPerformancesToTeamPerformanceDifferencesLayer &$teamPerformancesToPerformanceDifferences,
TeamDifferencesComparisonLayer &$teamDifferencesComparisonLayer)
{
parent::__construct($parentGraph);
$this->_TeamPerformancesToTeamPerformanceDifferencesLayer = $teamPerformancesToPerformanceDifferences;

View File

@ -14,7 +14,7 @@ use Moserware\Skills\TrueSkill\TrueSkillFactorGraph;
class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLayer
{
public function __construct(TrueSkillFactorGraph $parentGraph)
public function __construct(TrueSkillFactorGraph &$parentGraph)
{
parent::__construct($parentGraph);
}
@ -44,7 +44,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
"all player perf to team perf schedule");
}
protected function createPlayerToTeamSumFactor($teamMembers, $sumVariable)
protected function createPlayerToTeamSumFactor(&$teamMembers, &$sumVariable)
{
return new GaussianWeightedSumFactor(
$sumVariable,
@ -74,7 +74,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
return $this->scheduleSequence($allFactors, "all of the team's sum iterations");
}
private function createOutputVariable($team)
private function createOutputVariable(&$team)
{
///$teamMemberNames = String.Join(", ", team.Select(teamMember => teamMember.Key.ToString()).ToArray());
$teamMemberNames = "TODO";

View File

@ -19,7 +19,7 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
{
private $_teams;
public function __construct(TrueSkillFactorGraph $parentGraph, $teams)
public function __construct(TrueSkillFactorGraph &$parentGraph, &$teams)
{
parent::__construct($parentGraph);
$this->_teams = $teams;
@ -31,10 +31,11 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
{
$currentTeamSkills = array();
foreach ($currentTeam as $currentTeamPlayer)
foreach ($currentTeam->getAllPlayers() as $currentTeamPlayer)
{
$playerSkill = $this->createSkillOutputVariable($currentTeamPlayer.Key);
$this->addLayerFactor($this->createPriorFactor($currentTeamPlayer.Key, $currentTeamPlayer.Value, $playerSkill));
$currentTeamPlayerRating = $currentTeam->getRating($currentTeamPlayer);
$playerSkill = $this->createSkillOutputVariable($currentTeamPlayer);
$this->addLayerFactor($this->createPriorFactor($currentTeamPlayer, $currentTeamPlayerRating, $playerSkill));
$currentTeamSkills[] = $playerSkill;
}
@ -55,7 +56,7 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
"All priors");
}
private function createPriorFactor($player, $priorRating, $skillsVariable)
private function createPriorFactor(&$player, &$priorRating, &$skillsVariable)
{
return new GaussianPriorFactor($priorRating->getMean(),
square($priorRating->getStandardDeviation()) +
@ -65,7 +66,9 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
private function createSkillOutputVariable($key)
{
return $this->getParentFactorGraph()->getVariableFactory()->createKeyedVariable($key, "{0}'s skill", $key);
$parentFactorGraph = $this->getParentFactorGraph();
$variableFactory = $parentFactorGraph->getVariableFactory();
return $variableFactory->createKeyedVariable($key, "{0}'s skill", $key);
}
}

View File

@ -13,7 +13,7 @@ use Moserware\Skills\TrueSkill\Factors\GaussianLikelihoodFactor;
class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
{
public function __construct(TrueSkillFactorGraph $parentGraph)
public function __construct(TrueSkillFactorGraph &$parentGraph)
{
parent::__construct($parentGraph);
}
@ -36,12 +36,12 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
}
}
private function createLikelihood($playerSkill, $playerPerformance)
private function createLikelihood(&$playerSkill, &$playerPerformance)
{
return new GaussianLikelihoodFactor(square($this->getParentFactorGraph()->getGameInfo()->getBeta()), $playerPerformance, $playerSkill);
}
private function createOutputVariable($key)
private function createOutputVariable(&$key)
{
return $this->getParentFactorGraph()->getVariableFactory()->createKeyedVariable($key, "{0}'s performance", $key);
}

View File

@ -17,7 +17,7 @@ class TeamDifferencesComparisonLayer extends TrueSkillFactorGraphLayer
private $_epsilon;
private $_teamRanks;
public function __construct(TrueSkillFactorGraph $parentGraph, array $teamRanks)
public function __construct(TrueSkillFactorGraph &$parentGraph, array &$teamRanks)
{
parent::__construct($parentGraph);
$this->_teamRanks = $teamRanks;

View File

@ -13,7 +13,7 @@ use Moserware\Skills\TrueSkill\Factors\GaussianWeightedSumFactor;
class TeamPerformancesToTeamPerformanceDifferencesLayer extends TrueSkillFactorGraphLayer
{
public function __construct(TrueSkillFactorGraph $parentGraph)
public function __construct(TrueSkillFactorGraph &$parentGraph)
{
parent::__construct($parentGraph);
}
@ -38,7 +38,7 @@ class TeamPerformancesToTeamPerformanceDifferencesLayer extends TrueSkillFactorG
}
private function createTeamPerformanceToDifferenceFactor(
Variable $strongerTeam, Variable $weakerTeam, Variable $output)
Variable &$strongerTeam, Variable &$weakerTeam, Variable &$output)
{
return new GaussianWeightedSumFactor($output, array($strongerTeam, $weakerTeam), array(1.0, -1.0));
}

View File

@ -9,7 +9,7 @@ use Moserware\Skills\TrueSkill\TrueSkillFactorGraph;
abstract class TrueSkillFactorGraphLayer extends FactorGraphLayer
{
public function __construct(TrueSkillFactorGraph $parentGraph)
public function __construct(TrueSkillFactorGraph &$parentGraph)
{
parent::__construct($parentGraph);
}