mirror of
https://github.com/furyfire/trueskill.git
synced 2025-04-18 20:04:28 +00:00
Pint applied
This commit is contained in:
@ -88,7 +88,7 @@ class FactorGraphTrueSkillCalculator extends SkillCalculator
|
||||
{
|
||||
// A simple vector of all the player means.
|
||||
return new Vector(self::getPlayerRatingValues($teamAssignmentsList,
|
||||
fn($rating) => $rating->getMean()));
|
||||
fn ($rating) => $rating->getMean()));
|
||||
}
|
||||
|
||||
private static function getPlayerCovarianceMatrix(array $teamAssignmentsList)
|
||||
@ -97,7 +97,7 @@ class FactorGraphTrueSkillCalculator extends SkillCalculator
|
||||
// players.
|
||||
return new DiagonalMatrix(
|
||||
self::getPlayerRatingValues($teamAssignmentsList,
|
||||
fn($rating) => BasicMath::square($rating->getStandardDeviation())));
|
||||
fn ($rating) => BasicMath::square($rating->getStandardDeviation())));
|
||||
}
|
||||
|
||||
// Helper function that gets a list of values for all player ratings
|
||||
|
@ -38,6 +38,5 @@ class GaussianPriorFactor extends GaussianFactor
|
||||
$message->setValue($this->_newMessage);
|
||||
|
||||
return GaussianDistribution::subtract($oldMarginal, $newMarginal);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ namespace DNW\Skills\TrueSkill\Layers;
|
||||
use DNW\Skills\FactorGraphs\ScheduleStep;
|
||||
use DNW\Skills\PartialPlay;
|
||||
use DNW\Skills\TrueSkill\Factors\GaussianWeightedSumFactor;
|
||||
use DNW\Skills\TrueSkill\TrueSkillFactorGraph;
|
||||
|
||||
class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLayer
|
||||
{
|
||||
@ -31,7 +30,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
|
||||
|
||||
return $this->scheduleSequence(
|
||||
array_map(
|
||||
fn($weightedSumFactor) => new ScheduleStep('Perf to Team Perf Step', $weightedSumFactor, 0),
|
||||
fn ($weightedSumFactor) => new ScheduleStep('Perf to Team Perf Step', $weightedSumFactor, 0),
|
||||
$localFactors),
|
||||
'all player perf to team perf schedule');
|
||||
}
|
||||
@ -70,7 +69,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
|
||||
|
||||
private function createOutputVariable($team)
|
||||
{
|
||||
$memberNames = array_map(fn($currentPlayer) => (string) ($currentPlayer->getKey()), $team);
|
||||
$memberNames = array_map(fn ($currentPlayer) => (string) ($currentPlayer->getKey()), $team);
|
||||
|
||||
$teamMemberNames = \implode(', ', $memberNames);
|
||||
|
||||
|
@ -46,7 +46,7 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
|
||||
|
||||
return $this->scheduleSequence(
|
||||
array_map(
|
||||
fn($prior) => new ScheduleStep('Prior to Skill Step', $prior, 0),
|
||||
fn ($prior) => new ScheduleStep('Prior to Skill Step', $prior, 0),
|
||||
$localFactors),
|
||||
'All priors');
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ use DNW\Skills\FactorGraphs\KeyedVariable;
|
||||
use DNW\Skills\FactorGraphs\ScheduleStep;
|
||||
use DNW\Skills\Numerics\BasicMath;
|
||||
use DNW\Skills\TrueSkill\Factors\GaussianLikelihoodFactor;
|
||||
use DNW\Skills\TrueSkill\TrueSkillFactorGraph;
|
||||
|
||||
class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
|
||||
{
|
||||
@ -51,7 +50,7 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
|
||||
|
||||
return $this->scheduleSequence(
|
||||
array_map(
|
||||
fn($likelihood) => new ScheduleStep('Skill to Perf step', $likelihood, 0),
|
||||
fn ($likelihood) => new ScheduleStep('Skill to Perf step', $likelihood, 0),
|
||||
$localFactors),
|
||||
'All skill to performance sending');
|
||||
}
|
||||
@ -62,7 +61,7 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
|
||||
|
||||
return $this->scheduleSequence(
|
||||
array_map(
|
||||
fn($likelihood) => new ScheduleStep('name', $likelihood, 1),
|
||||
fn ($likelihood) => new ScheduleStep('name', $likelihood, 1),
|
||||
$localFactors),
|
||||
'All skill to performance sending');
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ namespace DNW\Skills\TrueSkill\Layers;
|
||||
|
||||
use DNW\Skills\FactorGraphs\Variable;
|
||||
use DNW\Skills\TrueSkill\Factors\GaussianWeightedSumFactor;
|
||||
use DNW\Skills\TrueSkill\TrueSkillFactorGraph;
|
||||
|
||||
class TeamPerformancesToTeamPerformanceDifferencesLayer extends TrueSkillFactorGraphLayer
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ class TrueSkillFactorGraph extends FactorGraph
|
||||
{
|
||||
$this->_priorLayer = new PlayerPriorValuesToSkillsLayer($this, $teams);
|
||||
$newFactory = new VariableFactory(
|
||||
fn() => GaussianDistribution::fromPrecisionMean(0, 0));
|
||||
fn () => GaussianDistribution::fromPrecisionMean(0, 0));
|
||||
|
||||
$this->setVariableFactory($newFactory);
|
||||
$this->_layers = [
|
||||
|
@ -72,12 +72,12 @@ class TwoTeamTrueSkillCalculator extends SkillCalculator
|
||||
|
||||
$totalPlayers = $selfTeam->count() + $otherTeam->count();
|
||||
|
||||
$meanGetter = fn($currentRating) => $currentRating->getMean();
|
||||
$meanGetter = fn ($currentRating) => $currentRating->getMean();
|
||||
|
||||
$selfMeanSum = BasicMath::sum($selfTeam->getAllRatings(), $meanGetter);
|
||||
$otherTeamMeanSum = BasicMath::sum($otherTeam->getAllRatings(), $meanGetter);
|
||||
|
||||
$varianceGetter = fn($currentRating) => BasicMath::square($currentRating->getStandardDeviation());
|
||||
$varianceGetter = fn ($currentRating) => BasicMath::square($currentRating->getStandardDeviation());
|
||||
|
||||
$c = sqrt(
|
||||
BasicMath::sum($selfTeam->getAllRatings(), $varianceGetter)
|
||||
@ -153,9 +153,9 @@ class TwoTeamTrueSkillCalculator extends SkillCalculator
|
||||
|
||||
$betaSquared = BasicMath::square($gameInfo->getBeta());
|
||||
|
||||
$meanGetter = fn($currentRating) => $currentRating->getMean();
|
||||
$meanGetter = fn ($currentRating) => $currentRating->getMean();
|
||||
|
||||
$varianceGetter = fn($currentRating) => BasicMath::square($currentRating->getStandardDeviation());
|
||||
$varianceGetter = fn ($currentRating) => BasicMath::square($currentRating->getStandardDeviation());
|
||||
|
||||
$team1MeanSum = BasicMath::sum($team1Ratings, $meanGetter);
|
||||
$team1StdDevSquared = BasicMath::sum($team1Ratings, $varianceGetter);
|
||||
|
Reference in New Issue
Block a user