mirror of
				https://github.com/furyfire/trueskill.git
				synced 2025-11-04 02:02:29 +01:00 
			
		
		
		
	More type work.
This commit is contained in:
		@@ -6,10 +6,11 @@ use DNW\Skills\FactorGraphs\ScheduleStep;
 | 
			
		||||
use DNW\Skills\FactorGraphs\ScheduleSequence;
 | 
			
		||||
use DNW\Skills\PartialPlay;
 | 
			
		||||
use DNW\Skills\TrueSkill\Factors\GaussianWeightedSumFactor;
 | 
			
		||||
use DNW\Skills\FactorGraphs\Variable; 
 | 
			
		||||
 | 
			
		||||
class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
{
 | 
			
		||||
    public function buildLayer()
 | 
			
		||||
    public function buildLayer(): void
 | 
			
		||||
    {
 | 
			
		||||
        $inputVariablesGroups = $this->getInputVariablesGroups();
 | 
			
		||||
        foreach ($inputVariablesGroups as $currentTeam) {
 | 
			
		||||
@@ -38,7 +39,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function createPlayerToTeamSumFactor($teamMembers, $sumVariable): GaussianWeightedSumFactor
 | 
			
		||||
    protected function createPlayerToTeamSumFactor(array $teamMembers, Variable $sumVariable): GaussianWeightedSumFactor
 | 
			
		||||
    {
 | 
			
		||||
        $weights = array_map(
 | 
			
		||||
            function ($v) {
 | 
			
		||||
@@ -75,7 +76,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
 | 
			
		||||
        return $this->scheduleSequence($allFactors, "all of the team's sum iterations");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function createOutputVariable($team)
 | 
			
		||||
    private function createOutputVariable(array $team): Variable
 | 
			
		||||
    {
 | 
			
		||||
        $memberNames = array_map(fn ($currentPlayer) => (string) ($currentPlayer->getKey()), $team);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,7 @@ use DNW\Skills\Numerics\BasicMath;
 | 
			
		||||
use DNW\Skills\Rating;
 | 
			
		||||
use DNW\Skills\TrueSkill\Factors\GaussianPriorFactor;
 | 
			
		||||
use DNW\Skills\TrueSkill\TrueSkillFactorGraph;
 | 
			
		||||
use DNW\Skills\FactorGraphs\ScheduleSequence;
 | 
			
		||||
 | 
			
		||||
// We intentionally have no Posterior schedule since the only purpose here is to
 | 
			
		||||
// start the process.
 | 
			
		||||
@@ -19,7 +20,7 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
        parent::__construct($parentGraph);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function buildLayer()
 | 
			
		||||
    public function buildLayer(): void
 | 
			
		||||
    {
 | 
			
		||||
        $teams = $this->teams;
 | 
			
		||||
        foreach ($teams as $currentTeam) {
 | 
			
		||||
@@ -41,7 +42,7 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function createPriorSchedule()
 | 
			
		||||
    public function createPriorSchedule(): ScheduleSequence
 | 
			
		||||
    {
 | 
			
		||||
        $localFactors = $this->getLocalFactors();
 | 
			
		||||
 | 
			
		||||
@@ -54,7 +55,7 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function createPriorFactor(Rating $priorRating, Variable $skillsVariable)
 | 
			
		||||
    private function createPriorFactor(Rating $priorRating, Variable $skillsVariable): GaussianPriorFactor
 | 
			
		||||
    {
 | 
			
		||||
        return new GaussianPriorFactor(
 | 
			
		||||
            $priorRating->getMean(),
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ use DNW\Skills\TrueSkill\Factors\GaussianWeightedSumFactor;
 | 
			
		||||
 | 
			
		||||
class TeamPerformancesToTeamPerformanceDifferencesLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
{
 | 
			
		||||
    public function buildLayer()
 | 
			
		||||
    public function buildLayer(): void
 | 
			
		||||
    {
 | 
			
		||||
        $inputVariablesGroups = $this->getInputVariablesGroups();
 | 
			
		||||
        $inputVariablesGroupsCount = is_countable($inputVariablesGroups) ? count($inputVariablesGroups) : 0;
 | 
			
		||||
@@ -30,14 +30,14 @@ class TeamPerformancesToTeamPerformanceDifferencesLayer extends TrueSkillFactorG
 | 
			
		||||
        Variable $strongerTeam,
 | 
			
		||||
        Variable $weakerTeam,
 | 
			
		||||
        Variable $output
 | 
			
		||||
    ) {
 | 
			
		||||
    ): GaussianWeightedSumFactor {
 | 
			
		||||
        $teams = [$strongerTeam, $weakerTeam];
 | 
			
		||||
        $weights = [1.0, -1.0];
 | 
			
		||||
 | 
			
		||||
        return new GaussianWeightedSumFactor($output, $teams, $weights);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function createOutputVariable()
 | 
			
		||||
    private function createOutputVariable(): Variable
 | 
			
		||||
    {
 | 
			
		||||
        return $this->getParentFactorGraph()->getVariableFactory()->createBasicVariable('Team performance difference');
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user