def run_round(self, round_number):
        round = Round(str(round_number))
        self.tournament.add_round(round)
        players = self.get_player()

        i = 0

        while len(players) > 0:
            player1 = players[i]
            player2 = players[i + 1]

            while player2.elo in player1.opponent:
                try:
                    i += 1
                    player2 = players[i + 1]
                except IndexError:
                    player2 = players[1]
                    i = 0
                    break

            round.add_match(player1, player2)
            del players[0]
            del players[i]

            i = 0

        for match in self.tournament.rounds[round_number - 1].matchs:
            match.score_player1, match.score_player2 = self.handle_score()
            print_match_result(match)
            self.update_player_score(match)
        print_final_round_score(
            self.tournament.rounds[round_number - 1].matchs, round.number)
    def run_first_round(self):
        # algorithme pour créer les premiers rounds

        match_number = 1

        start_time = set_round_time()
        end_time = None
        round1 = Round("1", start_time, end_time)
        self.tournament.add_round(round1)

        player_for_round = self.get_players()
        print_player(player_for_round)

        for i in range(4):
            round1.add_match(player_for_round[i], player_for_round[i + 4])

        for match in round1.matches:
            match.player1.opponent.append(match.player2.elo)
            match.player2.opponent.append(match.player1.elo)

        for match in self.tournament.rounds[0].matches:
            print_text(f"\nROUND #1 - MATCH #{match_number}")
            print_match(match)
            match.score_player1, match.score_player2 = self.handle_score()
            print_text(f"\nRÉSULTAT DU MATCH #{match_number}")
            match_number += 1
            print_match_result(match)
            self.update_tournament_score(match)
        self.tournament.players.sort(key=lambda x: x.elo, reverse=True)
        self.tournament.players.sort(key=lambda x: x.score, reverse=True)
        print_final_score(self.tournament.players, round1.round_number)
        round1.end_time = set_round_time()
Exemple #3
0
def round_deserializer(reloaded_round):
    reload_round = Round(reloaded_round["round_number"],
                         reloaded_round["start_time"],
                         reloaded_round["end_time"])
    for match in reloaded_round["matches"]:
        player1 = player_deserializer(match["player1"])
        player2 = player_deserializer(match["player2"])
        reload_match = Match(player1, player2)
        reload_match.score_player1 = match["score_player1"]
        reload_match.score_player2 = match["score_player2"]
        reload_round.add_reload_match(reload_match)
    return reload_round
Exemple #4
0
    def deserializer(name):
        db = TinyDB("db_tournament.json", indent=4)
        tournaments = db.table("Tournaments")
        tournament = Query()

        tournament = tournaments.search(tournament.name == name)[0]
        reload_tournament = Tournament(
            tournament["name"],
            tournament["time control"],
            tournament["place"],
            tournament["date"],
            tournament["description"],
        )

        for player in tournament["players"]:
            reload_player = Player(
                player["first name"],
                player["last name"],
                player["elo"],
                player["date of birth"],
                player["player's gender"],
                player["score"],
                player["opponent list"],
            )
            reload_tournament.add_player(reload_player)

        for round in tournament["rounds"]:
            reload_round = Round(round["number"])
            for match in round["matchs"]:
                player1 = Player(
                    match["player1"]["first name"],
                    match["player1"]["last name"],
                    match["player1"]["elo"],
                    match["player1"]["date of birth"],
                    match["player1"]["player's gender"],
                    match["player1"]["score"],
                    match["player1"]["opponent list"],
                )
                player2 = Player(
                    match["player2"]["first name"],
                    match["player2"]["last name"],
                    match["player2"]["elo"],
                    match["player2"]["date of birth"],
                    match["player2"]["player's gender"],
                    match["player2"]["score"],
                    match["player2"]["opponent list"],
                )
                reload_match = Match(player1, player2, match["score player 1"],
                                     match["Score player 2"])
                reload_round.add_reload_match(reload_match)
            reload_tournament.add_round(reload_round)
        return reload_tournament
