更有效地检测检查(国际象棋)

2023-12-31

我目前正在开发一个国际象棋引擎,该引擎到目前为止正在运行,但需要很长时间才能生成棋步。由于必须生成许多移动,因此检查检测花费的时间是迄今为止最长的。

在尝试了很多事情之后我陷入了困境,并且无法真正弄清楚如何提高效率。我是这样做的:

为了检查移动是否允许/合法,我检查移动的一方随后是否受到检查:

    def allowed_move(self, board, pos, move, colour):

    copy_board = copy.deepcopy(board)

    (x, y) = pos
    (new_x, new_y) = move

    if copy_board[x][y] == "k_w":
        self.white_king = (new_x, new_y)
        copy_board[new_x][new_y] = copy_board[x][y]
        copy_board[x][y] = " "
        self.in_check(colour, copy_board)
        self.white_king = (x, y)

    elif copy_board[x][y] == "k_b":
        self.black_king = (new_x, new_y)
        copy_board[new_x][new_y] = copy_board[x][y]
        copy_board[x][y] = " "
        self.in_check(colour, copy_board)
        self.black_king = (x, y)

    else:
        copy_board[new_x][new_y] = copy_board[x][y]
        copy_board[x][y] = " "
        self.in_check(colour, copy_board)


    if colour == "_w" and self.white_check:
        return False

    if colour == "_b" and self.black_check:
        return False

    return True

为了确定一方是否处于检查状态,我会生成对手一方的每一步棋,并检查他们是否能够在下一步棋中捕获国王。 (这是不好的部分)

  • sq[1:] 只是确定当前方块的颜色

  • self.(color).king 是国王当前的位置

  • move 是一个元组,包含每次移动结束方块的坐标

     def in_check(self, colour, board):
    
     self.white_check = False
     self.black_check = False
     for x, line in enumerate(board):
         for y, sq in enumerate(line):
             if sq[1:] == "_w":
                 for (move, _, _) in self.get_all_moves(board, (x, y)):
                     if move == self.black_king:
                         self.black_check = True
    
             if sq[1:] == "_b":
                 for (move, _, _) in self.get_all_moves(board, (x, y)):
                     if move == self.white_king:
                         self.white_check = True
    

这是迄今为止我的引擎中最昂贵的操作,我想知道是否可以以某种方式简化它。任何感兴趣的人都可以使用此文件计算伪合法移动。为了完成所有动作,过路、施法和升级是单独生成的。我还在每次执行的移动后生成每边可能的合法移动的列表,但由于检查检测使用潜在的移动,因此无法使用这些列表。

    class Rook:
    def __init__(self, pos, brd):
        self.board = brd
        self.pos = pos

    def moves(self):
        pos_caps = []
        (x, y) = self.pos
        clr = self.board[x][y][1:]
        for i in range(- 1, - y - 1, -1):
            if self.board[x][y + i][1:] != clr:  
                pos_caps.append((x, y + i))
                for v in range(- 1, i, - 1):
                    if self.board[x][y + v] != " ":
                        pos_caps.remove((x, y + i))
                        break

        for i in range(1, 8 - y):
            if self.board[x][y + i][1:] != clr:  
                pos_caps.append((x, y + i))
                for v in range(1, i):
                    if self.board[x][y + v] != " ":
                        pos_caps.remove((x, y + i))
                        break

        for i in range(- 1, - x - 1, -1):
            if self.board[x + i][y][1:] != clr:  
                pos_caps.append((x + i, y))
                for v in range(- 1, i, - 1):
                    if self.board[x + v][y] != " ":
                        pos_caps.remove((x + i, y))
                        break

        for i in range(1, 8 - x):
            if self.board[x + i][y][1:] != clr:  
                pos_caps.append((x + i, y))
                for v in range(1, i):
                    if self.board[x + v][y] != " ":
                        pos_caps.remove((x + i, y))
                        break

        return pos_caps


