<commit_before>import stratum.engine


CONFIG = {
    "num_players": 2,
    "player_names": ["X", "O"] 
}


class Engine(stratum.engine.BaseEngine):
    
    def __init__(self, players=[], view_connection=None):
        super(Engine, self).__init__(players=players, view_connection=view_connection)
        self._board = [[None for _ in range(3)] for _ in range(3)]
        self._winner = None
        self._x_turn = True

    def is_game_over(self):
        for row in self._board:
            if all("X" == cell for cell in row):
                self._winner = "X"
                return True
            elif all("O" == cell for cell in row):
                self._winner = "O"
                return True
        for col in range(3):
            col = tuple(self._board[i][col] for i in range(3))
            if all("X" == cell for cell in col):
                self._winner = "X"
                return True
            elif all("O" == cell for cell in col):
                self._winner = "O"
                return True
        for mod in (1, -1):
            diag = tuple(self._board[mod*i][i] for i in range(3))
            if all("X" == cell for cell in diag):
                self._winner = "X"
                return True
            elif all("O" == cell for cell in diag):
                self._winner = "O"
                return True
        return not any(None == cell for row in self._board for cell in row)

    def get_state(self):
        return {
            "type": "state",
            "board": self._board,
            "winner": self._winner
        }

    def play_turn(self):<commit_msg>fix win condition checking for TicTacToe<commit_after>import stratum.engine


CONFIG = {
    "num_players": 2,
    "player_names": ["X", "O"] 
}


def _get_first_if_all_equal(lst):
    first = lst[0]
    for el in lst[1:]:
        if el != first:
            return None
    return first


class Engine(stratum.engine.BaseEngine):
    
    def __init__(self, players=[], view_connection=None):
        super(Engine, self).__init__(players=players, view_connection=view_connection)
        self._board = [[None for _ in range(3)] for _ in range(3)]
        self._winner = None
        self._x_turn = True

    def is_game_over(self):
        for i in range(3):
            row_val = _get_first_if_all_equal(self._board[i])
            col_val = _get_first_if_all_equal(tuple(self._board[j][i] for j in range(3)))
            if row_val == "X" or col_val == "X":
                self._winner = "X"
                return True
            elif row_val == "O" or col_val == "O":
                self._winner = "O"
                return True
        diag1_val = _get_first_if_all_equal(tuple(self._board[i][i] for i in range(3)))
        diag2_val = _get_first_if_all_equal(tuple(self._board[2-i][i] for i in range(3)))
        if diag1_val == "X" or diag2_val == "X":
            self._winner = "X"
            return True
        elif diag1_val == "O" or diag2_val == "O":
            self._winner = "O"
            return True
        return not any(None == cell for row in self._board for cell in row)

    def get_state(self):
        return {
            "type": "state",
            "board": self._board,
            "winner": self._winner
        }

    def play_turn(self):
{'fraction_non_alphanumeric': 0.1172895776359769, 'fraction_numerical': 0.007292616226071103, 'mean_word_length': 1.7921967769296014, 'pattern_counts': {'":': 14, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5079548', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1018, 'n_words': 282}