Exemple #5
0
def make_a_round(ronde_dict, tournament_id):
    """
    :param ronde_dict: dictionary, with your round caract
    :param tournament_id: interger, identity of your tournament
    :return: round instance
    """

    rond = Round(tournament_id=tournament_id,
                 name=ronde_dict["name"],
                 starting_date=ronde_dict["starting_date"],
                 ending_date=ronde_dict["ending_date"])
    rond.edit_matches(ronde_dict["matches"])
    return rond
    def create_first_round(self):
        new_round = Round.create_round()
        serialized_round = vars(new_round)
        new_matchs_id = []
        self.round_table.insert(serialized_round)
        list_of_players_by_ranking = self.list_of_players_by_ranking()
        Play = Query()
        for i in range(4):
            new_match = Match.create_match(
                self.player_table.get(
                    Play.ranking == list_of_players_by_ranking[0][i]["ranking"]
                ).doc_id,
                self.player_table.get(
                    Play.ranking == list_of_players_by_ranking[1][i]["ranking"]
                ).doc_id,
            )
            serialized_match = vars(new_match)
            self.match_table.insert(serialized_match)
            new_matchs_id.append(self.match_table.all()[-1].doc_id)
        list_of_rounds = self.tournament_table.all()[-1]["rounds"]
        list_of_rounds.append(self.round_table.all()[-1].doc_id)
        self.round_table.update(
            {"list_of_match": new_matchs_id},
            doc_ids=[self.round_table.all()[-1].doc_id],
        )
        self.tournament_table.update(
            {"rounds": list_of_rounds},
            doc_ids=[self.tournament_table.all()[-1].doc_id],
        )
        self.warning.round_create(str(self.round_table.all()[-1]["current_round"]))
        self.table.matchs()

        return self.manage_tournament()
    def run_first_round(self):
        # algorithme pour créer les premier round
        self.tournament.players.sort(
            key=lambda x: x.elo)  # trier les joueurs par elo
        round1 = Round("1")  # nom du first round
        self.tournament.add_round(round1)  # ajoute le round à la liste
        for i in range(4):
            round1.add_match(self.tournament.players[i],
                             self.tournament.players[
                                 4 + i])  # 1er du haut du tableau contre 5ème

        for match in self.tournament.rounds[0].matchs:  # matching de joueurs
            match.score_player1, match.score_player2 = self.handle_score()
            print_match_result(match)
            self.update_player_score(match)
        print_final_round_score(self.tournament.rounds[0].matchs,
                                round1.number)