class Knight:
    def __init__(self, pos, brd):
        self.board = brd
        self.pos = pos
        (self.x_pos, self.y_pos) = self.pos
        self.clr = self.board[self.x_pos][self.y_pos][1:]

    def moves(self):
        pos_moves = []
        (x, y) = self.pos
        if x < 6 and y < 7:
            pos_moves.append((x + 2, y + 1))
        if x < 6 and y > 0:
            pos_moves.append((x + 2, y - 1))
        if x > 1 and y < 7:
            pos_moves.append((x - 2, y + 1))
        if x > 1 and y > 0:
            pos_moves.append((x - 2, y - 1))
        if x < 7 and y < 6:
            pos_moves.append((x + 1, y + 2))
        if x < 7 and y > 1:
            pos_moves.append((x + 1, y - 2))
        if x > 0 and y < 6:
            pos_moves.append((x - 1, y + 2))
        if x > 0 and y > 1:
            pos_moves.append((x - 1, y - 2))
            
        for mv in reversed(pos_moves):
            (x, y) = mv
            if self.board[x][y][1:] == self.clr:
                pos_moves.remove(mv)

        return pos_moves


class King:
    def __init__(self, pos, brd):
        self.board = brd
        self.pos = pos
        (self.x_pos, self.y_pos) = self.pos
        self.clr = self.board[self.x_pos][self.y_pos][1:]

    def moves(self):
        all_moves = []
        (x, y) = self.pos
        if x > 0:
            all_moves.append((x - 1, y))
            if y > 0:
                all_moves.append((x - 1, y - 1))
            if y < 7:
                all_moves.append((x - 1, y + 1))

        if x < 7:
            all_moves.append((x + 1, y))
            if y > 0:
                all_moves.append((x + 1, y - 1))
            if y < 7:
                all_moves.append((x + 1, y + 1))

        if y > 0:
            all_moves.append((x, y - 1))

        if y < 7:
            all_moves.append((x, y + 1))

        for mv in reversed(all_moves):
            (x, y) = mv
            if self.board[x][y][1:] == self.clr:
                all_moves.remove(mv)

        return all_moves


class Queen:
    def __init__(self, pos, brd):
        self.board = brd
        self.pos = pos
        (self.x_pos, self.y_pos) = self.pos
        self.clr = self.board[self.x_pos][self.y_pos][1:]

    def moves(self):
        pos_caps = []
        (x, y) = self.pos
        clr = self.board[x][y][1:]
        for i in range(- 1, - y - 1, -1):
            if self.board[x][y + i][1:] != clr:   
                pos_caps.append((x, y + i))
                for v in range(- 1, i, - 1):
                    if self.board[x][y + v] != " ":
                        pos_caps.remove((x, y + i))
                        break

        for i in range(1, 8 - y):
            if self.board[x][y + i][1:] != clr:   
                pos_caps.append((x, y + i))
                for v in range(1, i):
                    if self.board[x][y + v] != " ":
                        pos_caps.remove((x, y + i))
                        break

        for i in range(- 1, - x - 1, -1):
            if self.board[x + i][y][1:] != clr:   
                pos_caps.append((x + i, y))
                for v in range(- 1, i, - 1):
                    if self.board[x + v][y] != " ":
                        pos_caps.remove((x + i, y))
                        break

        for i in range(1, 8 - x):
            if self.board[x + i][y][1:] != clr:  
                pos_caps.append((x + i, y))
                for v in range(1, i):
                    if self.board[x + v][y] != " ":
                        pos_caps.remove((x + i, y))
                        break

        com = min(x, y)
        for i in range(1, com + 1):
            if self.board[x - i][y - i][1:] != clr:
                pos_caps.append((x - i, y - i))
                for v in range(1, i):
                    if self.board[x - v][y - v] != " ":
                        pos_caps.remove((x - i, y - i))
                        break

        com = min(7 - x, 7 - y)
        for i in range(1, com + 1):
            if self.board[x + i][y + i][1:] != clr:
                pos_caps.append((x + i, y + i))
                for v in range(1, i):
                    if self.board[x + v][y + v] != " ":
                        pos_caps.remove((x + i, y + i))
                        break

        com = min(7 - x, y)
        for i in range(1, com + 1):
            if self.board[x + i][y - i][1:] != clr:
                # print(str((x + i, y - i)) + "Appending")
                pos_caps.append((x + i, y - i))
                for v in range(1, i):
                    if self.board[x + v][y - v] != " ":
                        # print(str((x + i, y - i)) + "Removing")
                        pos_caps.remove((x + i, y - i))
                        break

        com = min(x, 7 - y)
        for i in range(1, com + 1):
            if self.board[x - i][y + i][1:] != clr:
                pos_caps.append((x - i, y + i))
                for v in range(1, i):
                    if self.board[x - v][y + v] != " ":
                        pos_caps.remove((x - i, y + i))
                        break

        return pos_caps


