Beispiel #1
0
def kingCanMooveIfCheck(board, isFinish, kingsMooves, player):
    global moovesCheck

    for i in kingsMooves:
        array = getArrayBoard.squareToArray(i[0], int(i[1]))
        array2 = getArrayBoard.squareToArray(i[3], int(i[4]))
        pieceTmp = board[int(array2[1])][int(array2[0])]
        if player == "WHITE":
            board[int(array2[1])][int(array2[0])] = "r"
        else:
            board[int(array2[1])][int(array2[0])] = "R"
        board[int(array[1])][int(array[0])] = "."
        if player == "WHITE":
            enemyMooves = possibleMooves(board, "BLACK", True)
        else:
            enemyMooves = possibleMooves(board, "WHITE", True)
        tmp = 0
        for j in enemyMooves:
            if j[3] == i[3] and j[4] == i[4]:
                tmp = 1
        if tmp == 0:
            isFinish = 0
            moovesCheck.append(i)
        board[int(array2[1])][int(array2[0])] = pieceTmp
        if player == "WHITE":
            board[int(array[1])][int(array[0])] = "r"
        else:
            board[int(array[1])][int(array[0])] = "R"
    return isFinish
Beispiel #2
0
def movePieceAndGetNewBoard(tmpBoard, move):
    array = gab.squareToArray(move[0], int(move[1]))
    array2 = gab.squareToArray(move[3], int(move[4]))
    # pieceEat = board[int(array2[1])][int(array2[0])]

    tmpBoard[int(array2[1])][int(array2[0])] = tmpBoard[int(array[1])][int(array[0])]
    tmpBoard[int(array[1])][int(array[0])] = "."

    return tmpBoard
Beispiel #3
0
def removeImpossibleMoves(myMooves, board, player):
    index = 0
    myMoovesFilter = []
    for i in myMooves:
        array = getArrayBoard.squareToArray(i[0], int(i[1]))
        array2 = getArrayBoard.squareToArray(i[3], int(i[4]))
        myPiece = board[int(array[1])][int(array[0])]
        enemyPiece = board[int(array2[1])][int(array2[0])]

        board[int(array[1])][int(array[0])] = "."
        board[int(array2[1])][int(array2[0])] = myPiece
        end = isEnd(board, player)
        if end != 2 and end != 3:
            myMoovesFilter.append(i)
        board[int(array[1])][int(array[0])] = myPiece
        board[int(array2[1])][int(array2[0])] = enemyPiece
        index += 1
    return myMoovesFilter
Beispiel #4
0
def addComeback(move, player, board):
    array2 = gab.squareToArray(move[0], int(move[1]))

    piece = board[int(array2[1])][int(array2[0])]

    if move[1] == "7" and move[3] == "8" and player == "WHITE" and piece == "p":
        move += "d"
    if move[1] == "2" and move[3] == "1" and player == "BLACK" and piece == "P":
        move += "d"
    return move