<commit_before>from MineField.MineField import MineField
from DeployMines.DeployMines import DeployMines 
from collections import deque
class MineShell:
    def __init__(self):
        self.field = None
        self.space = ' '
        self.flagNum = 0
        self.mineNum = 0
        self.firstPoke = True

    def getInput(self, string):
        strings = string.split(' ')
        if (strings[0] == 'minefield'):
            return self.createMineField(int(strings[2]), int(strings[1]), int(strings[3]))
        if self.field == None:
            return 'no minefield'
        if (strings[0] == 'poke'):
            x = int(strings[1])
            y = int(strings[2])
            if not self.checkPositionValid(x, y):
                return 'out of bounds'
            pos =  self.poke(x, y)
            return self.pokeOutPut(pos)
        if (strings[0] == 'peek'):
            x = int(strings[1])
            y = int(strings[2])
            if not self.checkPositionValid(x, y):
                return 'out of bounds'
            return self.peek(x, y)
        if (strings[0] == 'flag'):
            x = int(strings[1])
            y = int(strings[2])
            if not self.checkPositionValid(x, y):
                return 'out of bounds'
            return self.flag(x, y)
        if (strings[0] == 'unflag'):
            x = int(strings[1])
            y = int(strings[2])
            if not self.checkPositionValid(x, y):
                return 'out of bounds'
            return self.unflag(x, y)
        if (strings[0] == 'query'):
            if strings[1] == 'flags':
                return str(self.flagNum)
            if strings[1] == 'mines':
                return str(self.mineNum)
            if strings[1] == 'width':
                return str(self.field.width)
            if strings[1] == 'height':
                return str(self.field.height)
            if strings[1] == 'success':
                return self.isSuccess()

    def isSuccess(self):
        if self.flagNum != self.mineNum:
            return False
        for y in range(self.field.height):
            for x in range(self.field.width):
                if self.field.opened[y][x] == False and self.field.flagged[y][x] == False:
                    return False
                if self.field.status[y][x] == -1 and self.field.flagged[y][x] == False:
                    return False
                if self.field.status[y][x] != -1 and self.field.flagged[y][x] == True:
                    return False
        return True

    def flag(self, x, y):
        if self.field.opened[y][x] == False and self.field.flagged[y][x] ==  False:
            self.field.flagged[y][x] = True
            self.field.opened[y][x] = True
            self.flagNum = self.flagNum + 1
            return str(x) + self.space + str(y) + self.space + 'flagged'<commit_msg>Rm bug of isSuccess in MineShell<commit_after>from MineField.MineField import MineField
from DeployMines.DeployMines import DeployMines 
from collections import deque
class MineShell:
    def __init__(self):
        self.field = None
        self.space = ' '
        self.flagNum = 0
        self.mineNum = 0
        self.firstPoke = True

    def getInput(self, string):
        strings = string.split(' ')
        if (strings[0] == 'minefield'):
            return self.createMineField(int(strings[2]), int(strings[1]), int(strings[3]))
        if self.field == None:
            return 'no minefield'
        if (strings[0] == 'poke'):
            x = int(strings[1])
            y = int(strings[2])
            if not self.checkPositionValid(x, y):
                return 'out of bounds'
            pos =  self.poke(x, y)
            return self.pokeOutPut(pos)
        if (strings[0] == 'peek'):
            x = int(strings[1])
            y = int(strings[2])
            if not self.checkPositionValid(x, y):
                return 'out of bounds'
            return self.peek(x, y)
        if (strings[0] == 'flag'):
            x = int(strings[1])
            y = int(strings[2])
            if not self.checkPositionValid(x, y):
                return 'out of bounds'
            return self.flag(x, y)
        if (strings[0] == 'unflag'):
            x = int(strings[1])
            y = int(strings[2])
            if not self.checkPositionValid(x, y):
                return 'out of bounds'
            return self.unflag(x, y)
        if (strings[0] == 'query'):
            if strings[1] == 'flags':
                return str(self.flagNum)
            if strings[1] == 'mines':
                return str(self.mineNum)
            if strings[1] == 'width':
                return str(self.field.width)
            if strings[1] == 'height':
                return str(self.field.height)
            if strings[1] == 'success':
                return self.isSuccess()

    def isSuccess(self):
        #if self.flagNum != self.mineNum:
        #    return False
        for y in range(self.field.height):
            for x in range(self.field.width):
                if self.field.status[y][x] != -1 and self.field.opened[y][x] == False:
                    return False
                #if self.field.opened[y][x] == False and self.field.flagged[y][x] == False:
                #    return False
                #if self.field.status[y][x] == -1 and self.field.flagged[y][x] == False:
                #    return False
                #if self.field.status[y][x] != -1 and self.field.flagged[y][x] == True:
                #    return False
        return True

    def flag(self, x, y):
        if self.field.opened[y][x] == False and self.field.flagged[y][x] ==  False:
            self.field.flagged[y][x] = True
            self.field.opened[y][x] = True
            self.flagNum = self.flagNum + 1
            return str(x) + self.space + str(y) + self.space + 'flagged'
{'fraction_non_alphanumeric': 0.1316646665523744, 'fraction_numerical': 0.009429110234870563, 'mean_word_length': 1.6243814664867295, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3195726', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1728, 'n_words': 430}