class Pawn_white:
    def __init__(self, pos, brd):
        self.board = brd
        self.pos = pos
        (self.x_pos, self.y_pos) = self.pos
        self.clr = "_w"

    def moves(self):        
        all_moves = []
        (x, y) = self.pos
        if y > 0:
            if y == 6:
                all_moves.append((x, y - 1))
                all_moves.append((x, y - 2))

            else:
                all_moves.append((x, y - 1))

            if x > 0:
                if self.board[x - 1][y - 1][1:] != self.clr:
                    all_moves.append((x - 1, y - 1))
            if x < 7:
                if self.board[x + 1][y - 1][1:] != self.clr:
                    all_moves.append((x + 1, y - 1))

        for mv in reversed(all_moves):
            (x, y) = mv
            if self.board[x][y][1:] == self.clr:
                all_moves.remove(mv)

        return all_moves


class Pawn_black:
    def __init__(self, pos, brd):
        self.board = brd
        self.pos = pos
        (self.x_pos, self.y_pos) = self.pos
        self.clr = "_b"

    def moves(self):
        all_moves = []
        (x, y) = self.pos

        if y == 1:
            all_moves.append((x, y + 1))
            all_moves.append((x, y + 2))

        elif y < 7:
            all_moves.append((x, y + 1))

            if x > 0:
                if self.board[x - 1][y + 1] != self.clr:
                    all_moves.append((x - 1, y + 1))
            if x < 7:
                if self.board[x + 1][y + 1] != self.clr:
                    all_moves.append((x + 1, y + 1))
                    
        for mv in reversed(all_moves):
            (x, y) = mv
            if self.board[x][y][1:] == self.clr:
                all_moves.remove(mv)

        return all_moves


class Bishop:
    def __init__(self, pos, brd):
        self.board = brd
        self.pos = pos

    def moves(self):
        pos_caps = []
        (x, y) = self.pos
        clr = self.board[x][y][1:]

        com = min(x, y)
        for i in range(1, com + 1):
            if self.board[x - i][y - i][1:] != clr:
                pos_caps.append((x - i, y - i))
                for v in range(1, i):
                    if self.board[x - v][y - v] != " ":
                        pos_caps.remove((x - i, y - i))
                        break

        com = min(7 - x, 7 - y)
        for i in range(1, com + 1):
            if self.board[x + i][y + i][1:] != clr:
                pos_caps.append((x + i, y + i))
                for v in range(1, i):
                    if self.board[x + v][y + v] != " ":
                        pos_caps.remove((x + i, y + i))
                        break

        com = min(7 - x, y)
        for i in range(1, com + 1):
            if self.board[x + i][y - i][1:] != clr:
                pos_caps.append((x + i, y - i))
                for v in range(1, i):
                    if self.board[x + v][y - v] != " ":
                        pos_caps.remove((x + i, y - i))
                        break

        com = min(x, 7 - y)
        for i in range(1, com + 1):
            if self.board[x - i][y + i][1:] != clr:
                pos_caps.append((x - i, y + i))
                for v in range(1, i):
                    if self.board[x - v][y + v] != " ":
                        pos_caps.remove((x - i, y + i))
                        break

        return pos_caps

我希望我已经清楚地说明了我的问题/代码。任何帮助表示赞赏。


对于预先计算的数据结构还有很多工作要做。例如,您可以准备一个字典,其中包含每种工件类型和方向的任何位置的可能目的地。这样,您就不需要复杂的代码来检查可用的移动。

[有关合并和调整后的代码,请参阅我的第二个答案]

您还可以使用它来执行第一次验证以进行检查!。如果是另一颗棋子,您可以通过检查国王可以到达的位置来做到这一点。例如,如果您发现车处于可以从王位置移动的位置,那么就有可能进行过牌!对每种棋子类型执行此操作将使您知道是否有必要评估实际移动。

from collections import defaultdict
targets   = dict()
positions = [ (r,c) for r in range(8) for c in range(8) ]
def valid(positions): 
    return [(r,c) for r,c in positions if r in range(8) and c in range(8)]

从基本轨迹开始......

