mirror of
				https://github.com/furyfire/trueskill.git
				synced 2025-11-04 10:12:28 +01:00 
			
		
		
		
	First time of no blatant syntax errors
This commit is contained in:
		@@ -47,16 +47,17 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
        $totalTeamDifferences = count($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors());
 | 
			
		||||
        $totalTeams = $totalTeamDifferences + 1;
 | 
			
		||||
 | 
			
		||||
        $localFactors = $this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors();
 | 
			
		||||
        $innerSchedule = new ScheduleSequence(
 | 
			
		||||
            "inner schedule",
 | 
			
		||||
            array(
 | 
			
		||||
                    $loop,
 | 
			
		||||
                    new ScheduleStep(
 | 
			
		||||
                        "teamPerformanceToPerformanceDifferenceFactors[0] @ 1",
 | 
			
		||||
                        ($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors())[0], 1),
 | 
			
		||||
                        $localFactors[0], 1),
 | 
			
		||||
                    new ScheduleStep(
 | 
			
		||||
                        "teamPerformanceToPerformanceDifferenceFactors[teamTeamDifferences = {0} - 1] @ 2",                                      
 | 
			
		||||
                        ($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors())[$totalTeamDifferences - 1], 2)
 | 
			
		||||
                        $localFactors[$totalTeamDifferences - 1], 2)
 | 
			
		||||
                )
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
@@ -65,15 +66,18 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
 | 
			
		||||
    private function createTwoTeamInnerPriorLoopSchedule()
 | 
			
		||||
    {
 | 
			
		||||
        $teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors = $this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors();
 | 
			
		||||
        $teamDifferencesComparisonLayerLocalFactors = $this->_TeamDifferencesComparisonLayer->getLocalFactors();
 | 
			
		||||
 | 
			
		||||
        return $this->scheduleSequence(
 | 
			
		||||
            array(
 | 
			
		||||
                    new ScheduleStep(
 | 
			
		||||
                        "send team perf to perf differences",
 | 
			
		||||
                        ($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors())[0],
 | 
			
		||||
                        $teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors[0],
 | 
			
		||||
                        0),
 | 
			
		||||
                    new ScheduleStep(
 | 
			
		||||
                        "send to greater than or within factor",
 | 
			
		||||
                        ($this->_TeamDifferencesComparisonLayer->getLocalFactors())[0],
 | 
			
		||||
                        $teamDifferencesComparisonLayerLocalFactors[0],
 | 
			
		||||
                        0)
 | 
			
		||||
                ),
 | 
			
		||||
            "loop of just two teams inner sequence");
 | 
			
		||||
@@ -87,19 +91,22 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
 | 
			
		||||
        for ($i = 0; $i < $totalTeamDifferences - 1; $i++)
 | 
			
		||||
        {
 | 
			
		||||
            $teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors = $this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors();
 | 
			
		||||
            $teamDifferencesComparisonLayerLocalFactors = $this->_TeamDifferencesComparisonLayer->getLocalFactors();
 | 
			
		||||
 | 
			
		||||
            $currentForwardSchedulePiece =
 | 
			
		||||
                $this->scheduleSequence(
 | 
			
		||||
                    array(
 | 
			
		||||
                            new ScheduleStep(
 | 
			
		||||
                                sprintf("team perf to perf diff %d", $i),
 | 
			
		||||
                                ($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors())[$i], 0),
 | 
			
		||||
                                $teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors[$i], 0),
 | 
			
		||||
                            new ScheduleStep(
 | 
			
		||||
                                sprintf("greater than or within result factor %d", $i),
 | 
			
		||||
                                ($this->_TeamDifferencesComparisonLayer->getLocalFactors())[$i], 0),
 | 
			
		||||
                                $teamDifferencesComparisonLayerLocalFactors[$i], 0),
 | 
			
		||||
                            new ScheduleStep(
 | 
			
		||||
                                sprintf("team perf to perf diff factors [%d], 2", $i),
 | 
			
		||||
                                ($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors())[$i], 2)
 | 
			
		||||
                        ), sprintf("current forward schedule piece %d", $i);
 | 
			
		||||
                                $teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors[$i], 2)
 | 
			
		||||
                        ), sprintf("current forward schedule piece %d", $i));
 | 
			
		||||
 | 
			
		||||
            $forwardScheduleList[] = $currentForwardSchedulePiece;
 | 
			
		||||
        }
 | 
			
		||||