Exemple #8
0
def round_building(first):
    """
    draft the matchmaking according to the number of round in the current tournamenet
    :param first: boolean
    :return: none
    """
    sorted_players = get_players_id(sort_players())
    current_round = Round(current_tournament.identity)
    current_round.edit_sorted_players(sorted_players)
    current_round.edit_starting_date(what_date_is_it())
    if first:
        current_round.first_matchmaking()
    else:
        current_round.edit_matches(other_matchmaking(sorted_players))
    current_tournament.add_a_round(current_round)
    nb = len(current_tournament.rounds)
    current_tournament.rounds[-1].edit_name(f"round {nb}")
    def run_round(self, round_number):
        match_number = 1

        start_time = set_round_time()
        end_time = None
        round = Round(str(round_number), start_time, end_time)
        self.tournament.add_round(round)

        player_for_round = self.get_players()
        print_player(player_for_round)

        index_player = 0

        while len(player_for_round) != 0:
            player1 = player_for_round[index_player]
            player1_index = index_player
            player2 = player_for_round[index_player + 1]
            player2_index = index_player + 1

            while player2.elo in player1.opponent:
                index_player += 1
                player2 = player_for_round[index_player + 1]
                player2_index = index_player + 1
            round.add_match(player1, player2)
            del player_for_round[player1_index]
            del player_for_round[player2_index - 1]
            index_player = 0

        for match in round.matches:
            match.player1.opponent.append(match.player2.elo)
            match.player2.opponent.append(match.player1.elo)

        for i in range(1, 2):
            for match in self.tournament.rounds[round_number - 1].matches:
                print_text(f"\nROUND #{round_number} - MATCH #{match_number}")
                print_match(match)
                match.score_player1, match.score_player2 = self.handle_score()
                print_text(f"\nRÉSULTAT DU MATCH #{match_number}")
                match_number += 1
                print_match_result(match)
                self.update_tournament_score(match)
        self.tournament.players.sort(key=lambda x: x.elo, reverse=True)
        self.tournament.players.sort(key=lambda x: x.score, reverse=True)
        print_final_score(self.tournament.players, round.round_number)
        round.end_time = set_round_time()
    def instanciation_rounds(self):
        """ Fonction qui instancie les rounds du tournoi à partir du .json """
        for serialized_round in self.tournament_progress.serialized_rounds:

            r = Round(
                serialized_round["Name"],
                serialized_round["Date"],
                serialized_round["Round start-time"],
                [],
            )

            self.tournament_progress.add_round(r)
    def run_first_round(self, tournament_table, actors_db):
        """ Fonction qui fait tourner le premier round """
        round_name = "Round 1"
        round_date = str(vr.get_round_date())
        round_starttime = str(vr.get_round_starttime())
        round1 = Round(round_name, round_date, round_starttime)
        serialized_round1 = round1.serialize()

        self.tournament_progress.serialized_rounds.append(serialized_round1)
        self.tournament_progress.serialized_rounds = (
            self.tournament_progress.serialized_rounds)
        vt.print_info(
            f"{self.tournament_progress.name} begins !\n--------------------------------------\n"
        )
        vt.print_info(f"{round_name} launchment...")

        self.tournament_progress.players.sort(key=lambda x: x.elo)
        for i in range(4):
            round1.add_match(
                self.tournament_progress.players[i],
                self.tournament_progress.players[4 + i],
            )
        self.tournament_progress.add_round(round1)

        i = 0
        for match in self.tournament_progress.rounds[0].matchs:
            vt.print_info("\n...\n")
            vt.print_info(
                f"{match.player1.name} and {match.player2.name} play against each other !"
            )
            match.score1, match.score2 = self.handle_score(match)
            i += 1

            vr.print_match_result(match)

            serialized_match = match.serialize()
            round1.serialized_matchs.append(serialized_match)

            match.player1.add_opponent(match.player2)
            match.player2.add_opponent(match.player1)
            match.player1.add_score(match.score1)
            match.player2.add_score(match.score2)

            tournament_table.truncate()
            tournament_table.insert(
                self.tournament_progress.serialized_tournament)

        round1.endtime = str(vr.get_round_endtime())
        serialized_round1 = {
            "Round end-time": round1.endtime,
            "Round Matchs": round1.serialized_matchs,
        }
        self.tournament_progress.serialized_tournament = (
            self.tournament_progress.serialize())
        tournament_table.truncate()
        tournament_table.insert(self.tournament_progress.serialized_tournament)

        vt.print_info(f"End of the Round1 at {round1.endtime}.")
        vt.print_info("\n--------------------------------------\n")
