<commit_before>from series import Series
from itertools import combinations
from blessings import Terminal
from tabulate import tabulate

class Tournament(object):
    def __init__(self,
                 players,
                 numberOfGames,
                 alternateFirstPlayer=True,
                 debug=False,
                 boardWidth=None,
                 boardHeight=None,
                 showVisualization=False,
                 visualizationInterval=.01,
                 showStatistics=False,
                 clearBoardOnException=False):
        self.players = players
        self.numberOfGames = numberOfGames
        self.alternateFirstPlayer = alternateFirstPlayer
        self.debug = debug
        self.boardWidth = boardWidth
        self.boardHeight = boardHeight
        self.showVisualization = showVisualization
        self.visualizationInterval = visualizationInterval
        self.showStatistics = showStatistics
        self.clearBoardOnException = clearBoardOnException
        self.term = Terminal()

    def run(self):
        self.results = dict([(player, [{'win': 0,
                                        'lose': 0,
                                        'draw': 0}, []]) for player in self.players])
        self.series = [Series(x[0](),
                              x[1](),
                              self.numberOfGames,
                              alternateFirstPlayer=self.alternateFirstPlayer,
                              debug=self.debug,
                              boardWidth=self.boardWidth,
                              boardHeight=self.boardHeight,
                              showVisualization=self.showVisualization,
                              visualizationInterval=self.visualizationInterval,
                              clearBoardOnException=self.clearBoardOnException,
                              tournament=self)
                            for x in combinations(self.players, 2)]

        self.series[0].player1._initializeGameBoard()
        self.series[0].player2._initializeGameBoard()
        self.displayLeaderBoard(nextGameIndex=1)

        for idx, series in enumerate(self.series):
            if self.showVisualization:
                print self.term.clear
                self.series[0].player1._initializeGameBoard()
                self.series[0].player2._initializeGameBoard()
                series.printStats()
            self.displayLeaderBoard(nextGameIndex=idx + 1)
<commit_msg>Shuffling opponents<commit_after>from series import Series
from itertools import combinations
from blessings import Terminal
from tabulate import tabulate
import random

class Tournament(object):
    def __init__(self,
                 players,
                 numberOfGames,
                 alternateFirstPlayer=True,
                 debug=False,
                 boardWidth=None,
                 boardHeight=None,
                 showVisualization=False,
                 visualizationInterval=.01,
                 showStatistics=False,
                 clearBoardOnException=False):
        self.players = players
        self.numberOfGames = numberOfGames
        self.alternateFirstPlayer = alternateFirstPlayer
        self.debug = debug
        self.boardWidth = boardWidth
        self.boardHeight = boardHeight
        self.showVisualization = showVisualization
        self.visualizationInterval = visualizationInterval
        self.showStatistics = showStatistics
        self.clearBoardOnException = clearBoardOnException
        self.term = Terminal()

    def run(self):
        self.results = dict([(player, [{'win': 0,
                                        'lose': 0,
                                        'draw': 0}, []]) for player in self.players])
        self.series = [Series(x[0](),
                              x[1](),
                              self.numberOfGames,
                              alternateFirstPlayer=self.alternateFirstPlayer,
                              debug=self.debug,
                              boardWidth=self.boardWidth,
                              boardHeight=self.boardHeight,
                              showVisualization=self.showVisualization,
                              visualizationInterval=self.visualizationInterval,
                              clearBoardOnException=self.clearBoardOnException,
                              tournament=self)
                            for x in combinations(self.players, 2)]
        random.shuffle(self.series)

        self.series[0].player1._initializeGameBoard()
        self.series[0].player2._initializeGameBoard()
        self.displayLeaderBoard(nextGameIndex=1)

        for idx, series in enumerate(self.series):
            if self.showVisualization:
                print self.term.clear
                self.series[0].player1._initializeGameBoard()
                self.series[0].player2._initializeGameBoard()
                series.printStats()
            self.displayLeaderBoard(nextGameIndex=idx + 1)

{'fraction_non_alphanumeric': 0.07094459944200877, 'fraction_numerical': 0.007174172977281785, 'mean_word_length': 1.562021439509954, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3181165', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1110, 'n_words': 204}