@@ -110,19 +117,22 @@ class IteratedTeamDifferencesInnerLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
 | 
			
		||||
        for ($i = 0; $i < $totalTeamDifferences - 1; $i++)
 | 
			
		||||
        {
 | 
			
		||||
            $teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors = $this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors();
 | 
			
		||||
            $teamDifferencesComparisonLayerLocalFactors = $this->_TeamDifferencesComparisonLayer->getLocalFactors();
 | 
			
		||||
 | 
			
		||||
            $currentBackwardSchedulePiece = new ScheduleSequence(
 | 
			
		||||
                "current backward schedule piece",
 | 
			
		||||
                array(
 | 
			
		||||
                        new ScheduleStep(
 | 
			
		||||
                            sprintf("teamPerformanceToPerformanceDifferenceFactors[totalTeamDifferences - 1 - %d] @ 0", $i),
 | 
			
		||||
                            ($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors())[$totalTeamDifferences - 1 - $i], 0),
 | 
			
		||||
                            $teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors[$totalTeamDifferences - 1 - $i], 0),
 | 
			
		||||
                        new ScheduleStep(
 | 
			
		||||
                            sprintf("greaterThanOrWithinResultFactors[totalTeamDifferences - 1 - %d] @ 0", $i),
 | 
			
		||||
                            ($this->_TeamDifferencesComparisonLayer->getLocalFactors())[$totalTeamDifferences - 1 - $i], 0),
 | 
			
		||||
                            $teamDifferencesComparisonLayerLocalFactors[$totalTeamDifferences - 1 - $i], 0),
 | 
			
		||||
                        new ScheduleStep(
 | 
			
		||||
                            sprintf("teamPerformanceToPerformanceDifferenceFactors[totalTeamDifferences - 1 - %d] @ 1", $i),
 | 
			
		||||
                            ($this->_TeamPerformancesToTeamPerformanceDifferencesLayer->getLocalFactors())[$totalTeamDifferences - 1 - $i], 1)
 | 
			
		||||
                );
 | 
			
		||||
                            $teamPerformancesToTeamPerformanceDifferencesLayerLocalFactors[$totalTeamDifferences - 1 - $i], 1)
 | 
			
		||||
                ));
 | 
			
		||||
            $backwardScheduleList[] = $currentBackwardSchedulePiece;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -50,21 +50,24 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
 | 
			
		||||
    public function createPosteriorSchedule()
 | 
			
		||||
    {
 | 
			
		||||
        // BLOG
 | 
			
		||||
        return $this->scheduleSequence(
 | 
			
		||||
                from currentFactor in LocalFactors
 | 
			
		||||
                                from currentIteration in
 | 
			
		||||
                                    Enumerable.Range(1, currentFactor.NumberOfMessages - 1)
 | 
			
		||||
                                select new ScheduleStep<GaussianDistribution>(
 | 
			
		||||
                                    "team sum perf @" + currentIteration,
 | 
			
		||||
                                    currentFactor,
 | 
			
		||||
                                    currentIteration),
 | 
			
		||||
                                "all of the team's sum iterations");
 | 
			
		||||
        $allFactors = array();
 | 
			
		||||
        foreach($this->getLocalFactors() as $currentFactor)
 | 
			
		||||
        {
 | 
			
		||||
            $numberOfMessages = $currentFactor->getNumberOfMessages();
 | 
			
		||||
            for($currentIteration = 1; $currentIteration < $numberOfMessages; $currentIteration++)
 | 
			
		||||
            {
 | 
			
		||||
                $allFactors[] = new ScheduleStep("team sum perf @" + $currentIteration,
 | 
			
		||||
                                                 $currentFactor, $currentIteration);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return $this->scheduleSequence($allFactors, "all of the team's sum iterations");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function createOutputVariable($team)
 | 
			
		||||
    {
 | 
			
		||||
        $teamMemberNames = String.Join(", ", team.Select(teamMember => teamMember.Key.ToString()).ToArray());
 | 
			
		||||
        return ParentFactorGraph.VariableFactory.CreateBasicVariable("Team[{0}]'s performance", teamMemberNames);
 | 
			
		||||
        ///$teamMemberNames = String.Join(", ", team.Select(teamMember => teamMember.Key.ToString()).ToArray());
 | 
			
		||||
        $teamMemberNames = "TODO";
 | 
			
		||||
        return $this->getParentFactorGraph()->getVariableFactory()->createBasicVariable("Team[{0}]'s performance", $teamMemberNames);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -21,8 +21,9 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
 | 
			
		||||
                $this->addLayerFactor($this->createLikelihood($playerSkillVariable, $playerPerformance));
 | 
			
		||||
                $currentTeamPlayerPerformances[] = $playerPerformance;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $this->getOutputVariablesGroups()[] = $currentTeamPlayerPerformances;
 | 
			
		||||
            
 | 
			
		||||
            $outputVariablesGroups = $this->getOutputVariablesGroups();
 | 
			
		||||
            $outputVariablesGroups[] = $currentTeamPlayerPerformances;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,8 @@ class TeamPerformancesToTeamPerformanceDifferencesLayer extends TrueSkillFactorG
 | 
			
		||||
            $this->addLayerFactor($this->createTeamPerformanceToDifferenceFactor($strongerTeam, $weakerTeam, currentDifference));
 | 
			
		||||
 | 
			
		||||
            // REVIEW: Does it make sense to have groups of one?
 | 
			
		||||
            $this->getOutputVariablesGroups()[] = $currentDifference;
 | 
			
		||||
            $outputVariablesGroup = $this->getOutputVariablesGroups();
 | 
			
		||||
            $outputVariablesGroup[] = $currentDifference;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user