Exemple #12
0
	def post(self, user_id):
		args = tournamentParser.parse_args()
		tournamentName = args['tournamentName']
		isSchool = args['isSchool']
		school = args['school']
		descriptions = args['descriptions']
		entryFee = args['entryFee']
		size = args['size']
		try:
			rounds = request.json['rounds']
		except:
			raise InvalidUsage('Round information is not valid')
		teamSize = args['teamSize']
		#group_stage = args['group_stage']
		map = args['map']
		pick = args['pick']
		roundNumber = int(math.log(size,2))
		totalPrize = args['totalPrize']
		profile = Profile.objects(user=user_id).first()

		if roundNumber != math.log(size,2):
			return {'status' : 'error', 'message' : 'size not acceptable'}

		tournament = Tournament(tournamentName=tournamentName,isSchool=isSchool,descriptions=descriptions,entryFee=entryFee,size=size,school=school,creator=profile,totalPrize=totalPrize)

		for i in range(roundNumber):
			round = Round(roundName=str(Fraction(2*(i+1)/size))+' Final', startTime=rounds[i]['startTime'], bestOfN=rounds[i]['bestOfN'])
			round.save()
			tournament.rounds.append(round)
		for i in range(roundNumber-1):
			tournament.rounds[i].next = tournament.rounds[i+1]
		tournament.rounds[roundNumber-1].next = None


		try:
			tournament.save()
		except ValidationError,e:
			raise InvalidUsage(e.message)
Exemple #13
0
    def create_round():
        '''let the user create an instance of round'''
        while True:
            try:
                name = int(input('Enter the round number (1, 2, 3, 4): '))
                date = input('round_date: ')
                time = input('round_time')
                break

            except ValueError:
                print('Error in the entries')

        round = Round(name=name, date=date, time=time)
        return round
    def run_rounds(self, tournament_table, actors_db, next_round_number=2):
        """ Fonction qui fait tourner les rounds suivants """
        for i in range(next_round_number, 5):
            players = self.get_players()
            round_name = f"Round {i}"
            round_date = vr.get_round_date()
            round_starttime = vr.get_round_starttime()
            round_endtime = " "
            next_round = Round(round_name, round_date, round_starttime,
                               round_endtime)
            self.tournament_progress.add_round(next_round)

            serialized_next_round = next_round.serialize()

            self.tournament_progress.serialized_rounds.append(
                serialized_next_round)
            self.tournament_progress.serialized_rounds = (
                self.tournament_progress.serialized_rounds)
            self.serialized_tournament = self.tournament_progress.serialize()

            vt.print_info(f"{round_name} launchment...")

            self.make_pairing(players, next_round)
            self.tournament_progress.serialized_players.clear()

            for match in self.tournament_progress.rounds[i - 1].matchs:
                vt.print_info("\n...\n")
                vt.print_info(
                    f"{match.player1.name} and {match.player2.name} play against each other !"
                )

                match.score1, match.score2 = self.handle_score(match)
                vr.print_match_result(match)

                serialized_match = match.serialize()
                next_round.serialized_matchs.append(serialized_match)

                match.player1.add_opponent(match.player2)
                match.player2.add_opponent(match.player1)
                match.player1.add_score(match.score1)
                match.player2.add_score(match.score2)

                serialized_player1 = match.player1.serialize()
                self.tournament_progress.serialized_players.append(
                    serialized_player1)

                serialized_player2 = match.player2.serialize()
                self.tournament_progress.serialized_players.append(
                    serialized_player2)

                self.tournament_progress.serialized_tournament = (
                    self.tournament_progress.serialize())
                tournament_table.update(
                    self.tournament_progress.serialized_tournament)

            next_round.endtime = vr.get_round_endtime()
            endtime = next_round.serialize_endtime()

            tournament_table.update(
                self.tournament_progress.serialized_tournament)
            vt.print_info(f"End of the {round_name} at {next_round.endtime}.")
            vt.print_info("\n--------------------------------------\n")
            i += 1

        self.tournament_progress.serialized_tournament = (
            self.tournament_progress.serialize())
        vt.print_info(
            f"{self.tournament_progress.name} is over !\n--------------------------------------\n"
        )
        vt.print_players_scores(self.tournament_progress.players)
        return tournament_table, actors_db