targets["up"]    = { (r,c):valid( (r+v,c) for v in range(1,8))
                           for r,c in positions }
targets["down"]  = { (r,c):valid( (r-v,c) for v in range(1,8))
                           for r,c in positions }
targets["vertical"]  = { (r,c):targets["up"][r,c]+targets["down"][r,c]
                           for r,c in positions }

targets["left"]  = { (r,c):valid( (r,c+h) for h in range(1,8))
                           for r,c in positions }
targets["right"] = { (r,c):valid( (r,c+h) for h in range(1,8))
                           for r,c in positions }
targets["horizontal"] = { (r,c):targets["left"][r,c]+targets["right"][r,c]
                           for r,c in positions }

targets["upleft"]  = { (r,c):[(ru,cl) for (ru,_),(_,cl) in zip(targets["up"][r,c],targets["left"][r,c])]
                           for r,c in positions }

targets["upright"] = { (r,c):[(ru,cr) for (ru,_),(_,cr) in zip(targets["up"][r,c],targets["right"][r,c])]
                           for r,c in positions }

targets["downleft"] = { (r,c):[(rd,cl) for (rd,_),(_,cl) in zip(targets["down"][r,c],targets["left"][r,c])]
                           for r,c in positions }

targets["downright"] = { (r,c):[(rd,cr) for (rd,_),(_,cr) in zip(targets["down"][r,c],targets["right"][r,c])]
                           for r,c in positions }

targets["diagUL"] = { (r,c):targets["upleft"][r,c]+targets["downright"][r,c]
                           for r,c in positions }
targets["diagDL"] = { (r,c):targets["downleft"][r,c]+targets["upright"][r,c]
                           for r,c in positions }

然后将它们组合成每种类型......

targets["king"]    = { (r,c):valid( (r+v,c+h) for v in (-1,0,1) for h in (-1,0,1) if v or h)
                           for r,c in positions }
targets["rook"]    = { (r,c):targets["horizontal"][r,c]+targets["vertical"][r,c]
                           for r,c in positions }
targets["bishop"]  = { (r,c):targets["diagUL"][r,c]+targets["diagDL"][r,c]
                           for r,c in positions }
targets["queen"]   = { (r,c):targets["rook"][r,c]+targets["bishop"][r,c]
                           for r,c in positions }
targets["knight"]  = { (r,c):valid((r+v,c+h) for v,h in [(2,1),(2,-1),(1,2),(1,-2),(-2,1),(-2,-1),(-1,2),(-1,-2)])
                           for r,c in positions } 
targets["wpawn"]   = { (r,c):valid([(r+1,c)]*(r>0) + [(r+2,c)]*(r==1))
                           for r,c in positions }
targets["bpawn"]   = { (r,c):valid([(r-1,c)]*(r<7) + [(r-2,c)]*(r==6))
                           for r,c in positions }
targets["wptake"]  = { (r,c):valid([(r+1,c+1),(r+1,c-1)]*(r>0))
                           for r,c in positions }
targets["bptake"]  = { (r,c):valid([(r-1,c+1),(r-1,c-1)]*(r<7))
                           for r,c in positions }
targets["wcastle"] = defaultdict(list,{ (0,4):[(0,2),(0,6)] })
targets["bcastle"] = defaultdict(list,{ (7,4):[(7,2),(7,6)] }) 

这将允许您直接获取棋盘上任何位置的任何棋子的潜在移动位置列表。

例如:

 targets["bishop"][5,4]
 # [(6, 3), (7, 2), (4, 5), (3, 6), (2, 7), (4, 3), (3, 2), (2, 1), (1, 0), (6, 5), (7, 6)]

要了解白王在 5,4 处是否有潜在的检查,您可以在进入移动模拟之前执行快速验证:

 kingPos = (5,4)
 checkByQueen  = any(board[r][c]=="q_b" for r,c in targets["queen"][kingPos])
 checkByKnight = any(board[r][c]=="n_b" for r,c in targets["knight"][kingPos])
 checkByRook   = any(board[r][c]=="r_b" for r,c in targets["rook"][kingPos])
 checkByBishop = any(board[r][c]=="b_b" for r,c in targets["bishop"][kingPos])
 checkByPawn   = any(board[r][c]=="p_b" for r,c in targets["wptake"][kingPos])

