mirror of
https://github.com/furyfire/trueskill.git
synced 2025-03-26 02:58:00 +00:00
Tenative pass at getting prior layer working. Found out about division by zero and closure differences.
This commit is contained in:
@ -31,7 +31,7 @@ abstract class GaussianFactor extends Factor
|
||||
|
||||
public function createVariableToMessageBinding(Variable &$variable)
|
||||
{
|
||||
return parent::createVariableToMessageBinding($variable,
|
||||
return parent::createVariableToMessageBindingWithMessage($variable,
|
||||
new Message(
|
||||
GaussianDistribution::fromPrecisionMean(0, 0),
|
||||
"message from {0} to {1}", $this));
|
||||
|
@ -23,11 +23,11 @@ class GaussianPriorFactor extends GaussianFactor
|
||||
{
|
||||
parent::__construct("Prior value going to {0}");
|
||||
$this->_newMessage = new GaussianDistribution($mean, sqrt($variance));
|
||||
$this->createVariableToMessageBinding($variable,
|
||||
new Message(
|
||||
GaussianDistribution::fromPrecisionMean(0, 0),
|
||||
$newMessage = new Message(GaussianDistribution::fromPrecisionMean(0, 0),
|
||||
"message from {0} to {1}",
|
||||
$this, variable));
|
||||
$this, $variable);
|
||||
|
||||
$this->createVariableToMessageBindingWithMessage($variable, $newMessage);
|
||||
}
|
||||
|
||||
protected function updateMessageVariable(Message &$message, Variable &$variable)
|
||||
|
@ -35,11 +35,12 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
|
||||
{
|
||||
$currentTeamPlayerRating = $currentTeam->getRating($currentTeamPlayer);
|
||||
$playerSkill = $this->createSkillOutputVariable($currentTeamPlayer);
|
||||
$this->addLayerFactor($this->createPriorFactor($currentTeamPlayer, $currentTeamPlayerRating, $playerSkill));
|
||||
$priorFactor = $this->createPriorFactor($currentTeamPlayer, $currentTeamPlayerRating, $playerSkill);
|
||||
$this->addLayerFactor($priorFactor);
|
||||
$currentTeamSkills[] = $playerSkill;
|
||||
}
|
||||
|
||||
$outputVariablesGroups = $this->getOutputVariablesGroups();
|
||||
$outputVariablesGroups = &$this->getOutputVariablesGroups();
|
||||
$outputVariablesGroups[] = $currentTeamSkills;
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
|
||||
array_map(
|
||||
function($likelihood)
|
||||
{
|
||||
return $this->scheduleStep("Skill to Perf step", $likelihood, 0);
|
||||
return new ScheduleStep("Skill to Perf step", $likelihood, 0);
|
||||
},
|
||||
$this->getLocalFactors()),
|
||||
"All skill to performance sending");
|
||||
|
@ -15,6 +15,7 @@ require_once(dirname(__FILE__) . '/Layers/PlayerSkillsToPerformancesLayer.php');
|
||||
require_once(dirname(__FILE__) . '/Layers/TeamDifferencesComparisonLayer.php');
|
||||
require_once(dirname(__FILE__) . '/Layers/TeamPerformancesToTeamPerformanceDifferencesLayer.php');
|
||||
|
||||
use Moserware\Numerics\GaussianDistribution;
|
||||
use Moserware\Skills\GameInfo;
|
||||
use Moserware\Skills\Rating;
|
||||
use Moserware\Skills\FactorGraphs\FactorGraph;
|
||||
@ -32,8 +33,7 @@ class TrueSkillFactorGraph extends FactorGraph
|
||||
{
|
||||
private $_gameInfo;
|
||||
private $_layers;
|
||||
private $_priorLayer;
|
||||
private $_variableFactory;
|
||||
private $_priorLayer;
|
||||
|
||||
public function __construct(GameInfo &$gameInfo, &$teams, array $teamRanks)
|
||||
{
|
||||
@ -44,8 +44,8 @@ class TrueSkillFactorGraph extends FactorGraph
|
||||
{
|
||||
return GaussianDistribution::fromPrecisionMean(0, 0);
|
||||
});
|
||||
|
||||
$this->setVariableFactory($newFactory);
|
||||
|
||||
$this->_layers = array(
|
||||
$this->_priorLayer,
|
||||
new PlayerSkillsToPerformancesLayer($this),
|
||||
|
Reference in New Issue
Block a user