mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-15 17:37:39 +00:00
Start of the long road towards debugging it to work
This commit is contained in:
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
namespace Moserware\Skills\FactorGraphs;
|
||||
|
||||
require_once(dirname(__FILE__) . "../Guard.php");
|
||||
require_once(dirname(__FILE__) . "../HashMap.php");
|
||||
require_once(dirname(__FILE__) . "./../Guard.php");
|
||||
require_once(dirname(__FILE__) . "./../HashMap.php");
|
||||
|
||||
use Moserware\Skills\Guard;
|
||||
use Moserware\Skills\HashMap;
|
||||
|
||||
class Factor
|
||||
abstract class Factor
|
||||
{
|
||||
private $_messages = array();
|
||||
private $_messageToVariableBinding;
|
||||
@ -78,11 +78,11 @@ class Factor
|
||||
|
||||
public abstract function createVariableToMessageBinding($variable);
|
||||
|
||||
protected function createVariableToMessageBinding($variable, $message)
|
||||
protected function createVariableToMessageBindingWithMessage($variable, $message)
|
||||
{
|
||||
$index = count($this->_messages);
|
||||
$this->_messages[] = $message;
|
||||
$this->_messageToVariableBinding->setValue($message) = $variable;
|
||||
$this->_messageToVariableBinding->setValue($message, $variable);
|
||||
$this->_variables[] = $variable;
|
||||
return $message;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Moserware\Skills\FactorGraphs;
|
||||
|
||||
require_once(dirname(__FILE__) . "Factor.php");
|
||||
require_once(dirname(__FILE__) . "./Factor.php");
|
||||
|
||||
/// <summary>
|
||||
/// Helper class for computing the factor graph's normalization constant.
|
||||
|
@ -30,7 +30,7 @@ class ScheduleStep extends Schedule
|
||||
$this->_index = $index;
|
||||
}
|
||||
|
||||
public function visit($depth, $maxDepth)
|
||||
public function visit($depth = -1, $maxDepth = 0)
|
||||
{
|
||||
$delta = $this->_factor->updateMessageIndex($this->_index);
|
||||
return $delta;
|
||||
@ -47,7 +47,7 @@ class ScheduleSequence extends Schedule
|
||||
$this->_schedules = $schedules;
|
||||
}
|
||||
|
||||
public function visit($depth, $maxDepth)
|
||||
public function visit($depth = -1, $maxDepth = 0)
|
||||
{
|
||||
$maxDelta = 0;
|
||||
|
||||
@ -72,7 +72,7 @@ class ScheduleLoop extends Schedule
|
||||
$this->_maxDelta = $maxDelta;
|
||||
}
|
||||
|
||||
public function visit($depth, $maxDepth)
|
||||
public function visit($depth = -1, $maxDepth = 0)
|
||||
{
|
||||
$totalIterations = 1;
|
||||
$delta = $this->_scheduleToLoop->visit($depth + 1, $maxDepth);
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
namespace Moserware\Skills\TrueSkill;
|
||||
|
||||
require_once(dirname(__FILE__) . '../Rating.php');
|
||||
require_once(dirname(__FILE__) . '../FactorGraphs/FactorList.php');
|
||||
require_once(dirname(__FILE__) . '../FactorGraphs/Schedule.php');
|
||||
require_once(dirname(__FILE__) . '../FactorGraphs/VariableFactory.php');
|
||||
require_once(dirname(__FILE__) . '../Numerics/GaussianDistribution.php');
|
||||
require_once(dirname(__FILE__) . './../Rating.php');
|
||||
require_once(dirname(__FILE__) . './../FactorGraphs/FactorList.php');
|
||||
require_once(dirname(__FILE__) . './../FactorGraphs/Schedule.php');
|
||||
require_once(dirname(__FILE__) . './../FactorGraphs/VariableFactory.php');
|
||||
require_once(dirname(__FILE__) . './../Numerics/GaussianDistribution.php');
|
||||
require_once(dirname(__FILE__) . '/Layers/PlayerPriorValuesToSkillsLayer.php');
|
||||
require_once(dirname(__FILE__) . '/Layers/PlayerSkillsToPerformancesLayer.php');
|
||||
require_once(dirname(__FILE__) . '/Layers/IteratedTeamDifferencesInnerLayer.php');
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../PHPSkills/TrueSkill/FactorGraphTrueSkillCalculator.php');
|
||||
require_once(dirname(__FILE__) . '/TrueSkillCalculatorTests.php');
|
||||
|
||||
use \PHPUnit_Framework_TestCase;
|
||||
use Moserware\Skills\TrueSkill\FactorGraphTrueSkillCalculator;
|
||||
|
||||
class FactorGraphTrueSkillCalculatorTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testFactorGraphTrueSkillCalculator()
|
||||
{
|
||||
$calculator = new FactorGraphTrueSkillCalculator();
|
||||
|
||||
// We only support two players
|
||||
TrueSkillCalculatorTests::testAllTwoPlayerScenarios($this, $calculator);
|
||||
TrueSkillCalculatorTests::testAllTwoTeamScenarios($this, $calculator);
|
||||
}
|
||||
}
|
||||
|
||||
$testSuite = new \PHPUnit_Framework_TestSuite();
|
||||
$testSuite->addTest( new TwoTeamTrueSkillCalculatorTest("testFactorGraphTrueSkillCalculator"));
|
||||
|
||||
\PHPUnit_TextUI_TestRunner::run($testSuite);
|
||||
?>
|
Reference in New Issue
Block a user