mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-15 17:37:39 +00:00
More warnings resolved.
This commit is contained in:
@ -6,6 +6,11 @@ class FactorGraph
|
||||
{
|
||||
private VariableFactory $variableFactory;
|
||||
|
||||
public function __construct(VariableFactory $factory)
|
||||
{
|
||||
$this->variableFactory = $factory;
|
||||
}
|
||||
|
||||
public function getVariableFactory(): VariableFactory
|
||||
{
|
||||
return $this->variableFactory;
|
||||
|
@ -2,18 +2,20 @@
|
||||
|
||||
namespace DNW\Skills\FactorGraphs;
|
||||
|
||||
use DNW\Skills\Numerics\GaussianDistribution;
|
||||
|
||||
class Message implements \Stringable
|
||||
{
|
||||
public function __construct(private ?object $value = null, private ?string $name = null)
|
||||
public function __construct(private GaussianDistribution $value, private string $name)
|
||||
{
|
||||
}
|
||||
|
||||
public function getValue(): ?object
|
||||
public function getValue(): GaussianDistribution
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue(?object $value): void
|
||||
public function setValue(GaussianDistribution $value): void
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
@ -2,24 +2,26 @@
|
||||
|
||||
namespace DNW\Skills\FactorGraphs;
|
||||
|
||||
use DNW\Skills\Numerics\GaussianDistribution;
|
||||
|
||||
class Variable implements \Stringable
|
||||
{
|
||||
private string $name;
|
||||
|
||||
private mixed $value;
|
||||
|
||||
public function __construct(string $name, private mixed $prior)
|
||||
public function __construct(string $name, private GaussianDistribution $prior)
|
||||
{
|
||||
$this->name = 'Variable[' . $name . ']';
|
||||
$this->resetToPrior();
|
||||
}
|
||||
|
||||
public function getValue(): mixed
|
||||
public function getValue(): GaussianDistribution
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue(mixed $value): void
|
||||
public function setValue(GaussianDistribution $value): void
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
@ -318,11 +318,6 @@ class Matrix
|
||||
|
||||
public function equals(Matrix $otherMatrix): bool
|
||||
{
|
||||
// If one is null, but not both, return false.
|
||||
if ($otherMatrix == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (($this->rowCount != $otherMatrix->getRowCount()) || ($this->columnCount != $otherMatrix->getColumnCount())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -6,11 +6,6 @@ class PartialPlay
|
||||
{
|
||||
public static function getPartialPlayPercentage(Player $player): float
|
||||
{
|
||||
// If the player doesn't support the interface, assume 1.0 == 100%
|
||||
if (! $player instanceof ISupportPartialPlay) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
$partialPlayPercentage = $player->getPartialPlayPercentage();
|
||||
|
||||
// HACK to get around bug near 0
|
||||
|
@ -12,7 +12,7 @@ class RankSorter
|
||||
*
|
||||
* @param array<mixed> $teams The items to sort according to the order specified by ranks.
|
||||
* @param array<int> $teamRanks The ranks for each item where 1 is first place.
|
||||
* @return array<mixed>
|
||||
* @return array<int>
|
||||
*/
|
||||
public static function sort(array &$teams, array &$teamRanks): array
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ use DNW\Skills\Numerics\GaussianDistribution;
|
||||
class GaussianWeightedSumFactor extends GaussianFactor
|
||||
{
|
||||
/**
|
||||
* @var array<float[]> $variableIndexOrdersForWeights
|
||||
* @var array<int[]> $variableIndexOrdersForWeights
|
||||
*/
|
||||
private array $variableIndexOrdersForWeights = [];
|
||||
|
||||
@ -42,8 +42,8 @@ class GaussianWeightedSumFactor extends GaussianFactor
|
||||
|
||||
// The first weights are a straightforward copy
|
||||
// v_0 = a_1*v_1 + a_2*v_2 + ... + a_n * v_n
|
||||
$variableWeightsLength = count((array) $variableWeights);
|
||||
$this->weights[0] = array_fill(0, count((array) $variableWeights), 0);
|
||||
$variableWeightsLength = count($variableWeights);
|
||||
$this->weights[0] = array_fill(0, count($variableWeights), 0);
|
||||
|
||||
for ($i = 0; $i < $variableWeightsLength; $i++) {
|
||||
$weight = &$variableWeights[$i];
|
||||
@ -59,7 +59,7 @@ class GaussianWeightedSumFactor extends GaussianFactor
|
||||
$this->variableIndexOrdersForWeights[0][] = $i;
|
||||
}
|
||||
|
||||
$variableWeightsLength = count((array) $variableWeights);
|
||||
$variableWeightsLength = count($variableWeights);
|
||||
|
||||
// The rest move the variables around and divide out the constant.
|
||||
// For example:
|
||||
@ -111,7 +111,7 @@ class GaussianWeightedSumFactor extends GaussianFactor
|
||||
}
|
||||
$currentWeights[$currentDestinationWeightIndex] = $finalWeight;
|
||||
$currentWeightsSquared[$currentDestinationWeightIndex] = BasicMath::square($finalWeight);
|
||||
$variableIndices[count((array) $variableWeights)] = 0;
|
||||
$variableIndices[count($variableWeights)] = 0;
|
||||
$this->variableIndexOrdersForWeights[] = $variableIndices;
|
||||
|
||||
$this->weights[$weightsIndex] = $currentWeights;
|
||||
|
@ -8,6 +8,7 @@ use DNW\Skills\FactorGraphs\KeyedVariable;
|
||||
use DNW\Skills\Numerics\BasicMath;
|
||||
use DNW\Skills\Rating;
|
||||
use DNW\Skills\Team;
|
||||
use DNW\Skills\Player;
|
||||
use DNW\Skills\TrueSkill\Factors\GaussianPriorFactor;
|
||||
use DNW\Skills\TrueSkill\TrueSkillFactorGraph;
|
||||
use DNW\Skills\FactorGraphs\ScheduleSequence;
|
||||
@ -69,7 +70,7 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
|
||||
);
|
||||
}
|
||||
|
||||
private function createSkillOutputVariable(mixed $key): KeyedVariable
|
||||
private function createSkillOutputVariable(Player $key): KeyedVariable
|
||||
{
|
||||
$parentFactorGraph = $this->getParentFactorGraph();
|
||||
$variableFactory = $parentFactorGraph->getVariableFactory();
|
||||
|
Reference in New Issue
Block a user