Exemple #15
0
                    # Ajout des joueurs
                    controller.create_players(current_tournament)
                    # Liste des joueurs
                    players_list = current_tournament.players_list

                    # Déroulement d'un match
                    round_number = current_tournament.turn_number
                    counter = round_number - 1
                    sort_list = sorted(players_list,
                                       key=attrgetter("player_ranking"))
                    half_length = len(sort_list) // 2

                    # premier tour
                    # création d'une instance round
                    view.show("Round", round_number - counter)
                    current_round = Round("Round {}".format(round_number -
                                                            counter))
                    for k in range(len(sort_list) // 2):
                        current_tournament.add_matches(
                            Match(sort_list[k], sort_list[half_length]))
                        current_round.add_matches(
                            Match(sort_list[k], sort_list[half_length]))
                        half_length += 1
                    controller.enter_matches_score(current_round.matches_list)

                    # determiner la date et leur de fin du tour
                    current_round.end_date = datetime.datetime.now().strftime(
                        "%d/%m/%Y %H:%M:%S")

                    # Sauvegarde des matchs dans la base de données
                    controller.save_match(current_round.matches_list)
                    matches_id_list = controller.get_matches_id(
def server_thread(aggregator, log, users, train_qs, weight_qs, statistics, xtest, ytest, train_pct=10, mode=0):
    """
    Workflow: (1) Create and run a round... entails asking users to train and
                  retrieving the result
              (2) Update teh global model with user weights
              (3) Receive user requests for updates and deletes and handle them
    """
    global TRAIN_TIME
    start = time.time()
    print("Starting server thread at: " + str(start))

    # initialize global weights of round -1 to be random
    initial_weights = np.zeros(xtest[0].shape[0])
    log.set_global_checkpoint(-1, initial_weights)

    rid = 0
    for _ in range(len(users)):
        while True:
            try:
                print("[server thread] Starting round " + str(rid) + " at time: " + str(time.time() - start))
                # determine number of users to participate in the next round
                r = random.randrange(1, len(users) + 1)

                # set up the round
                new_round = Round(
                    rid,                    # round id
                    tfunc,                  # training function
                    dfunc,                  # data function
                    afunc,                  # aggregator function
                    r                       # number of participating devices
                )

                # tell aggregator to make users train on data
                print("[server thread] calling on users to train...")
                if not aggregator.basic_train(new_round, train_qs, weight_qs, TRAIN_TIME):
                    continue

                print("[server thread] handling user update requests...")
                handled = aggregator.urm.handle_requests()

                print("[server thread] computing accuracy on most recent global weights")

                round_stats = {"guesses": 0, "correct": 0, "guess_to_actual":{"True": [0, 0], "False": [0, 0]}}
                round_stats["round"] = rid

                indices = random.sample(list(range(len(xtest))), len(xtest) // 4)

                samples, labels = [], []
                for i in indices:
                    samples.append(xtest[i])
                    labels.append(ytest[i])
                samples, labels = np.array(samples).astype(float), np.array(labels)
                model_weights = log.get_global_checkpoint(rid)
                # and then this part is to create a dummy LocalUpdate
                prediction_loss = loss(samples, labels, model_weights)
                print("Loss: ", prediction_loss, ", at round: ", rid)

                predictions = np.dot(samples, model_weights)
                softmaxed = softmax(predictions)
                prediction_labels = np.array([1.0 if e > 0.5 else 0.0 for e in softmaxed])


                for pred, act in zip(prediction_labels, labels):
                    round_stats["guesses"] += 1
                    round_stats["correct"] += 1 if pred == min(act, 1.) else 0
                    round_stats["guess_to_actual"]["True" if pred == min(act, 1.) else "False"][min(1, int(act))] += 1

                round_stats['time'] = time.time() - start

                if handled:
                    round_stats['requests_handled'] = 1
                else:
                    round_stats['requests_handled'] = 0

                round_stats['logger_size'] = log.getsize()

                print("Round stats: ", round_stats)
                statistics.append(round_stats)

                rid += 1
                break
            except Exception:
                continue

    log.save_logger_model("income-logger.pkl")

    return statistics
    def create_round(self):
        """
        Create a round. Update tournament and round table
        """
        new_round = Round.create_round()
        serialized_round = vars(new_round)
        new_matchs_id = []
        serialized_round["current_round"] = (
            self.round_table.all()[-1]["current_round"] + 1
        )
        serialized_round["name"] = "Round " + str(serialized_round["current_round"])
        self.round_table.insert(serialized_round)
        list_of_players_by_score = self.list_of_players_by_score()
        all_matchs_of_a_tournament = self.list_of_all_matchs_of_a_tournament()
        Play = Query()
        list_matchs = []
        j = 0

        try:
            for _ in range(4):
                k = 1
                while self.is_match_already_play(
                    all_matchs_of_a_tournament,
                    self.player_table.get(
                        Play.ranking == list_of_players_by_score[j]["ranking"]
                    ).doc_id,
                    self.player_table.get(
                        Play.ranking == list_of_players_by_score[j + 1]["ranking"]
                    ).doc_id,
                ):
                    self.is_match_already_play(
                        all_matchs_of_a_tournament,
                        self.player_table.get(
                            Play.ranking == list_of_players_by_score[j]["ranking"]
                        ).doc_id,
                        self.player_table.get(
                            Play.ranking
                            == list_of_players_by_score[j + 1 + k]["ranking"]
                        ).doc_id,
                    )
                    (
                        list_of_players_by_score[j + 1],
                        list_of_players_by_score[j + 1 + k],
                    ) = (
                        list_of_players_by_score[j + 1 + k],
                        list_of_players_by_score[j + 1],
                    )
                    k += 1
                list_matchs.append(
                    (
                        self.player_table.get(
                            Play.ranking == list_of_players_by_score[j]["ranking"]
                        ).doc_id,
                        self.player_table.get(
                            Play.ranking == list_of_players_by_score[j + 1]["ranking"]
                        ).doc_id,
                    )
                )
                j += 2
        except IndexError:
            list_matchs.pop(-1)
            if (
                self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -1, -3
                )
                is not True
                and self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -2, -4
                )
                is not True
            ):
                list_matchs.append(
                    (
                        list_of_players_by_score[-1].doc_id,
                        list_of_players_by_score[-3].doc_id,
                    )
                )
                list_matchs.append(
                    (
                        list_of_players_by_score[-2].doc_id,
                        list_of_players_by_score[-4].doc_id,
                    )
                )
            elif (
                self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -1, -4
                )
                is not True
                and self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -2, -3
                )
                is not True
            ):
                list_matchs.append(
                    (
                        list_of_players_by_score[-1].doc_id,
                        list_of_players_by_score[-4].doc_id,
                    )
                )
                list_matchs.append(
                    (
                        list_of_players_by_score[-2].doc_id,
                        list_of_players_by_score[-3].doc_id,
                    )
                )
            elif (
                self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -1, -3
                )
                is not True
                and self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -2, -5
                )
                is not True
                and self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -4, -6
                )
                is not True
            ):
                list_matchs.pop(-1)
                list_matchs.append(
                    (
                        list_of_players_by_score[-1].doc_id,
                        list_of_players_by_score[-3].doc_id,
                    )
                )
                list_matchs.append(
                    (
                        list_of_players_by_score[-2].doc_id,
                        list_of_players_by_score[-5].doc_id,
                    )
                )
                list_matchs.append(
                    (
                        list_of_players_by_score[-4].doc_id,
                        list_of_players_by_score[-6].doc_id,
                    )
                )
            elif (
                self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -1, -4
                )
                is not True
                and self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -2, -5
                )
                is not True
                and self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -3, -6
                )
                is not True
            ):
                list_matchs.pop(-1)
                list_matchs.append(
                    (
                        list_of_players_by_score[-1].doc_id,
                        list_of_players_by_score[-4].doc_id,
                    )
                )
                list_matchs.append(
                    (
                        list_of_players_by_score[-2].doc_id,
                        list_of_players_by_score[-5].doc_id,
                    )
                )
                list_matchs.append(
                    (
                        list_of_players_by_score[-3].doc_id,
                        list_of_players_by_score[-6].doc_id,
                    )
                )
            elif (
                self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -2, -3
                )
                is not True
                and self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -1, -5
                )
                is not True
                and self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -4, -6
                )
                is not True
            ):
                list_matchs.pop(-1)
                list_matchs.append(
                    (
                        list_of_players_by_score[-2].doc_id,
                        list_of_players_by_score[-3].doc_id,
                    )
                )
                list_matchs.append(
                    (
                        list_of_players_by_score[-1].doc_id,
                        list_of_players_by_score[-5].doc_id,
                    )
                )
                list_matchs.append(
                    (
                        list_of_players_by_score[-4].doc_id,
                        list_of_players_by_score[-6].doc_id,
                    )
                )
            elif (
                self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -2, -4
                )
                is not True
                and self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -1, -5
                )
                is not True
                and self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -3, -6
                )
                is not True
            ):
                list_matchs.pop(-1)
                list_matchs.append(
                    (
                        list_of_players_by_score[-2].doc_id,
                        list_of_players_by_score[-4].doc_id,
                    )
                )
                list_matchs.append(
                    (
                        list_of_players_by_score[-1].doc_id,
                        list_of_players_by_score[-5].doc_id,
                    )
                )
                list_matchs.append(
                    (
                        list_of_players_by_score[-3].doc_id,
                        list_of_players_by_score[-6].doc_id,
                    )
                )
            elif (
                self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -1, -5
                )
                is not True
                and self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -2, -6
                )
                is not True
                and self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -3, -4
                )
                is not True
            ):
                list_matchs.pop(-1)
                list_matchs.append(
                    (
                        list_of_players_by_score[-1].doc_id,
                        list_of_players_by_score[-5].doc_id,
                    )
                )
                list_matchs.append(
                    (
                        list_of_players_by_score[-2].doc_id,
                        list_of_players_by_score[-6].doc_id,
                    )
                )
                list_matchs.append(
                    (
                        list_of_players_by_score[-3].doc_id,
                        list_of_players_by_score[-4].doc_id,
                    )
                )
            elif (
                self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -1, -6
                )
                is not True
                and self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -2, -5
                )
                is not True
                and self.is_permuted_match_existed(
                    all_matchs_of_a_tournament, list_of_players_by_score, -3, -4
                )
                is not True
            ):
                list_matchs.pop(-1)
                list_matchs.append(
                    (
                        list_of_players_by_score[-1].doc_id,
                        list_of_players_by_score[-6].doc_id,
                    )
                )
                list_matchs.append(
                    (
                        list_of_players_by_score[-2].doc_id,
                        list_of_players_by_score[-5].doc_id,
                    )
                )
                list_matchs.append(
                    (
                        list_of_players_by_score[-3].doc_id,
                        list_of_players_by_score[-4].doc_id,
                    )
                )

        for match in list_matchs:
            new_match = Match.create_match(
                match[0],
                match[1],
            )
            serialized_match = vars(new_match)
            self.match_table.insert(serialized_match)
            new_matchs_id.append(self.match_table.all()[-1].doc_id)

        list_of_rounds = self.tournament_table.all()[-1]["rounds"]
        list_of_rounds.append(self.round_table.all()[-1].doc_id)
        self.round_table.update(
            {"list_of_match": new_matchs_id},
            doc_ids=[self.round_table.all()[-1].doc_id],
        )
        self.tournament_table.update(
            {"rounds": list_of_rounds},
            doc_ids=[self.tournament_table.all()[-1].doc_id],
        )
        self.warning.round_create(str(self.round_table.all()[-1]["current_round"]))
        self.table.matchs()
        return self.manage_tournament()