_teams = $teams; } public function buildLayer() { $teams = $this->_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($localCurrentTeamPlayer, $currentTeamPlayerRating, $playerSkill); $this->addLayerFactor($priorFactor); $currentTeamSkills[] = $playerSkill; } $outputVariablesGroups = &$this->getOutputVariablesGroups(); $outputVariablesGroups[] = $currentTeamSkills; } } public function createPriorSchedule() { $localFactors = $this->getLocalFactors(); return $this->scheduleSequence( array_map( function ($prior) { return new ScheduleStep('Prior to Skill Step', $prior, 0); }, $localFactors), 'All priors'); } private function createPriorFactor($player, 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(); $skillOutputVariable = $variableFactory->createKeyedVariable($key, $key."'s skill"); return $skillOutputVariable; } }