Skip to content

Commit

Permalink
Slight tweaks based off references and need for a RatingContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
moserware committed Sep 29, 2010
1 parent a45a1c4 commit 4c7cfef
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
9 changes: 5 additions & 4 deletions PHPSkills/TrueSkill/Factors/GaussianWeightedSumFactor.php
Expand Up @@ -63,13 +63,11 @@ public function __construct(Variable &$sumVariable, array &$variablesToSum, arra
for ($weightsIndex = 1; $weightsIndex < $weightsLength; $weightsIndex++)
{
$currentWeights = array();
$this->_weights[$weightsIndex] = &$currentWeights;


$variableIndices = array();
$variableIndices[0] = $weightsIndex;

$currentWeightsSquared = array();
$this->_weightsSquared[$weightsIndex] = &$currentWeightsSquared;

// keep a single variable to keep track of where we are in the array.
// This is helpful since we skip over one of the spots
Expand Down Expand Up @@ -112,7 +110,10 @@ public function __construct(Variable &$sumVariable, array &$variablesToSum, arra
$currentWeights[$currentDestinationWeightIndex] = $finalWeight;
$currentWeightsSquared[$currentDestinationWeightIndex] = square($finalWeight);
$variableIndices[count($variableWeights)] = 0;
$this->_variableIndexOrdersForWeights[] = &$variableIndices;
$this->_variableIndexOrdersForWeights[] = $variableIndices;

$this->_weights[$weightsIndex] = $currentWeights;
$this->_weightsSquared[$weightsIndex] = $currentWeightsSquared;
}

$this->createVariableToMessageBinding($sumVariable);
Expand Down
Expand Up @@ -29,7 +29,7 @@ public function buildLayer()
$weakerTeam = $inputVariablesGroups[$i + 1][0];

$currentDifference = &$this->createOutputVariable();
$newDifferencesFactor = &$this->createTeamPerformanceToDifferenceFactor($strongerTeam, $weakerTeam, $currentDifference);
$newDifferencesFactor = $this->createTeamPerformanceToDifferenceFactor($strongerTeam, $weakerTeam, $currentDifference);
$this->addLayerFactor($newDifferencesFactor);

// REVIEW: Does it make sense to have groups of one?
Expand Down
10 changes: 7 additions & 3 deletions PHPSkills/TrueSkill/TrueSkillFactorGraph.php
Expand Up @@ -3,6 +3,7 @@

require_once(dirname(__FILE__) . '/../GameInfo.php');
require_once(dirname(__FILE__) . '/../Rating.php');
require_once(dirname(__FILE__) . '/../RatingContainer.php');
require_once(dirname(__FILE__) . '/../FactorGraphs/FactorGraph.php');
require_once(dirname(__FILE__) . '/../FactorGraphs/FactorList.php');
require_once(dirname(__FILE__) . '/../FactorGraphs/Schedule.php');
Expand All @@ -18,6 +19,7 @@
use Moserware\Numerics\GaussianDistribution;
use Moserware\Skills\GameInfo;
use Moserware\Skills\Rating;
use Moserware\Skills\RatingContainer;
use Moserware\Skills\FactorGraphs\FactorGraph;
use Moserware\Skills\FactorGraphs\FactorList;
use Moserware\Skills\FactorGraphs\ScheduleSequence;
Expand Down Expand Up @@ -130,14 +132,16 @@ private function createFullSchedule()

public function getUpdatedRatings()
{
$result = array();
$result = new RatingContainer();

foreach ($this->_priorLayer->getOutputVariablesGroups() as $currentTeam)
{
foreach ($currentTeam as $currentPlayer)
{
$result[$currentPlayer->getKey()] = new Rating($currentPlayer->getValue()->getMean(),
$currentPlayer->getValue()->getStandardDeviation());
$newRating = new Rating($currentPlayer->getValue()->getMean(),
$currentPlayer->getValue()->getStandardDeviation());

$result->setRating($currentPlayer, $newRating);
}
}

Expand Down

0 comments on commit 4c7cfef

Please sign in to comment.