<commit_before>from collections import namedtuple
from games import (Game)
from copy import deepcopy

class TemplateState:    # one way to define the state of a minimal game.

    def __init__(self, player, board):  # add parameters as needed.
        self.to_move = player
        self.label = str(id(self))   # change this to something easier to read
        self.board = board
        # add code and self.variables as needed.
        # print(board)

    def __str__(self):  # use this exact signature
        return self.label

class TemplateGame(Game):
    '''
    This is a minimal Game definition,
    the shortest implementation I could run without errors.
    '''

    def __init__(self, initial):    # add parameters if needed.
        self.initial = initial
        # add code and self.variables if needed.
        self.oldBoard = []



    def actions(self, state):   # use this exact signature.
        try:
            return state.moves
        except:
            pass
        "Legal moves are any square not yet taken."
        moves = []
        board = state.board
        if state.to_move == '1':
            for x in range(0,6):
                if board[0][x] > 0:
                   moves.append(x)
        if state.to_move == '2':
            for x in range(0,6):
                 if board[1][x] > 0:
                  moves.append(x+6)
        return moves



    def result(self, state, move):   # use this exact signature.
        newState = deepcopy(state)
        self.oldBoard = state.board.copy()
        # if move not in self.actions(state):
        #     return state  # Illegal move has no effect
        board = state.board.copy()
        firstMove = move + 1
        player = newState.to_move
        lastMove = 0
        if player == '1' and move < 7:
            count1 = board[0][move]
            game = 6 - move
            board[0][move] = 0
            while count1 > 0 and game != 0:
                board[0][firstMove] = board[0][firstMove] + 1
                count1 -= 1
                game -= 1
                lastMove = firstMove
                firstMove += 1


            while count1 > 0:
                for y in range(0, 6):
                    board[1][y] = board[1][y] + 1
                    count1 -= 1
                    lastMove = y
                if count1 > 0:
                    for z in range(0,7):
                        board[0][z] = board[0][z] + 1
                        count1 -= 1
                        lastMove = z
        if player == '2' and move > 6:
            count1 = board[1][move - 6]
            game = 6 - (move - 8)
            board[1][move - 6] = 0
            while count1 > 0 and game != 0:
                board[1][firstMove - 7] = board[1][firstMove - 7] + 1
                count1 -= 1
                game -= 1
                lastMove = firstMove - 7
                firstMove += 1

            while count1 > 0:
                for y in range(0, 7):
                    board[0][y] = board[0][y] + 1
                    count1 -= 1
                    lastMove = y
                if count1 > 0:
                    for z in range(0,6):
                        board[1][z] = board[1][z] + 1
                        count1 -= 1
                        lastMove = z
        if lastMove == 6:
            newState.to_move = newState.to_move
        else:
            state.to_move = self.opponent(player)
            newState.to_move = self.opponent(player)
        newState.board = board
        return newState

    # defines the order of play
    def opponent(self, player):
        if player == '1':
            return '2'
        if player == '2':<commit_msg>Search Problem<commit_after>from collections import namedtuple
from games import (Game)
from copy import deepcopy

class TemplateState:    # one way to define the state of a minimal game.

    def __init__(self, player, board):  # add parameters as needed.
        self.to_move = player
        self.label = str(id(self))   # change this to something easier to read
        self.board = board
        # add code and self.variables as needed.
        # print(board)

    def __str__(self):  # use this exact signature
        return self.label

class TemplateGame(Game):
    '''
    This is a minimal Game definition,
    the shortest implementation I could run without errors.
    '''

    def __init__(self, initial):    # add parameters if needed.
        self.initial = initial
        # add code and self.variables if needed.
        self.oldBoard = []



    def actions(self, state):   # use this exact signature.
        try:
            return state.moves
        except:
            pass
        "Legal moves are any square not yet taken."
        moves = []
        board = state.board
        if state.to_move == '1':
            for x in range(0,6):
                if board[0][x] > 0:
                   moves.append(x)
        if state.to_move == '2':
            for x in range(0,6):
                 if board[1][x] > 0:
                  moves.append(x+6)
        return moves



    def result(self, state, move):   # use this exact signature.
        newState = deepcopy(state)
        self.oldBoard = state.board.copy()
        # if move not in self.actions(state):
        #     return state  # Illegal move has no effect
        board = state.board.copy()
        firstMove = move + 1
        player = newState.to_move
        lastMove = 0
        if player == '1' and move < 7:
            count1 = board[0][move]
            game = 6 - move
            board[0][move] = 0
            while count1 > 0 and game != 0:
                board[0][firstMove] = board[0][firstMove] + 1
                count1 -= 1
                game -= 1
                lastMove = firstMove
                firstMove += 1


            while count1 > 0:
                for y in range(0, 6):
                    board[1][y] = board[1][y] + 1
                    count1 -= 1
                    lastMove = y
                if count1 > 0:
                    for z in range(0,7):
                        board[0][z] = board[0][z] + 1
                        count1 -= 1
                        lastMove = z
        if player == '2' and move > 6:
            count1 = board[1][move - 6]
            game = 6 - (move - 8)
            board[1][move - 6] = 0
            while count1 > 0 and game != 0:
                board[1][firstMove - 7] = board[1][firstMove - 7] + 1
                count1 -= 1
                game -= 1
                lastMove = firstMove - 7
                firstMove += 1

            while count1 > 0:
                for y in range(0, 7):
                    board[0][y] = board[0][y] + 1
                    count1 -= 1
                    lastMove = y
                if count1 > 0:
                    for z in range(0,6):
                        board[1][z] = board[1][z] + 1
                        count1 -= 1
                        lastMove = z
        if lastMove == 6:
            newState.to_move = newState.to_move
        else:
            # state.to_move = self.opponent(player)
            newState.to_move = self.opponent(player)
        newState.board = board
        return newState

    # defines the order of play
    def opponent(self, player):
        if player == '1':
            return '2'
        if player == '2':
{'fraction_non_alphanumeric': 0.09567353623584005, 'fraction_numerical': 0.025385560256585234, 'mean_word_length': 1.2444104134762635, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '2858385', 'n_tokens_mistral': 2135, 'n_tokens_neox': 1962, 'n_words': 652}