allPieces = updateChessPieces() p.event.post(resolvedBoard) #prevPiece = selectedPiece #selectedPiece[2].position = hold #post selection else: selectedPiece[1][0] = px selectedPiece[1][1] = py selectedPiece = None if event.type == resolve: aiTurn = False if chessBoard.currentPlayer == "White": chessBoard.currentPlayer = "Black" chessBoard.prevBoard.currentPlayer = "White" aiTurn = True else: chessBoard.currentPlayer = "White" chessBoard.prevBoard.currentPlayer = "Black" chessBoard.moveCounter += 1 for piece in allPieces: if piece[2].color == chessBoard.currentPlayer and piece[ 2].toString().lower() == "k": friendlyKing = piece[2] # print("King Legal Moves:", friendlyKing.legalMoves(chessBoard)) if friendlyKing.inCheck(chessBoard): print("Check") if friendlyKing.inCheckmate(chessBoard):
newBoard.currentPlayer = "Black" newBoard.prevBoard.currentPlayer = "White" else: newBoard.currentPlayer = "White" newBoard.prevBoard.currentPlayer = "Black" return newBoard #testing # b = BoardEvaluator(b) b = Board() b.tiles[39] = (Tile(39, Queen("White", 39))) b.tiles[36] = (Tile(36, Pawn("Black", 36))) b.tiles[52] = (Tile(52, NullPiece())) b.tiles[53] = (Tile(53, NullPiece())) b.tiles[21] = (Tile(21, Knight("White", 21))) b.tiles[6] = (Tile(6, NullPiece())) b.currentPlayer = "Black" # newBoard.printBoard() #resultNode = Node(b, True) #a = getBestMove(resultNode, 1) #x = 0 #for node in nodes.keys(): #node.position.printBoard() #print(len(nodes)) #a[0].printBoard() #print(a[0].currentPlayer, a[0].moveCounter)