mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-15 17:37:39 +00:00
Stringable removed.
This commit is contained in:
@ -13,7 +13,9 @@ namespace DNW\Skills\Numerics;
|
||||
class GaussianDistribution
|
||||
{
|
||||
private const DEFAULT_STANDARD_DEVIATION = 1.0;
|
||||
|
||||
private const DEFAULT_MEAN = 0.0;
|
||||
|
||||
/**
|
||||
* Square Root 2π.
|
||||
* Precalculated constant for performance reasons
|
||||
@ -42,8 +44,7 @@ class GaussianDistribution
|
||||
|
||||
public function __construct(private float $mean = self::DEFAULT_MEAN, private float $standardDeviation = self::DEFAULT_STANDARD_DEVIATION)
|
||||
{
|
||||
if($mean == self::DEFAULT_MEAN && $standardDeviation == self::DEFAULT_STANDARD_DEVIATION)
|
||||
{
|
||||
if ($mean == self::DEFAULT_MEAN && $standardDeviation == self::DEFAULT_STANDARD_DEVIATION) {
|
||||
//Use all the defaults
|
||||
return;
|
||||
}
|
||||
@ -187,7 +188,7 @@ class GaussianDistribution
|
||||
return $multiplier * $expPart;
|
||||
}
|
||||
|
||||
public static function cumulativeTo(float $x, float $mean = 0.0, float $standardDeviation = 1.0): float
|
||||
public static function cumulativeTo(float $x): float
|
||||
{
|
||||
$result = GaussianDistribution::errorFunctionCumulativeTo(-M_SQRT1_2 * $x);
|
||||
|
||||
|
@ -59,9 +59,4 @@ class Player implements ISupportPartialPlay, ISupportPartialUpdate
|
||||
{
|
||||
return $this->PartialUpdatePercentage;
|
||||
}
|
||||
/*
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string)$this->Id;
|
||||
}*/
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ use DNW\Skills\Numerics\GaussianDistribution;
|
||||
/**
|
||||
* Container for a player's rating.
|
||||
*/
|
||||
class Rating implements \Stringable
|
||||
class Rating
|
||||
{
|
||||
private const CONSERVATIVE_STANDARD_DEVIATION_MULTIPLIER = 3;
|
||||
|
||||
@ -73,9 +73,4 @@ class Rating implements \Stringable
|
||||
|
||||
return new Rating($partialPosteriorGaussion->getMean(), $partialPosteriorGaussion->getStandardDeviation(), $prior->conservativeStandardDeviationMultiplier);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return sprintf('mean=%.4f, standardDeviation=%.4f', $this->mean, $this->standardDeviation);
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,6 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
|
||||
$parentFactorGraph = $this->getParentFactorGraph();
|
||||
$variableFactory = $parentFactorGraph->getVariableFactory();
|
||||
|
||||
return $variableFactory->createKeyedVariable($key, (string)$key->getId() . "'s skill");
|
||||
return $variableFactory->createKeyedVariable($key, $key->getId() . "'s skill");
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
|
||||
|
||||
private function createOutputVariable(mixed $key): KeyedVariable
|
||||
{
|
||||
return $this->getParentFactorGraph()->getVariableFactory()->createKeyedVariable($key, (string)$key->getId() . "'s performance");
|
||||
return $this->getParentFactorGraph()->getVariableFactory()->createKeyedVariable($key, $key->getId() . "'s performance");
|
||||
}
|
||||
|
||||
public function createPriorSchedule(): ?ScheduleSequence
|
||||
|
@ -15,7 +15,6 @@ class RatingTest extends TestCase
|
||||
$this->assertEquals(100, $rating->getMean());
|
||||
$this->assertEquals(10, $rating->getStandardDeviation());
|
||||
$this->assertEquals(50, $rating->getConservativeRating());
|
||||
$this->assertEquals("mean=100.0000, standardDeviation=10.0000", (string)$rating);
|
||||
}
|
||||
|
||||
public function testPartialUpdate(): void
|
||||
@ -26,10 +25,8 @@ class RatingTest extends TestCase
|
||||
|
||||
$rating_partial = $rating->getPartialUpdate($ratingOld, $ratingNew, 0.5);
|
||||
|
||||
|
||||
$this->assertEquals(150, $rating_partial->getMean());
|
||||
$this->assertEquals(10, $rating_partial->getStandardDeviation());
|
||||
$this->assertEquals(100, $rating_partial->getConservativeRating());
|
||||
$this->assertEquals("mean=150.0000, standardDeviation=10.0000", (string)$rating_partial);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user