0

让我们想象一下有 8 名球员参加沙滩排球比赛。比赛以 2 对 2 进行。

作为组织者,我想为具有以下规则的玩家生成时间表:

  • 每个玩家与每个人一起玩(每个玩家7场比赛)
  • 每个玩家与每个玩家交手两次

因此,时间表将开始,例如:

round 1 
player1 + player2 vs player3 + player4
player5 + player6 vs player7 + player8

round2
player1 + player3 vs player2 + player5
player4 + player7 vs player6 + player8

round3
player1 + player4 vs player2 + player3
player5 + player8 vs player6 + player7

etc

通过上面的示例,让我们考虑 player1。他一直和球员(2,3,4)一起比赛,所以他还和球员(5,6,7,8)一起比赛

他一直在对抗:

Player3 (twice)
Player4
Player2 (twice)
Player5

所以剩下的 4 场比赛(球员 1)应该和球员 5,6,7,8 一起比赛,对手不能是球员 3 或球员 2(因为你已经和他们打过两次了)

我在这里看到了很好的例子如何自动生成体育联赛时间表和关于循环赛的维基百科文章https://en.wikipedia.org/wiki/Round-robin_tournament(Richard Schurig (1886) 的配对表的原始构造)有效生成比赛很好,但是与某些球员的比赛将超过两场。

我真的很感激任何帮助!

4

1 回答 1

5

Yes, this can be accomplished with the help of the finite field F8. We identify each player with one of the elements of F8. Let t and p be any distinct nonzero elements of F8. In round r for r in F8 ∖ {0} (seven elements), player x has x + r t as a teammate and x + r p and x + r p + r t as opponents.

Since x + r t + r t = x and x + r p + r t + r t = x + r p in a field of characteristic 2, each player in each round has exactly one teammate, and their two opponents are teammates. For a pair of players x and y, the round in which they are teammates is uniquely determined because the equation x + r t = y (equivalent to x = y + r t) has exactly one solution. Similar reasoning demonstrates why each player opposes each other player in exactly two rounds.

F8 = {
    (0, 0, 0): "a",
    (1, 0, 0): "b",
    (0, 1, 0): "c",
    (1, 1, 0): "d",
    (0, 0, 1): "e",
    (1, 0, 1): "f",
    (0, 1, 1): "g",
    (1, 1, 1): "h",
}


def f8_times(p, q):
    pq = (
        p[0] & q[0],
        (p[0] & q[1]) ^ (p[1] & q[0]),
        (p[0] & q[2]) ^ (p[1] & q[1]) ^ (p[2] & q[0]),
        (p[1] & q[2]) ^ (p[2] & q[1]),
        p[2] & q[2],
    )
    return (pq[0] ^ pq[3], pq[1] ^ pq[3] ^ pq[4], pq[2] ^ pq[4])


for a in F8:
    if any(a):
        print("{}{} vs {}{}; {}{} vs {}{}".format(*(F8[f8_times(a, b)] for b in F8)))

Output:

ab vs cd; ef vs gh
ac vs eg; db vs hf
ad vs gf; he vs bc
ae vs dh; gc vs fb
af vs be; ch vs dg
ag vs hb; fd vs ce
ah vs fc; bg vs ed
于 2021-09-29T23:03:48.457 回答