_teams; foreach ($teams as $currentTeam) { $localCurrentTeam = $currentTeam; $currentTeamSkills = []; $currentTeamAllPlayers = $localCurrentTeam->getAllPlayers(); foreach ($currentTeamAllPlayers as $currentTeamPlayer) { $localCurrentTeamPlayer = $currentTeamPlayer; $currentTeamPlayerRating = $currentTeam->getRating($localCurrentTeamPlayer); $playerSkill = $this->createSkillOutputVariable($localCurrentTeamPlayer); $priorFactor = $this->createPriorFactor($currentTeamPlayerRating, $playerSkill); $this->addLayerFactor($priorFactor); $currentTeamSkills[] = $playerSkill; } $outputVariablesGroups = &$this->getOutputVariablesGroups(); $outputVariablesGroups[] = $currentTeamSkills; } } public function createPriorSchedule() { $localFactors = $this->getLocalFactors(); return $this->scheduleSequence( array_map( fn ($prior) => new ScheduleStep('Prior to Skill Step', $prior, 0), $localFactors ), 'All priors' ); } private function createPriorFactor(Rating $priorRating, Variable $skillsVariable) { return new GaussianPriorFactor( $priorRating->getMean(), BasicMath::square($priorRating->getStandardDeviation()) + BasicMath::square($this->getParentFactorGraph()->getGameInfo()->getDynamicsFactor()), $skillsVariable ); } private function createSkillOutputVariable($key) { $parentFactorGraph = $this->getParentFactorGraph(); $variableFactory = $parentFactorGraph->getVariableFactory(); return $variableFactory->createKeyedVariable($key, $key . "'s skill"); } }