mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-15 17:37:39 +00:00
More types
This commit is contained in:
@ -6,15 +6,14 @@ class Message implements \Stringable
|
||||
{
|
||||
public function __construct(private ?object $value = null, private ?string $name = null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
public function getValue(): ?object
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue($value)
|
||||
public function setValue(?object $value): void
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ namespace DNW\Skills\FactorGraphs;
|
||||
|
||||
class ScheduleLoop extends Schedule
|
||||
{
|
||||
public function __construct($name, private readonly Schedule $scheduleToLoop, private $maxDelta)
|
||||
public function __construct(string $name, private readonly Schedule $scheduleToLoop, private float $maxDelta)
|
||||
{
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ namespace DNW\Skills\FactorGraphs;
|
||||
|
||||
class ScheduleStep extends Schedule
|
||||
{
|
||||
public function __construct(string $name, private readonly Factor $factor, private $index)
|
||||
public function __construct(string $name, private readonly Factor $factor, private int $index)
|
||||
{
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
@ -7,8 +7,14 @@ namespace DNW\Skills;
|
||||
*/
|
||||
class HashMap
|
||||
{
|
||||
/**
|
||||
* @var mixed[] $hashToValue
|
||||
*/
|
||||
private array $hashToValue = [];
|
||||
|
||||
/**
|
||||
* @var mixed[] $hashToKey
|
||||
*/
|
||||
private array $hashToKey = [];
|
||||
|
||||
public function getValue(string|object $key): mixed
|
||||
@ -27,11 +33,17 @@ class HashMap
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getAllKeys(): array
|
||||
{
|
||||
return array_values($this->hashToKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getAllValues(): array
|
||||
{
|
||||
return array_values($this->hashToValue);
|
||||
|
@ -63,18 +63,6 @@ class GaussianDistribution implements \Stringable
|
||||
return 1.0 / (sqrt(2 * M_PI) * $this->standardDeviation);
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$result = new GaussianDistribution();
|
||||
$result->mean = $this->mean;
|
||||
$result->standardDeviation = $this->standardDeviation;
|
||||
$result->variance = $this->variance;
|
||||
$result->precision = $this->precision;
|
||||
$result->precisionMean = $this->precisionMean;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function fromPrecisionMean(float $precisionMean, float $precision): self
|
||||
{
|
||||
$result = new GaussianDistribution();
|
||||
@ -174,7 +162,7 @@ class GaussianDistribution implements \Stringable
|
||||
return 0.5 * $result;
|
||||
}
|
||||
|
||||
private static function errorFunctionCumulativeTo($x): float
|
||||
private static function errorFunctionCumulativeTo(float $x): float
|
||||
{
|
||||
// Derived from page 265 of Numerical Recipes 3rd Edition
|
||||
$z = abs($x);
|
||||
|
@ -53,7 +53,7 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
|
||||
}
|
||||
|
||||
// When dealing with differences, there are always (n-1) differences, so add in the 1
|
||||
$totalTeamDifferences = is_countable($this->TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors()) ? count($this->TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors()) : 0;
|
||||
$totalTeamDifferences = count($this->TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors());
|
||||
|
||||
$localFactors = $this->TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors();
|
||||
|
||||
|
Reference in New Issue
Block a user