예제 #1
0
    def evolution2(self, board, player):
        wmobility = bmobility = piecescore = 0
        if (self.b.playercolor == "white"):
            if (player > 0):
                pawn_move = -1
            else:
                pawn_move = 1
        else:
            if (player < 0):
                pawn_move = 1
            else:
                pawn_move = -1

        MD = PA = MT = 0
        for i in range(8):
            for j in range(8):
                if (board[i][j] > 0):
                    MD += PieceMap.getPoints(board[i][j])
                    MT += PieceMap.getPoints(board[i][j])
                elif (board[i][j] < 0):
                    MD -= PieceMap.getPoints(board[i][j])
                    MT += PieceMap.getPoints(board[i][j])
                if (board[i][j] * player < 0 and abs(board[i][j]) == 6):
                    PA += 1

                if (player > 0):
                    f = PieceMap.getFun(board[i][j])
                    moves = []
                    if (abs(board[i][j]) == 6):
                        moves = f([i, j], board, pawn_move)
                    elif (abs(board[i][j] != 0)):
                        moves = f([i, j], board)
                    wmobility += len(moves)
                else:
                    f = PieceMap.getFun(board[i][j])
                    moves = []
                    if (abs(board[i][j]) == 6):
                        moves = f([i, j], board, pawn_move)
                    elif (abs(board[i][j]) != 0):
                        moves = f([i, j], board)
                    bmobility += len(moves)

                if (board[i][j] * player > 0):
                    piecescore += PieceMap.getPieceScore(
                        board[i][j], i, j, player)
        MD = abs(MD)

        MS = min(24000, MD) + ((MD * PA * (80000 - MT)) / (64000 * (PA + 1)))
        materialscore = min(31000, MS)
        mobilityscore = 0.1 * (wmobility - bmobility) * player

        return (materialscore + mobilityscore) * player
예제 #2
0
    def evolution3(self, board, player):
        materialscore = wmobility = bmobility = piecescore = 0
        if (self.b.playercolor == "white"):
            if (player > 0):
                pawn_move = -1
            else:
                pawn_move = 1
        else:
            if (player < 0):
                pawn_move = 1
            else:
                pawn_move = -1

        for i in range(8):
            for j in range(8):
                if (player > 0):
                    if (board[i][j] > 0):
                        materialscore += PieceMap.getPoints(board[i][j])
                    elif (board[i][j] < 0):
                        materialscore -= PieceMap.getPoints(board[i][j])
                    f = PieceMap.getFun(board[i][j])
                    moves = []
                    if (abs(board[i][j]) == 6):
                        moves = f([i, j], board, pawn_move)
                    elif (abs(board[i][j] != 0)):
                        moves = f([i, j], board)
                    wmobility += len(moves)
                else:
                    if (board[i][j] > 0):
                        materialscore -= PieceMap.getPoints(board[i][j])
                    elif (board[i][j] < 0):
                        materialscore += PieceMap.getPoints(board[i][j])
                    f = PieceMap.getFun(board[i][j])
                    moves = []
                    if (abs(board[i][j]) == 6):
                        moves = f([i, j], board, pawn_move)
                    elif (abs(board[i][j]) != 0):
                        moves = f([i, j], board)
                    bmobility += len(moves)

                if (board[i][j] * player > 0):
                    piecescore += PieceMap.getPieceScore(
                        board[i][j], i, j, player)

        mobilityscore = 0.1 * (wmobility - bmobility) * player

        return (materialscore + mobilityscore + piecescore) * player