Example #1
0
    def move(self, board):
        moves = []
        directions = [1, 0, -1, 0, 0, 1, 0, -1]
        for i in range(0, len(directions), 2):
            for j in range(1, 8):
                area = (self.pos[0] + j * directions[i], self.pos[1] + j * directions[i + 1])
                if is_area_in_board(area):
                    if board[area[0]][area[1]].checker == None:
                        moves.append(area)
                    else:
                        if board[area[0]][area[1]].checker.color != self.color:
                            if board[area[0]][area[1]].checker.val != 900 * self.color * -1:
                                moves.append(area)
                        break
                else:
                    break

        directions = [1, 1, -1, -1, 1, -1, -1, 1]
        for i in range(0, len(directions), 2):
            for j in range(1, 8):
                area = (self.pos[0] + j * directions[i], self.pos[1] + j * directions[i + 1])
                if is_area_in_board(area):
                    if board[area[0]][area[1]].checker == None:
                        moves.append(area)
                    else:
                        if board[area[0]][area[1]].checker.color != self.color:
                            if board[area[0]][area[1]].checker.val != 900 * self.color * -1:
                                moves.append(area)
                        break
                else:
                    break

        return moves
Example #2
0
    def king_attack(self, board):
        directions = [1, 0, -1, 0, 0, 1, 0, -1]
        for i in range(0, len(directions), 2):
            for j in range(1, 8):
                area = (self.pos[0] + j * directions[i], self.pos[1] + j * directions[i + 1])
                if is_area_in_board(area):
                    if board[area[0]][area[1]].checker == None:
                        continue
                    else:
                        if board[area[0]][area[1]].checker.color != self.color:
                            if board[area[0]][area[1]].checker.val == 900 * self.color * -1:
                                return True
                        break
                else:
                    break
        directions = [1, 1, -1, -1, 1, -1, -1, 1]
        for i in range(0, len(directions), 2):
            for j in range(1, 8):
                area = (self.pos[0] + j * directions[i], self.pos[1] + j * directions[i + 1])
                if is_area_in_board(area):
                    if board[area[0]][area[1]].checker == None:
                        continue
                    else:
                        if board[area[0]][area[1]].checker.color != self.color:
                            if board[area[0]][area[1]].checker.val == 900 * self.color * -1:
                                return True
                        break
                else:
                    break

        return False
Example #3
0
    def normal_move(self, board):
        correct_moves = []
        direction = self.color * -1

        area = (self.pos[0] + 1 * direction, self.pos[1])
        if is_area_in_board(area) and board[area[0]][area[1]].checker == None:
            correct_moves.append(area)

        moves = [(self.pos[0] + 1 * direction, self.pos[1] + 1),
                 (self.pos[0] + 1 * direction, self.pos[1] - 1)]
        for area in moves:
            if is_area_in_board(area) and board[area[0]][
                    area[1]].checker != None:  #Wedlug Pycharm is not
                if board[area[0]][area[1]].checker.color != self.color:
                    if board[area[0]][
                            area[1]].checker.val != 900 * self.color * -1:
                        correct_moves.append(area)

        return correct_moves
Example #4
0
    def king_attack(self, board):
        moves = []
        directions = [1, 0, -1, 0, 0, 1, 0, -1, 1, 1, -1, -1, 1, -1, -1, 1]
        for i in range(0, len(directions), 2):
            moves.append(
                (self.pos[0] + directions[i], self.pos[1] + directions[i + 1]))

        for area in moves:
            if is_area_in_board(area):
                if board[area[0]][area[1]].checker != None:
                    if board[area[0]][area[1]].checker.color != self.color:
                        if board[area[0]][
                                area[1]].checker.val == 900 * self.color * -1:
                            return True
        return False
Example #5
0
    def king_attack(self, board):
        self.is_promotion(board)
        direction = self.color * -1

        moves = [(self.pos[0] + 1 * direction, self.pos[1] + 1),
                 (self.pos[0] + 1 * direction, self.pos[1] - 1)]

        for area in moves:
            if is_area_in_board(area) and board[area[0]][
                    area[1]].checker != None:  # Wedlug Pycharm is not
                if board[area[0]][area[1]].checker.color != self.color:
                    if board[area[0]][
                            area[1]].checker.val == 900 * self.color * -1:
                        return True

        return False
Example #6
0
    def normal_move(self, board):
        moves = []
        correct_moves = []
        directions = [1, 0, -1, 0, 0, 1, 0, -1, 1, 1, -1, -1, 1, -1, -1, 1]
        for i in range(0, len(directions), 2):
            moves.append(
                (self.pos[0] + directions[i], self.pos[1] + directions[i + 1]))

        for area in moves:
            if is_area_in_board(area):
                if board[area[0]][area[1]].checker == None:
                    correct_moves.append(area)
                elif board[area[0]][area[1]].checker.color != self.color:
                    if board[area[0]][
                            area[1]].checker.val != 900 * self.color * -1:
                        correct_moves.append(area)
        return correct_moves
Example #7
0
    def set_passe(self, board, move_count):
        passe_moves = []
        passe_attack = 3
        if self.color == -1:
            passe_attack = 4

        moves = [(self.pos[0], self.pos[1] + 1),
                 (self.pos[0], self.pos[1] - 1)]

        for area in moves:
            if is_area_in_board(
                    area) and self.pos[0] == passe_attack and board[area[0]][
                        area[1]].checker != None:
                if abs(board[area[0]][area[1]].checker.val) == 10 and board[
                        area[0]][area[1]].checker.move_passe != -1:
                    if move_count - board[area[0]][
                            area[1]].checker.move_passe <= 2:
                        passe_moves.append((area[0] - 1 * self.color, area[1]))

        return passe_moves