如果这些都不是真的,那么对白王就没有威胁。如果 checkByQueen、checkByRook 或 checkByBishop 为 True,那么您需要验证中间另一块的遮挡,但这已经大大减少了案例数量。

您还可以增强字典,使用位置作为键(而不是字符串)为您提供棋盘上两个方块之间的位置。

for r,c in positions:
    targets[(r,c)] = defaultdict(list)
    for direction in ("up","down","left","right","upleft","upright","downleft","downright"):
        path = targets[direction][r,c]
        for i,(tr,tc) in enumerate(path):
            targets[(r,c)][tr,tc]=path[:i]

这将使您可以轻松检查两个位置之间是否有一块。例如,如果您在 (5,0) 处找到皇后,您可以使用以下命令检查国王是否在视线范围内:

queenPos = next((r,c) for r,c in targets["queen"][kingPos] 
                      if board[r][c]=="q_b") # (5,0)

targets[kingPos][queenPos] # [(5, 3), (5, 2), (5, 1)]

lineOfSight = all(board[r][c]=="" for r,c in targets[kingPos][queenPos])

这可以结合以上条件来综合验证:

def lineOfSight(A,B): 
    return all(board[r][c]=="" for r,c in targets[A][B])

checkByQueen  = any(board[r][c]=="q_b" and lineOfSight(kingPos,(r,c))
                    for r,c in targets["queen"][kingPos] )
checkByRook   = any(board[r][c]=="r_b" and lineOfSight(kingPos,(r,c))
                    for r,c in targets["rook"][kingPos]  )
checkByBishop = any(board[r][c]=="b_b" and lineOfSight(kingPos,(r,c))
                    for r,c in targets["bishop"][kingPos])

使用所有这些,您根本不需要模拟移动来检测检查!,您可以在一行中完成:

isCheck = any( board[r][c]==opponent and lineOfSight(kingPos,(r,c))
               for opponent,piece in [("q_b","queen"),("r_b","rook"),("b_b","bishop"),("n_b","knight"),("p_b","wptake")]
               for r,c in target[piece][kingPos] )    
  

样本内容:

for r,c in positions:
    print("FROM",(r,c))
    for piece in targets:
        print(f"  {piece:10}:",*targets[piece][r,c])

...

FROM (2, 4)
  up        : (3, 4) (4, 4) (5, 4) (6, 4) (7, 4)
  down      : (1, 4) (0, 4)
  vertical  : (3, 4) (4, 4) (5, 4) (6, 4) (7, 4) (1, 4) (0, 4)
  left      : (2, 3) (2, 2) (2, 1) (2, 0)
  right     : (2, 5) (2, 6) (2, 7)
  horizontal: (2, 3) (2, 2) (2, 1) (2, 0) (2, 5) (2, 6) (2, 7)
  upleft    : (3, 3) (4, 2) (5, 1) (6, 0)
  upright   : (3, 5) (4, 6) (5, 7)
  downleft  : (1, 3) (0, 2)
  downright : (1, 5) (0, 6)
  diagUL    : (3, 3) (4, 2) (5, 1) (6, 0) (1, 5) (0, 6)
  diagDL    : (1, 3) (0, 2) (3, 5) (4, 6) (5, 7)
  king      : (1, 4) (1, 5) (2, 3) (2, 5) (3, 3) (3, 4)
  rook      : (2, 3) (2, 2) (2, 1) (2, 0) (2, 5) (2, 6) (2, 7) (3, 4) (4, 4) (5, 4) (6, 4) (7, 4) (1, 4) (0, 4)
  bishop    : (3, 3) (4, 2) (5, 1) (6, 0) (1, 5) (0, 6) (1, 3) (0, 2) (3, 5) (4, 6) (5, 7)
  queen     : (2, 3) (2, 2) (2, 1) (2, 0) (2, 5) (2, 6) (2, 7) (3, 4) (4, 4) (5, 4) (6, 4) (7, 4) (1, 4) (0, 4) (3, 3) (4, 2) (5, 1) (6, 0) (1, 5) (0, 6) (1, 3) (0, 2) (3, 5) (4, 6) (5, 7)
  wpawn     : (3, 4)
  bpawn     : (1, 4)
  wptake    : (3, 5) (3, 3)
  bptake    : (1, 5) (1, 3)
  knight    : (4, 5) (4, 3) (3, 6) (3, 2) (0, 5) (0, 3) (1, 6) (1, 2)    
