示例#1
0
文件: mslgroup.py 项目: alendit/simul
    def setup(self):
        self._first = [Match(self._num), Match(self._num)]
        self._second = [Match(self._num), Match(self._num)]
        self._final = Match(self._num)

        self._matches = self._first + self._second + [self._final]

        self._first[0].add_winner_link(self._second[0], 0)
        self._first[0].add_loser_link(self._second[1], 0)
        self._first[0].add_parent(self)
        self._first[1].add_winner_link(self._second[0], 1)
        self._first[1].add_loser_link(self._second[1], 1)
        self._first[1].add_parent(self)
        self._second[0].add_loser_link(self._final, 0)
        self._second[0].add_parent(self)
        self._second[1].add_winner_link(self._final, 1)
        self._second[1].add_parent(self)
        self._final.add_parent(self)
示例#2
0
文件: rrgroup.py 项目: alendit/simul
    def setup(self):
        nmatches = len(self._schema_out) * (len(self._schema_out) - 1) // 2
        self._matches = []

        for r in range(0, nmatches):
            m = Match(self._num)
            self._matches.append(m)

            m.add_parent(self)
示例#3
0
    def setup(self):
        self._matches = dict()
        self._bracket = []

        prev_round = None
        this_round = []

        for r in range(0, len(self._num)):
            for i in range(0, 2**(len(self._num) - 1 - r)):
                m = Match(self._num[r])
                this_round.append(m)

                m.add_parent(self)
                if prev_round != None:
                    prev_round[2 * i].add_winner_link(m, 0)
                    prev_round[2 * i + 1].add_winner_link(m, 1)

            self._matches['Round ' + str(r + 1)] = this_round
            self._bracket.append(this_round)
            prev_round = this_round
            this_round = []
示例#4
0
    def setup(self):
        self._matches = dict()
        self._winners = []
        self._losers = []
        self._final = []

        prev_round = None
        L = 32
        for r in range(0, 7):
            rnd = []
            for i in range(0, L):
                m = Match(self._num)
                rnd.append(m)

                m.add_parent(self)
                if prev_round != None and r != 3:
                    prev_round[2 * i].add_winner_link(m, 0)
                    prev_round[2 * i + 1].add_winner_link(m, 1)
                elif prev_round != None and r == 3:
                    prev_round[i].add_winner_link(m, 1)

            self._matches['Winner Round ' + str(r + 1)] = rnd
            self._winners.append(rnd)
            prev_round = rnd

            if r != 2:
                L = L // 2

        prev_round = None
        L = 16
        fill_rounds = [1, 3, 4, 6, 8, 10, -1]
        fill_ind = 0
        pm = [[24,26,28,30,16,18,20,22,8,10,12,14,0,2,4,6],\
              [4,5,6,7,0,1,2,3,12,13,14,15,8,9,10,11], [5,4,7,6,1,0,3,2],\
              [0,1,2,3,4,5,6,7], [3,2,1,0], [0,1], [0]]
        for r in range(0, 11):
            rnd = []
            for i in range(0, L):
                m = Match(self._num)
                rnd.append(m)

                m.add_parent(self)
                if r == 0:
                    self._winners[0][pm[0][i]].add_loser_link(m, 0)
                    self._winners[0][pm[0][i] + 1].add_loser_link(m, 1)
                elif r == fill_rounds[fill_ind]:
                    self._winners[fill_ind + 1][pm[fill_ind +
                                                   1][i]].add_loser_link(m, 0)
                    prev_round[i].add_winner_link(m, 1)
                else:
                    prev_round[2 * i].add_winner_link(m, 0)
                    prev_round[2 * i + 1].add_winner_link(m, 1)

            if r == fill_rounds[fill_ind]:
                fill_ind += 1

            self._matches['Loser Round ' + str(r + 1)] = rnd
            self._losers.append(rnd)
            prev_round = rnd

            if r in [1, 4, 6, 8, 10]:
                L = L // 2

        f1 = Match(self._num)
        f2 = Match(self._num)
        self._winners[-1][0].add_winner_link(f1, 0)
        self._winners[-1][0].add_winner_link(f2, 0)
        self._losers[-1][0].add_winner_link(f1, 1)
        self._losers[-1][0].add_winner_link(f2, 1)

        self._final.append(f1)
        self._final.append(f2)
示例#5
0
    def setup(self):
        self._matches = dict()
        self._winners = []
        self._losers = []
        self._final = []

        prev_round = None
        L = 2**(self._rounds - 1)
        for r in range(0, self._rounds):
            rnd = []
            for i in range(0, L):
                m = Match(self._num)
                rnd.append(m)

                m.add_parent(self)
                if prev_round != None:
                    prev_round[2 * i].add_winner_link(m, 0)
                    prev_round[2 * i + 1].add_winner_link(m, 1)

            self._matches['Winner Round ' + str(r + 1)] = rnd
            self._winners.append(rnd)
            prev_round = rnd

            L = L // 2

        prev_round = None
        L = 2**(self._rounds - 2)
        for r in range(0, 2 * (self._rounds - 1)):
            rnd = []
            for i in range(0, L):
                m = Match(self._num)
                rnd.append(m)

                m.add_parent(self)
                if r == 0:
                    self._winners[0][2 * i].add_loser_link(m, 0)
                    self._winners[0][2 * i + 1].add_loser_link(m, 1)
                elif r % 2 == 1:
                    par = i if (i % 4 == 3) else L - i - 1
                    self._winners[(r + 1) // 2][par].add_loser_link(m, 0)
                    prev_round[i].add_winner_link(m, 1)
                else:
                    prev_round[2 * i].add_winner_link(m, 0)
                    prev_round[2 * i + 1].add_winner_link(m, 1)

            self._matches['Loser Round ' + str(r + 1)] = rnd
            self._losers.append(rnd)
            prev_round = rnd

            if r % 2 == 1:
                L = L // 2

        f1 = Match(self._num)
        f2 = Match(self._num)
        self._winners[-1][0].add_winner_link(f1, 0)
        self._winners[-1][0].add_winner_link(f2, 0)
        self._losers[-1][0].add_winner_link(f1, 1)
        self._losers[-1][0].add_winner_link(f2, 1)

        self._final.append(f1)
        self._final.append(f2)