mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-15 17:37:39 +00:00
Some minor documentation cleanup (e.g. converted C# comments to PHPDocumentor comments)
This commit is contained in:
@ -2,8 +2,8 @@
|
||||
|
||||
namespace Moserware\Skills\Elo;
|
||||
|
||||
require_once(dirname(__FILE__) . "/TwoPlayerEloCalculator.php");
|
||||
require_once(dirname(__FILE__) . "/FideKFactor.php");
|
||||
require_once(dirname(__FILE__) . "/TwoPlayerEloCalculator.php");
|
||||
|
||||
/** Including Elo's scheme as a simple comparison.
|
||||
* See http://en.wikipedia.org/wiki/Elo_rating_system#Theory
|
||||
|
@ -23,13 +23,17 @@ abstract class Factor
|
||||
$this->_messageToVariableBinding = new HashMap();
|
||||
}
|
||||
|
||||
/// Returns the log-normalization constant of that factor
|
||||
/**
|
||||
* @return The log-normalization constant of that factor
|
||||
*/
|
||||
public function getLogNormalization()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Returns the number of messages that the factor has
|
||||
/**
|
||||
* @return The number of messages that the factor has
|
||||
*/
|
||||
public function getNumberOfMessages()
|
||||
{
|
||||
return count($this->_messages);
|
||||
@ -45,7 +49,9 @@ abstract class Factor
|
||||
return $this->_messages;
|
||||
}
|
||||
|
||||
/// Update the message and marginal of the i-th variable that the factor is connected to
|
||||
/**
|
||||
* Update the message and marginal of the i-th variable that the factor is connected to
|
||||
*/
|
||||
public function updateMessageIndex($messageIndex)
|
||||
{
|
||||
Guard::argumentIsValidIndex($messageIndex, count($this->_messages), "messageIndex");
|
||||
@ -59,7 +65,9 @@ abstract class Factor
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
/// Resets the marginal of the variables a factor is connected to
|
||||
/**
|
||||
* Resets the marginal of the variables a factor is connected to
|
||||
*/
|
||||
public function resetMarginals()
|
||||
{
|
||||
$allValues = &$this->_messageToVariableBinding->getAllValues();
|
||||
@ -69,7 +77,9 @@ abstract class Factor
|
||||
}
|
||||
}
|
||||
|
||||
/// Sends the ith message to the marginal and returns the log-normalization constant
|
||||
/**
|
||||
* Sends the ith message to the marginal and returns the log-normalization constant
|
||||
*/
|
||||
public function sendMessageIndex($messageIndex)
|
||||
{
|
||||
Guard::argumentIsValidIndex($messageIndex, count($this->_messages), "messageIndex");
|
||||
|
@ -4,9 +4,9 @@ namespace Moserware\Skills\FactorGraphs;
|
||||
|
||||
require_once(dirname(__FILE__) . "/Factor.php");
|
||||
|
||||
/// <summary>
|
||||
/// Helper class for computing the factor graph's normalization constant.
|
||||
/// </summary>
|
||||
/**
|
||||
* Helper class for computing the factor graph's normalization constant.
|
||||
*/
|
||||
class FactorList
|
||||
{
|
||||
private $_list = array();
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
namespace Moserware\Skills;
|
||||
|
||||
/// <summary>
|
||||
/// Verifies argument contracts.
|
||||
/// </summary>
|
||||
/// <remarks>These are used until .NET 4.0 ships with Contracts. For more information,
|
||||
/// see http://www.moserware.com/2008/01/borrowing-ideas-from-3-interesting.html</remarks>
|
||||
/**
|
||||
* Verifies argument contracts.
|
||||
*
|
||||
* @see http://www.moserware.com/2008/01/borrowing-ideas-from-3-interesting.html
|
||||
*/
|
||||
class Guard
|
||||
{
|
||||
public static function argumentNotNull($value, $parameterName)
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
namespace Moserware\Skills;
|
||||
|
||||
/**
|
||||
* Basic hashmap that supports object keys.
|
||||
*/
|
||||
class HashMap
|
||||
{
|
||||
private $_hashToValue = array();
|
||||
|
@ -2,22 +2,30 @@
|
||||
/**
|
||||
* Basic math functions.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Math
|
||||
* @package PHPSkills
|
||||
* @author Jeff Moser <jeff@moserware.com>
|
||||
* @copyright 2010 Jeff Moser
|
||||
*/
|
||||
|
||||
/**
|
||||
* Squares the input (x^2 = x * x)
|
||||
* @param number $x Value to square (x)
|
||||
* @return number The squared value (x^2)
|
||||
*/
|
||||
function square($x)
|
||||
{
|
||||
return $x * $x;
|
||||
}
|
||||
|
||||
function sum(array $itemsToSum, $funcName )
|
||||
/**
|
||||
* Sums the items in $itemsToSum
|
||||
* @param array $itemsToSum The items to sum,
|
||||
* @param callback $callback The function to apply to each array element before summing.
|
||||
* @return number The sum.
|
||||
*/
|
||||
function sum(array $itemsToSum, $callback )
|
||||
{
|
||||
$mappedItems = array_map($funcName, $itemsToSum);
|
||||
$mappedItems = array_map($callback, $itemsToSum);
|
||||
return array_sum($mappedItems);
|
||||
}
|
||||
|
||||
|
@ -1,30 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Computes Gaussian values.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Math
|
||||
* @package PHPSkills
|
||||
* @author Jeff Moser <jeff@moserware.com>
|
||||
* @copyright 2010 Jeff Moser
|
||||
*/
|
||||
|
||||
namespace Moserware\Numerics;
|
||||
|
||||
require_once(dirname(__FILE__) . "/basicmath.php");
|
||||
|
||||
/**
|
||||
* Computes Gaussian (bell curve) values.
|
||||
*
|
||||
* @package PHPSkills
|
||||
* @author Jeff Moser <jeff@moserware.com>
|
||||
* @copyright 2010 Jeff Moser
|
||||
*/
|
||||
class GaussianDistribution
|
||||
{
|
||||
private $_mean;
|
||||
private $_standardDeviation;
|
||||
|
||||
// Precision and PrecisionMean are used because they make multiplying and dividing simpler
|
||||
// precision and precisionMean are used because they make multiplying and dividing simpler
|
||||
// (the the accompanying math paper for more details)
|
||||
private $_precision;
|
||||
private $_precisionMean;
|
||||
private $_variance;
|
||||
|
||||
|
||||
function __construct($mean = 0.0, $standardDeviation = 1.0)
|
||||
{
|
||||
$this->_mean = $mean;
|
||||
|
@ -5,9 +5,9 @@ require_once(dirname(__FILE__) . "/Guard.php");
|
||||
require_once(dirname(__FILE__) . "/ISupportPartialPlay.php");
|
||||
require_once(dirname(__FILE__) . "/ISupportPartialUpdate.php");
|
||||
|
||||
/// <summary>
|
||||
/// Represents a player who has a <see cref="Rating"/>.
|
||||
/// </summary>
|
||||
/**
|
||||
* Represents a player who has a Rating.
|
||||
*/
|
||||
class Player implements ISupportPartialPlay, ISupportPartialUpdate
|
||||
{
|
||||
const DEFAULT_PARTIAL_PLAY_PERCENTAGE = 1.0; // = 100% play time
|
||||
@ -17,12 +17,13 @@ class Player implements ISupportPartialPlay, ISupportPartialUpdate
|
||||
private $_PartialPlayPercentage;
|
||||
private $_PartialUpdatePercentage;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a player.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier for the player, such as a name.</param>
|
||||
/// <param name="partialPlayPercentage">The weight percentage to give this player when calculating a new rank.</param>
|
||||
/// <param name="partialUpdatePercentage">/// Indicated how much of a skill update a player should receive where 0 represents no update and 1.0 represents 100% of the update.</param>
|
||||
/**
|
||||
* Constructs a player.
|
||||
*
|
||||
* @param mixed $id The identifier for the player, such as a name.
|
||||
* @param number $partialPlayPercentage The weight percentage to give this player when calculating a new rank.
|
||||
* @param number $partialUpdatePercentage Indicated how much of a skill update a player should receive where 0 represents no update and 1.0 represents 100% of the update.
|
||||
*/
|
||||
public function __construct($id,
|
||||
$partialPlayPercentage = self::DEFAULT_PARTIAL_PLAY_PERCENTAGE,
|
||||
$partialUpdatePercentage = self::DEFAULT_PARTIAL_UPDATE_PERCENTAGE)
|
||||
@ -35,39 +36,31 @@ class Player implements ISupportPartialPlay, ISupportPartialUpdate
|
||||
$this->_PartialUpdatePercentage = $partialUpdatePercentage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The identifier for the player, such as a name.
|
||||
/// </summary>
|
||||
/**
|
||||
* The identifier for the player, such as a name.
|
||||
*/
|
||||
public function &getId()
|
||||
{
|
||||
$id = &$this->_Id;
|
||||
return $this->_Id;
|
||||
}
|
||||
|
||||
#region ISupportPartialPlay Members
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the percent of the time the player should be weighted where 0.0 indicates the player didn't play and 1.0 indicates the player played 100% of the time.
|
||||
/// </summary>
|
||||
|
||||
/**
|
||||
* Indicates the percent of the time the player should be weighted where 0.0 indicates the player didn't play and 1.0 indicates the player played 100% of the time.
|
||||
*/
|
||||
public function getPartialPlayPercentage()
|
||||
{
|
||||
return $this->_PartialPlayPercentage;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISupportPartialUpdate Members
|
||||
|
||||
/// <summary>
|
||||
/// Indicated how much of a skill update a player should receive where 0.0 represents no update and 1.0 represents 100% of the update.
|
||||
/// </summary>
|
||||
|
||||
/**
|
||||
* Indicated how much of a skill update a player should receive where 0.0 represents no update and 1.0 represents 100% of the update.
|
||||
*/
|
||||
public function getPartialUpdatePercentage()
|
||||
{
|
||||
return $this->_PartialUpdatePercentage;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
if ($this->_Id != null)
|
||||
|
@ -2,17 +2,17 @@
|
||||
|
||||
namespace Moserware\Skills;
|
||||
|
||||
/// <summary>
|
||||
/// Helper class to sort ranks in non-decreasing order.
|
||||
/// </summary>
|
||||
/**
|
||||
* Helper class to sort ranks in non-decreasing order.
|
||||
*/
|
||||
class RankSorter
|
||||
{
|
||||
/// <summary>
|
||||
/// Performs an in-place sort of the <paramref name="items"/> in according to the <paramref name="ranks"/> in non-decreasing order.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The types of items to sort.</typeparam>
|
||||
/// <param name="items">The items to sort according to the order specified by <paramref name="ranks"/>.</param>
|
||||
/// <param name="ranks">The ranks for each item where 1 is first place.</param>
|
||||
/**
|
||||
* Performs an in-place sort of the items in according to the ranks in non-decreasing order.
|
||||
*
|
||||
* @param $items The items to sort according to the order specified by ranks.
|
||||
* @param $ranks The ranks for each item where 1 is first place.
|
||||
*/
|
||||
public static function sort(array &$teams, array &$teamRanks)
|
||||
{
|
||||
array_multisort($teamRanks, $teams);
|
||||
|
@ -21,25 +21,24 @@ abstract class SkillCalculator
|
||||
$this->_playersPerTeamAllowed = $playerPerTeamAllowed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates new ratings based on the prior ratings and team ranks.
|
||||
/// </summary>
|
||||
/// <typeparam name="TPlayer">The underlying type of the player.</typeparam>
|
||||
/// <param name="gameInfo">Parameters for the game.</param>
|
||||
/// <param name="teams">A mapping of team players and their ratings.</param>
|
||||
/// <param name="teamRanks">The ranks of the teams where 1 is first place. For a tie, repeat the number (e.g. 1, 2, 2)</param>
|
||||
/// <returns>All the players and their new ratings.</returns>
|
||||
/**
|
||||
* Calculates new ratings based on the prior ratings and team ranks.
|
||||
* @param $gameInfo Parameters for the game.
|
||||
* @param $teams A mapping of team players and their ratings.
|
||||
* @param $teamRanks The ranks of the teams where 1 is first place. For a tie, repeat the number (e.g. 1, 2, 2).
|
||||
* @return All the players and their new ratings.
|
||||
*/
|
||||
public abstract function calculateNewRatings(GameInfo &$gameInfo,
|
||||
array $teamsOfPlayerToRatings,
|
||||
array $teamRanks);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the match quality as the likelihood of all teams drawing.
|
||||
/// </summary>
|
||||
/// <typeparam name="TPlayer">The underlying type of the player.</typeparam>
|
||||
/// <param name="gameInfo">Parameters for the game.</param>
|
||||
/// <param name="teams">A mapping of team players and their ratings.</param>
|
||||
/// <returns>The quality of the match between the teams as a percentage (0% = bad, 100% = well matched).</returns>
|
||||
/**
|
||||
* Calculates the match quality as the likelihood of all teams drawing.
|
||||
*
|
||||
* @param $gameInfo Parameters for the game.
|
||||
* @param $teams A mapping of team players and their ratings.
|
||||
* @return The quality of the match between the teams as a percentage (0% = bad, 100% = well matched).
|
||||
*/
|
||||
public abstract function calculateMatchQuality(GameInfo &$gameInfo,
|
||||
array &$teamsOfPlayerToRatings);
|
||||
|
||||
|
@ -30,9 +30,9 @@ use Moserware\Skills\SkillCalculator;
|
||||
use Moserware\Skills\SkillCalculatorSupportedOptions;
|
||||
use Moserware\Skills\TeamsRange;
|
||||
|
||||
/// <summary>
|
||||
/// Calculates TrueSkill using a full factor graph.
|
||||
/// </summary>
|
||||
/**
|
||||
* Calculates TrueSkill using a full factor graph.
|
||||
*/
|
||||
class FactorGraphTrueSkillCalculator extends SkillCalculator
|
||||
{
|
||||
public function __construct()
|
||||
|
@ -19,7 +19,9 @@ abstract class GaussianFactor extends Factor
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
/// Sends the factor-graph message with and returns the log-normalization constant
|
||||
/**
|
||||
* Sends the factor-graph message with and returns the log-normalization constant.
|
||||
*/
|
||||
protected function sendMessageVariable(Message &$message, Variable &$variable)
|
||||
{
|
||||
$marginal = &$variable->getValue();
|
||||
|
@ -1,21 +1,22 @@
|
||||
<?php
|
||||
namespace Moserware\Skills\TrueSkill\Factors;
|
||||
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
require_once(dirname(__FILE__) . "/../TruncatedGaussianCorrectionFunctions.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Message.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Variable.php");
|
||||
require_once(dirname(__FILE__) . "/../../Numerics/GaussianDistribution.php");
|
||||
require_once(dirname(__FILE__) . "/../TruncatedGaussianCorrectionFunctions.php");
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
|
||||
use Moserware\Numerics\GaussianDistribution;
|
||||
use Moserware\Skills\TrueSkill\TruncatedGaussianCorrectionFunctions;
|
||||
use Moserware\Skills\FactorGraphs\Message;
|
||||
use Moserware\Skills\FactorGraphs\Variable;
|
||||
|
||||
/// <summary>
|
||||
/// Factor representing a team difference that has exceeded the draw margin.
|
||||
/// </summary>
|
||||
/// <remarks>See the accompanying math paper for more details.</remarks>
|
||||
/**
|
||||
* Factor representing a team difference that has exceeded the draw margin.
|
||||
*
|
||||
* See the accompanying math paper for more details.
|
||||
*/
|
||||
class GaussianGreaterThanFactor extends GaussianFactor
|
||||
{
|
||||
private $_epsilon;
|
||||
@ -72,12 +73,12 @@ class GaussianGreaterThanFactor extends GaussianFactor
|
||||
GaussianDistribution::multiply($oldMessage, $newMarginal),
|
||||
$oldMarginal);
|
||||
|
||||
/// Update the message and marginal
|
||||
// Update the message and marginal
|
||||
$message->setValue($newMessage);
|
||||
|
||||
$variable->setValue($newMarginal);
|
||||
|
||||
/// Return the difference in the new marginal
|
||||
// Return the difference in the new marginal
|
||||
return GaussianDistribution::subtract($newMarginal, $oldMarginal);
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,20 @@
|
||||
<?php
|
||||
namespace Moserware\Skills\TrueSkill\Factors;
|
||||
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Message.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Variable.php");
|
||||
require_once(dirname(__FILE__) . "/../../Numerics/GaussianDistribution.php");
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
|
||||
use Moserware\Numerics\GaussianDistribution;
|
||||
use Moserware\Skills\FactorGraphs\Message;
|
||||
use Moserware\Skills\FactorGraphs\Variable;
|
||||
|
||||
/// <summary>
|
||||
/// Connects two variables and adds uncertainty.
|
||||
/// </summary>
|
||||
/// <remarks>See the accompanying math paper for more details.</remarks>
|
||||
/**
|
||||
* Connects two variables and adds uncertainty.
|
||||
*
|
||||
* See the accompanying math paper for more details.
|
||||
*/
|
||||
class GaussianLikelihoodFactor extends GaussianFactor
|
||||
{
|
||||
private $_precision;
|
||||
@ -55,12 +56,12 @@ class GaussianLikelihoodFactor extends GaussianFactor
|
||||
|
||||
$newMarginal = GaussianDistribution::multiply($oldMarginalWithoutMessage, $newMessage);
|
||||
|
||||
/// Update the message and marginal
|
||||
// Update the message and marginal
|
||||
|
||||
$message1->setValue($newMessage);
|
||||
$variable1->setValue($newMarginal);
|
||||
|
||||
/// Return the difference in the new marginal
|
||||
// Return the difference in the new marginal
|
||||
return GaussianDistribution::subtract($newMarginal, $marginal1);
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,20 @@
|
||||
<?php
|
||||
namespace Moserware\Skills\TrueSkill\Factors;
|
||||
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Message.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Variable.php");
|
||||
require_once(dirname(__FILE__) . "/../../Numerics/GaussianDistribution.php");
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
|
||||
use Moserware\Numerics\GaussianDistribution;
|
||||
use Moserware\Skills\FactorGraphs\Message;
|
||||
use Moserware\Skills\FactorGraphs\Variable;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Supplies the factor graph with prior information.
|
||||
/// </summary>
|
||||
/// <remarks>See the accompanying math paper for more details.</remarks>
|
||||
/**
|
||||
* Supplies the factor graph with prior information.
|
||||
*
|
||||
* See the accompanying math paper for more details.
|
||||
*/
|
||||
class GaussianPriorFactor extends GaussianFactor
|
||||
{
|
||||
private $_newMessage;
|
||||
|
@ -1,22 +1,23 @@
|
||||
<?php
|
||||
namespace Moserware\Skills\TrueSkill\Factors;
|
||||
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
require_once(dirname(__FILE__) . "/../../Guard.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Message.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Variable.php");
|
||||
require_once(dirname(__FILE__) . "/../../Numerics/GaussianDistribution.php");
|
||||
require_once(dirname(__FILE__) . "/../../Numerics/BasicMath.php");
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
|
||||
use Moserware\Numerics\GaussianDistribution;
|
||||
use Moserware\Skills\Guard;
|
||||
use Moserware\Skills\FactorGraphs\Message;
|
||||
use Moserware\Skills\FactorGraphs\Variable;
|
||||
|
||||
/// <summary>
|
||||
/// Factor that sums together multiple Gaussians.
|
||||
/// </summary>
|
||||
/// <remarks>See the accompanying math paper for more details.</remarks>
|
||||
/**
|
||||
* Factor that sums together multiple Gaussians.
|
||||
*
|
||||
* See the accompanying math paper for more details.s
|
||||
*/
|
||||
class GaussianWeightedSumFactor extends GaussianFactor
|
||||
{
|
||||
private $_variableIndexOrdersForWeights = array();
|
||||
@ -189,12 +190,12 @@ class GaussianWeightedSumFactor extends GaussianFactor
|
||||
|
||||
$newMarginal = GaussianDistribution::multiply($oldMarginalWithoutMessage, $newMessage);
|
||||
|
||||
/// Update the message and marginal
|
||||
// Update the message and marginal
|
||||
|
||||
$messages[0]->setValue($newMessage);
|
||||
$variables[0]->setValue($newMarginal);
|
||||
|
||||
/// Return the difference in the new marginal
|
||||
// Return the difference in the new marginal
|
||||
$finalDiff = GaussianDistribution::subtract($newMarginal, $marginal0);
|
||||
return $finalDiff;
|
||||
}
|
||||
|
@ -1,21 +1,22 @@
|
||||
<?php
|
||||
namespace Moserware\Skills\TrueSkill\Factors;
|
||||
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
require_once(dirname(__FILE__) . "/../TruncatedGaussianCorrectionFunctions.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Message.php");
|
||||
require_once(dirname(__FILE__) . "/../../FactorGraphs/Variable.php");
|
||||
require_once(dirname(__FILE__) . "/../../Numerics/GaussianDistribution.php");
|
||||
require_once(dirname(__FILE__) . "/GaussianFactor.php");
|
||||
|
||||
use Moserware\Numerics\GaussianDistribution;
|
||||
use Moserware\Skills\TrueSkill\TruncatedGaussianCorrectionFunctions;
|
||||
use Moserware\Skills\FactorGraphs\Message;
|
||||
use Moserware\Skills\FactorGraphs\Variable;
|
||||
|
||||
/// <summary>
|
||||
/// Factor representing a team difference that has not exceeded the draw margin.
|
||||
/// </summary>
|
||||
/// <remarks>See the accompanying math paper for more details.</remarks>
|
||||
/**
|
||||
* Factor representing a team difference that has not exceeded the draw margin.
|
||||
*
|
||||
* See the accompanying math paper for more details.
|
||||
*/
|
||||
class GaussianWithinFactor extends GaussianFactor
|
||||
{
|
||||
private $_epsilon;
|
||||
@ -71,11 +72,11 @@ class GaussianWithinFactor extends GaussianFactor
|
||||
GaussianDistribution::multiply($oldMessage, $newMarginal),
|
||||
$oldMarginal);
|
||||
|
||||
/// Update the message and marginal
|
||||
// Update the message and marginal
|
||||
$message->setValue($newMessage);
|
||||
$variable->setValue($newMarginal);
|
||||
|
||||
/// Return the difference in the new marginal
|
||||
// Return the difference in the new marginal
|
||||
return GaussianDistribution::subtract($newMarginal, $oldMarginal);
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,7 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
|
||||
}
|
||||
|
||||
public function createPriorSchedule()
|
||||
{
|
||||
// BLOG about $loop
|
||||
{
|
||||
switch (count($this->getInputVariablesGroups()))
|
||||
{
|
||||
case 0:
|
||||
|
@ -73,8 +73,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
|
||||
}
|
||||
|
||||
public function createPosteriorSchedule()
|
||||
{
|
||||
// BLOG
|
||||
{
|
||||
$allFactors = array();
|
||||
$localFactors = &$this->getLocalFactors();
|
||||
foreach($localFactors as &$currentFactor)
|
||||
|
@ -9,14 +9,14 @@ class TruncatedGaussianCorrectionFunctions
|
||||
{
|
||||
// These functions from the bottom of page 4 of the TrueSkill paper.
|
||||
|
||||
/// <summary>
|
||||
/// The "V" function where the team performance difference is greater than the draw margin.
|
||||
/// </summary>
|
||||
/// <remarks>In the reference F# implementation, this is referred to as "the additive
|
||||
/// correction of a single-sided truncated Gaussian with unit variance."</remarks>
|
||||
/// <param name="teamPerformanceDifference"></param>
|
||||
/// <param name="drawMargin">In the paper, it's referred to as just "ε".</param>
|
||||
/// <returns></returns>
|
||||
/**
|
||||
* The "V" function where the team performance difference is greater than the draw margin.
|
||||
*
|
||||
* In the reference F# implementation, this is referred to as "the additive
|
||||
* correction of a single-sided truncated Gaussian with unit variance."
|
||||
*
|
||||
* @param number $drawMargin In the paper, it's referred to as just "ε".
|
||||
*/
|
||||
public static function vExceedsMarginScaled($teamPerformanceDifference, $drawMargin, $c)
|
||||
{
|
||||
return self::vExceedsMargin($teamPerformanceDifference/$c, $drawMargin/$c);
|
||||
@ -34,15 +34,13 @@ class TruncatedGaussianCorrectionFunctions
|
||||
return GaussianDistribution::at($teamPerformanceDifference - $drawMargin)/$denominator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The "W" function where the team performance difference is greater than the draw margin.
|
||||
/// </summary>
|
||||
/// <remarks>In the reference F# implementation, this is referred to as "the multiplicative
|
||||
/// correction of a single-sided truncated Gaussian with unit variance."</remarks>
|
||||
/// <param name="teamPerformanceDifference"></param>
|
||||
/// <param name="drawMargin"></param>
|
||||
/// <param name="c"></param>
|
||||
/// <returns></returns>
|
||||
/**
|
||||
* The "W" function where the team performance difference is greater than the draw margin.
|
||||
*
|
||||
* In the reference F# implementation, this is referred to as "the multiplicative
|
||||
* correction of a single-sided truncated Gaussian with unit variance."
|
||||
*/
|
||||
|
||||
public static function wExceedsMarginScaled($teamPerformanceDifference, $drawMargin, $c)
|
||||
{
|
||||
return self::wExceedsMargin($teamPerformanceDifference/$c, $drawMargin/$c);
|
||||
|
@ -30,13 +30,13 @@ use Moserware\Skills\SkillCalculatorSupportedOptions;
|
||||
use Moserware\Skills\PlayersRange;
|
||||
use Moserware\Skills\TeamsRange;
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the new ratings for only two players.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When you only have two players, a lot of the math simplifies. The main purpose of this class
|
||||
/// is to show the bare minimum of what a TrueSkill implementation should have.
|
||||
/// </remarks>
|
||||
/**
|
||||
* Calculates the new ratings for only two players.
|
||||
*
|
||||
* When you only have two players, a lot of the math simplifies. The main purpose of this class
|
||||
* is to show the bare minimum of what a TrueSkill implementation should have.
|
||||
*/
|
||||
|
||||
class TwoPlayerTrueSkillCalculator extends SkillCalculator
|
||||
{
|
||||
public function __construct()
|
||||
@ -139,7 +139,9 @@ class TwoPlayerTrueSkillCalculator extends SkillCalculator
|
||||
return new Rating($newMean, $newStdDev);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
/**
|
||||
* {@inheritdoc }
|
||||
*/
|
||||
public function calculateMatchQuality(GameInfo &$gameInfo, array &$teams)
|
||||
{
|
||||
Guard::argumentNotNull($gameInfo, "gameInfo");
|
||||
|
@ -34,12 +34,11 @@ use Moserware\Skills\TeamsRange;
|
||||
|
||||
use Moserware\Skills\Team;
|
||||
|
||||
/// <summary>
|
||||
/// Calculates new ratings for only two teams where each team has 1 or more players.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When you only have two teams, the math is still simple: no factor graphs are used yet.
|
||||
/// </remarks>
|
||||
/**
|
||||
* Calculates new ratings for only two teams where each team has 1 or more players.
|
||||
*
|
||||
* When you only have two teams, the math is still simple: no factor graphs are used yet.
|
||||
*/
|
||||
class TwoTeamTrueSkillCalculator extends SkillCalculator
|
||||
{
|
||||
public function __construct()
|
||||
@ -165,7 +164,9 @@ class TwoTeamTrueSkillCalculator extends SkillCalculator
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
/**
|
||||
* {@inheritdoc }
|
||||
*/
|
||||
public function calculateMatchQuality(GameInfo &$gameInfo,
|
||||
array &$teams)
|
||||
{
|
||||
|
Reference in New Issue
Block a user