...

[EDIT]

要利用它来生成移动,您仍然需要添加一些条件,但我相信字典应该使逻辑更简单、更快:

# add to setup ...
targets["bishop"]["paths"] = ["upleft","upright","downleft","downright"]
targets["rook"]["paths"]   = ["up","down","left","right"]
targets["queen"]["paths"]  = targets["bishop"]["paths"]+targets["rook"]["paths"]

def linearMoves(position,opponent,piece):
    if position in pinnedPositions: return # see below
    for direction in targets[piece]["paths"]
        for r,c in targets[direction][position]:
              if board[r][c]=="": yield (position,(r,c)); continue
              if board[r][c].endswith(opponent): yield(position,(r,c))
              break

...初始化移动生成周期

# flag white pieces that are pinned 
# (do this before each move generation)

pinnedPositions = set()
for piece,path in [("q_b","queen"),("r_b","rook"),("b_b","bishop"):
    for T in targets[path][kingPos]:
        if board[T] != piece: continue
        pinned = [[board[r][c][-1:] for r,c in targets[T][kingPos]]
        if pinned.count("w")==1 and "b" not in pinned:
            pinnedPositions.add(targets[T][kingPos][pinned.index("w")])

...对于棋盘上的每个棋子...

moves = []
# Move white bishop from position bishosPos ...
moves += linearMoves(bishopPos,"b","bishop")

# Move white rook from position rookPos ...
moves += linearMoves(rookPos,"b","rook")

# Move white queen from position queenPos ...
moves += linearMoves(queenPos,"b","queen")

# Move white knight from position knightPos ...
moves += ( (knightPos,(r,c)) for r,c in targets["knight"][knightPos]
           if board[r][c][-1:]!="w" )    

# Move white pawn from position pawnPos ...
moves += ( (pawnPos,(r,c)) for r,c in targets["wpawn"][pawnPos]
           if board[r][c][-1:]=="" and lineOfSight(pawnPos,(r,c)) )    
moves += ( (pawnPos,(r,c)) for r,c in targets["wptake"][pawnPos]
           if board[r][c][-1:]=="b" )    

# Move white king from position kingPos ... 
# (need to filter this so king doesn't place itself in check!)
moves += ( (kingPos,(r,c)) for r,c in targets["king"][kingPos]
           if board[r][c][-1]!="w" )    

      

还有更多例外需要管理,例如“castling”和“en passant”,但大多数代码应该更简单(并且可能更快)。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

更有效地检测检查(国际象棋) 的相关文章

随机推荐

  • 重叠图像与图像贴图相互遮挡

    信息 图像具有大的透明部分 因此每个图像都必须重叠才能创建所需的效果 具体来说 每个图像的可点击部分都是奇怪的梯形形状 意味着相互挤压 图像的图像映射的大部分与其他附近 梯形 图像的透明部分重叠 我不认为 z 索引的任何改变能解决这个问题
  • Git 标签发布版本?

    预发布版本可以通过紧跟在补丁版本后面附加破折号和一系列点分隔的标识符来表示 示例 1 0 0 alpha 1 0 0 alpha 1 1 0 0 0 3 7 1 0 0 x 7 z 92 semver org http semver org
  • 仅提交存储库根目录上的属性更改,而不是文件

    我有一个 SVN 存储库 其中包含未提交的文件更改 根文件夹上的 svn externals 属性也发生了变化 如何提交属性更改 而不提交对文件本身的更改 为了仅提交在命令行上指定的显式路径 请使用 depth empty选项例如在具有新修
  • Django 按两个字段对项目进行排序,但如果它们为零则忽略它们

    我有以下模型 为了解决这个问题而大大简化 class Product models Model price models DecimalField max digits 8 decimal places 2 sale price model
  • WindowBuilder 无法显示 GUI。无法加载组件 javax.swing.JFrame 的 *.wbp-component.xml 描述

    我使用的是 Eclipse 2021 9 版本 并且已经安装了 windowbuilder 当我单击设计器选项卡时会发生此错误 有谁能够帮助我 我遇到了同样的问题 我刚刚更新了 WindowBuilder Nightly Build 1 9
  • 如何在SASS中将整数转换为十六进制

    代替类似的东西地图数据结构 http chriseppstein github ioChris Eppstein 提到 SASS 正在进行的工作 我正在尝试实现类似的目标 将字符串映射到相应的十六进制值 该值将用于指定 CSS 的 unic
  • 如何在 Spring Boot 2.0 中注册自定义环境后处理器?

    我按照这个中的确切步骤进行操作文档 https docs spring io spring boot docs 1 5 x SNAPSHOT reference htmlsingle boot features application ev
  • IE8 中的 Jquery 问题

    Jquery 在 Safari 和 Firefox 中运行良好 在 IE8 中 使用开发人员工具 我收到错误 无法获取位置属性 无效参数 jquery 1 3 2 js 第 12 行字符 12949 通过调试 脚本突出显示字符 J G K
  • Kubernetes 配置:在代码存储库上与在 helm 图表存储库上

    Helm 被宣传为 管理 k8s 上应用程序部署的方式 我们的微服务具有代码存储库和可部署的 1 对 1 映射 我发现将 k8s 配置映射与代码一起使用要方便得多 以便它们一起发展 例如为功能标志添加新的环境变量时 然而 我们维护的是一个
  • Asp.net Core 自定义过滤器实现 IActionModelConvention 和 IFilterFactory

    我需要创建一个实现两者的自定义操作过滤器IActionModelConvention and IFilterFactory I use IActionModelConvention用于同时设置多条路线 我使用IFilterFactory注入
  • Java中忽略大小写

    我想知道如何使用户输入的任何内容在我的方法中忽略大小写 public static void findPatient if myPatientList getNumPatients 0 System out println No patie
  • 需要使用 Android 模拟器进行身份验证的代理

    有没有人设法让 Android 模拟器在需要身份验证的代理后面工作 我尝试将 http proxy 参数设置为 http DOMAIN USERNAME PASSWORD IP PORT 但我没有成功 我尝试按照文档进行操作 但没有成功 我
  • docker image ubuntu:16.04 似乎省略了 logrotate 的一些文件

    我根据以下内容构建了一个图像ubuntu 16 04 在构建图像时 我确实运行了一些命令 包括apt get y update 然后 我浏览图像docker run it myimage bash我发现有一些遗漏的文件logrotate在那
  • 使用 open cv Mat::at 时出现段错误

    我试图用一些值填充 opencv 矩阵 但我不断出现段错误 代码如下 Mat mask gx in window size in window size image type for int i 0 i lt in window size
  • Linux下多线程进程的信号SIGTERM处理

    我在Linux下调试一个多线程进程的信号处理时 发现了一种奇怪的现象 这个问题的一句话是 SIGTERM handler为空并且已成功注册到系统 但进程启动时仍可能被SIGTERM杀死 详细说明如下 该进程由父进程派生 并由execve 处
  • 同步两个ListView位置

    我有两个列表视图 当我滚动任何一个列表时 有什么方法可以同步 ListViews 的位置 实施一个AbsListView OnScrollListener http developer android com reference andro
  • Azure Web App:发布前删除所有文件

    使用以下 Powershell 脚本发布到 Azure Web App 时 我们经常会遇到问题 即先前发布的文件会导致运行时错误 param websiteName packOutput website Get AzureWebsite N
  • xunit 扩展/行测试发生了什么?

    在 NUnit 2 4 7 中 包含了 nunit framework extensions dll 这使得可以进行 RowTests 下载最新版本 2 5 8 时我找不到它 这是怎么回事 而不是使用RowTest 您可以使用TestCas
  • Solr/Lucene 是否可以先按相关性排序,然后再按第二个属性排序?

    在 Solr Lucene 中 是否可以首先按相关性排序 然后再按第二个属性排序 据我所知 如果我设置了排序参数 它会完全覆盖相关性 并按排序参数进行排序 我如何才能首先按相关性对结果进行排序 然后在两个具有完全相同相关性的条目的情况下 对
  • 更有效地检测检查(国际象棋)

    我目前正在开发一个国际象棋引擎 该引擎到目前为止正在运行 但需要很长时间才能生成棋步 由于必须生成许多移动 因此检查检测花费的时间是迄今为止最长的 在尝试了很多事情之后我陷入了困境 并且无法真正弄清楚如何提高效率 我是这样做的 为了检查移动