teams; foreach ($teams as $currentTeam) { $localCurrentTeam = $currentTeam; $currentTeamSkills = []; $curTeamAllPlayers = $localCurrentTeam->getAllPlayers(); foreach ($curTeamAllPlayers as $curTeamPlayer) { $localCurTeamPlayer = $curTeamPlayer; $curTeamPlayerRating = $currentTeam->getRating($localCurTeamPlayer); $playerSkill = $this->createSkillOutputVariable($localCurTeamPlayer); $priorFactor = $this->createPriorFactor($curTeamPlayerRating, $playerSkill); $this->addLayerFactor($priorFactor); $currentTeamSkills[] = $playerSkill; } $outputVariablesGroups = &$this->getOutputVariablesGroups(); $outputVariablesGroups[] = $currentTeamSkills; } } #[\Override] public function createPriorSchedule(): ScheduleSequence { $localFactors = $this->getLocalFactors(); //All priors return $this->scheduleSequence( array_map( //Prior to Skill Step static fn($prior): ScheduleStep => new ScheduleStep($prior, 0), $localFactors ) ); } private function createPriorFactor(Rating $priorRating, Variable $skillsVariable): GaussianPriorFactor { return new GaussianPriorFactor( $priorRating->getMean(), BasicMath::square($priorRating->getStandardDeviation()) + BasicMath::square($this->getParentFactorGraph()->getGameInfo()->getDynamicsFactor()), $skillsVariable ); } private function createSkillOutputVariable(Player $key): KeyedVariable { $parentFactorGraph = $this->getParentFactorGraph(); $variableFactory = $parentFactorGraph->getVariableFactory(); return $variableFactory->createKeyedVariable($key); } }