没有循环赛的联赛调度



目前我正在寻找一个特定于我的问题的术语:

我创建了一个有4支球队的联赛联赛持续3轮(为了简单起见,使用数字)比赛将从尚未对战过的队伍中随机分配。

我正在努力让我当前的代码与每个边缘情况下运行,所以我想查找为这种情况开发的"标准"算法,但我不能想出我正在寻找的术语。

一个时间表示例是:

TeamA: C,E,B
TeamB: F,H,A
TeamC: A,D,H
TeamD: G,C,F
TeamE: H,A,G
TeamF: B,G,D
TeamG: D,F,G
TeamH: E,B,C

我找不到任何关于这方面的东西,因为它似乎是一个非常,非常不可能在联赛/比赛中使用的东西-然而这是我的要求。

这是我当前创建ONE Round的代码。有可能,这段代码不会在第3轮给每个队伍一个对手,因为他们可能的对手在这一轮已经分配了一个对手(测试了6支队伍,可能发生在第3轮)

 public function CalculateDivision()
{
     $teams = Division::find(1)->teams()->get();
     $diffs = array();
     foreach($teams as $team)
     {
//Get possible Opponents
         $opp = Division::find(1)->teams()->where('id','!=',$team->id)->lists('id');
         $matches = $team->matches()->get();
         $plyd = array();
         foreach($matches as $match)
         {   
//Find Opponents a team already has played against
             $plyd[] = $match->teams()->where('id','!=',$team->id)->pluck('id');    
         }
//Substract Opponents already played against from possible Opponents
         $TBP = array_diff($opp,$plyd);
         $diffs[$team->id] = $TBP;
     }
//Order By Least possible Opponents possible
     asort($diffs);
     $this->CalculateMatches($diffs);
}
private function CalculateMatches($teams)
{
//$teams equals $teams[teamID] = [Opponent1ID,Opponent2ID ...]
    $setTeams = array();
    foreach($teams as $key => $team)
    {
//If Team hasn't already a new matchup find opponent from their possible opponent array
        if(!in_array($key,$setTeams))
        {
           shuffle($team);
           foreach($team as $opponent)
           {
//If possible opponent hasn't already a matchup create one, add both teams to 'has already a match' so the loop doesn't evaluate them again
               if(!in_array($opponent,$setTeams))
               {
                   $this->CreateMatch($key,$opponent);
                   $setTeams[] = $key;
                   $setTeams[] = $opponent;
                   break;    
               }
           }
        }
    }
}

任何帮助我将谷歌将不胜感激

瑞士赛制"是一种非淘汰制的比赛形式,其特点是预先确定了比赛的轮数,但比循环赛少得多

在国际象棋和其他游戏中广泛使用。根据维基百科:

瑞士系统通常用于国际象棋,桥牌,电子竞技,Morabaraba, Scrabble, Backgammon,壁球,psamtanque (boules), Quiz bowl, Magic: The Gathering,政策辩论,战锤,八球,Reversi, Dominion, poksammon TCG,游戏王,血碗,激战2,星球大战:x翼微型游戏,流放之路和Android: Netrunner。

它可能符合您的需要,您可以找到一些现成的实现。

最新更新