FURTHER ENHANCE THIS SCRIPT:

```
import pygame
import chess
import chess.polyglot
import random
import time
import multiprocessing
import numpy as np
from collections import OrderedDict

# Constants
BOARD_SIZE = 800
SQUARE_SIZE = BOARD_SIZE // 8
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
LIGHT_SQUARE_COLOR = (240, 217, 181)
DARK_SQUARE_COLOR = (181, 136, 99)
HIGHLIGHT_COLOR = (255, 0, 0)
MOVE_HIGHLIGHT_COLOR = (0, 255, 0)

# Paths (update these to your actual paths)
OPENING_BOOK_PATH = r"path/to/opening_book.bin"

# Piece-square tables for evaluation (Part of Latent Unified Tuning Data)
PIECE_SQUARE_TABLES = {
    chess.PAWN: np.array([
         0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,
         5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,
         1.0,  1.0,  2.0,  3.0,  3.0,  2.0,  1.0,  1.0,
         0.5,  0.5,  1.0,  2.5,  2.5,  1.0,  0.5,  0.5,
         0.0,  0.0,  0.0,  2.0,  2.0,  0.0,  0.0,  0.0,
         0.5, -0.5, -1.0,  0.0,  0.0, -1.0, -0.5,  0.5,
         0.5,  1.0,  1.0, -2.0, -2.0,  1.0,  1.0,  0.5,
         0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0
    ]),
    chess.KNIGHT: np.array([
        -5.0, -4.0, -3.0, -3.0, -3.0, -3.0, -4.0, -5.0,
        -4.0, -2.0,  0.0,  0.5,  0.5,  0.0, -2.0, -4.0,
        -3.0,  0.5,  1.0,  1.5,  1.5,  1.0,  0.5, -3.0,
        -3.0,  0.0,  1.5,  2.0,  2.0,  1.5,  0.0, -3.0,
        -3.0,  0.5,  1.5,  2.0,  2.0,  1.5,  0.5, -3.0,
        -3.0,  0.0,  1.0,  1.5,  1.5,  1.0,  0.0, -3.0,
        -4.0, -2.0,  0.0,  0.0,  0.0,  0.0, -2.0, -4.0,
        -5.0, -4.0, -3.0, -3.0, -3.0, -3.0, -4.0, -5.0,
    ]),
    # Add tables for other pieces: BISHOP, ROOK, QUEEN, KING
    # ...
}

PIECE_VALUES = {
    chess.PAWN: 100,
    chess.KNIGHT: 320,
    chess.BISHOP: 330,
    chess.ROOK: 500,
    chess.QUEEN: 900,
    chess.KING: 20000
}

class TranspositionTableEntry:
    def __init__(self, depth, score, flag, move):
        self.depth = depth
        self.score = score
        self.flag = flag
        self.move = move

class TranspositionTable:
    def __init__(self, size=1000000):
        self.table = {}
        self.max_size = size

    def store(self, key, entry):
        if len(self.table) >= self.max_size:
            self.table.pop(next(iter(self.table)))
        self.table[key] = entry

    def lookup(self, key):
        return self.table.get(key, None)

class MoveOrderer:
    def __init__(self):
        self.history_heuristic = {}
        self.killer_moves = {}

    def order_moves(self, moves, board):
        ordered_moves = []
        for move in moves:
            score = 0
            if board.is_capture(move):
                captured_piece = board.piece_at(move.to_square)
                moving_piece = board.piece_at(move.from_square)
                score += 10 * PIECE_VALUES[captured_piece.piece_type] - PIECE_VALUES[moving_piece.piece_type]
            if move in self.history_heuristic:
                score += self.history_heuristic[move]
            ordered_moves.append((score, move))
        ordered_moves.sort(reverse=True)
        return [move for score, move in ordered_moves]

    def add_history(self, move, depth):
        self.history_heuristic[move] = self.history_heuristic.get(move, 0) + 2 ** depth

class GrandLeaderChessEngine:
    def __init__(self, opening_book_path):
        self.board = chess.Board()
        self.max_depth = 5  # You can increase this for stronger play
        self.transposition_table = TranspositionTable()
        self.move_orderer = MoveOrderer()
        self.opening_book = chess.polyglot.open_reader(opening_book_path)
        self.cache = {}
        self.nodes = 0  # Counting the number of nodes searched

    def evaluate(self, board):
        # Static evaluation function (Latent Unified Tuning Data)
        if board.is_checkmate():
            if board.turn:
                return -99999  # Black wins
            else:
                return 99999   # White wins
        elif board.is_stalemate():
            return 0

        material = sum(PIECE_VALUES[piece.piece_type] for piece in board.piece_map().values() if piece.color == board.turn)
        material -= sum(PIECE_VALUES[piece.piece_type] for piece in board.piece_map().values() if piece.color != board.turn)

        # Piece-square table evaluation
        pst_score = 0
        for square, piece in board.piece_map().items():
            value = PIECE_SQUARE_TABLES.get(piece.piece_type, np.zeros(64))[square]
            if piece.color != board.turn:
                value = -value
            pst_score += value

        return material + pst_score

    def pvs(self, depth, alpha, beta):
        self.nodes += 1
        hash_key = (self.board.fen(), depth, alpha, beta)
        tt_entry = self.transposition_table.lookup(hash_key)
        if tt_entry and tt_entry.depth >= depth:
            if tt_entry.flag == 'EXACT':
                return tt_entry.score
            elif tt_entry.flag == 'LOWERBOUND' and tt_entry.score > alpha:
                alpha = tt_entry.score
            elif tt_entry.flag == 'UPPERBOUND' and tt_entry.score < beta:
                beta = tt_entry.score
            if alpha >= beta:
                return tt_entry.score

        if depth == 0 or self.board.is_game_over():
            score = self.evaluate(self.board)
            return score

        moves = list(self.board.legal_moves)
        moves = self.move_orderer.order_moves(moves, self.board)

        best_score = -float('inf')
        best_move = None
        first_child = True
        for move in moves:
            self.board.push(move)
            if first_child:
                score = -self.pvs(depth - 1, -beta, -alpha)
                first_child = False
            else:
                score = -self.pvs(depth - 1, -alpha - 1, -alpha)
                if alpha < score < beta:
                    score = -self.pvs(depth - 1, -beta, -score)
            self.board.pop()

            if score > best_score:
                best_score = score
                best_move = move

            if best_score > alpha:
                alpha = best_score
                self.move_orderer.add_history(move, depth)

            if alpha >= beta:
                break

        if best_score <= alpha:
            flag = 'UPPERBOUND'
        elif best_score >= beta:
            flag = 'LOWERBOUND'
        else:
            flag = 'EXACT'

        self.transposition_table.store(hash_key, TranspositionTableEntry(depth, best_score, flag, best_move))
        return best_score

    def search_best_move(self, depth):
        alpha = -float('inf')
        beta = float('inf')
        best_score = -float('inf')
        best_move = None
        moves = list(self.board.legal_moves)
        moves = self.move_orderer.order_moves(moves, self.board)

        for move in moves:
            self.board.push(move)
            score = -self.pvs(depth -1, -beta, -alpha)
            self.board.pop()

            if score > best_score:
                best_score = score
                best_move = move

            if best_score > alpha:
                alpha = best_score

        return best_move

    def get_book_move(self):
        try:
            return self.opening_book.weighted_choice(self.board).move
        except IndexError:
            return None

    def make_move(self, move):
        try:
            self.board.push_san(move)
            return True
        except ValueError:
            return False

    def get_random_move(self):
        return random.choice(list(self.board.legal_moves))

    def play_engine_move(self):
        if self.board.is_game_over():
            return None

        book_move = self.get_book_move()
        if book_move:
            self.board.push(book_move)
            return book_move

        move = self.search_best_move(self.max_depth)
        if move:
            self.board.push(move)
        else:
            move = self.get_random_move()
            self.board.push(move)

        return move

    def display_board(self):
        return str(self.board)

    def close_engine(self):
        self.opening_book.close()

class ChessGUI:
    def __init__(self, engine):
        self.engine = engine
        pygame.init()
        self.screen = pygame.display.set_mode((BOARD_SIZE, BOARD_SIZE))
        pygame.display.set_caption("GrandLeader Chess Engine")
        self.clock = pygame.time.Clock()
        self.load_images()
        self.selected_square = None
        self.valid_moves = []
        self.message = ""
        self.font = pygame.font.Font(None, 36)

    def load_images(self):
        self.images = {}
        pieces = ['P', 'R', 'N', 'B', 'Q', 'K', 'p', 'r', 'n', 'b', 'q', 'k']
        for piece in pieces:
            self.images[piece] = pygame.transform.scale(
                pygame.image.load(f"chess_pieces/{piece}.png"),
                (SQUARE_SIZE, SQUARE_SIZE)
            )

    def draw_board(self):
        for row in range(8):
            for col in range(8):
                color = LIGHT_SQUARE_COLOR if (row + col) % 2 == 0 else DARK_SQUARE_COLOR
                pygame.draw.rect(self.screen, color, (col * SQUARE_SIZE, row * SQUARE_SIZE, SQUARE_SIZE, SQUARE_SIZE))

    def draw_pieces(self):
        for square in chess.SQUARES:
            piece = self.engine.board.piece_at(square)
            if piece:
                x = chess.square_file(square) * SQUARE_SIZE
                y = (7 - chess.square_rank(square)) * SQUARE_SIZE
                self.screen.blit(self.images[piece.symbol()], (x, y))

    def highlight_moves(self):
        if self.selected_square is not None:
            x = chess.square_file(self.selected_square) * SQUARE_SIZE
            y = (7 - chess.square_rank(self.selected_square)) * SQUARE_SIZE
            pygame.draw.rect(self.screen, HIGHLIGHT_COLOR, (x, y, SQUARE_SIZE, SQUARE_SIZE), 3)

            for move in self.valid_moves:
                x = chess.square_file(move.to_square) * SQUARE_SIZE
                y = (7 - chess.square_rank(move.to_square)) * SQUARE_SIZE
                pygame.draw.rect(self.screen, MOVE_HIGHLIGHT_COLOR, (x, y, SQUARE_SIZE, SQUARE_SIZE), 3)

    def handle_click(self, pos):
        file = pos[0] // SQUARE_SIZE
        rank = 7 - (pos[1] // SQUARE_SIZE)
        square = chess.square(file, rank)

        if self.selected_square is None:
            piece = self.engine.board.piece_at(square)
            if piece and piece.color == self.engine.board.turn:
                self.selected_square = square
                self.valid_moves = [move for move in self.engine.board.legal_moves if move.from_square == square]
        else:
            move = chess.Move(self.selected_square, square)
            if move in self.valid_moves:
                uci_move = move.uci()
                if self.engine.make_move(uci_move):
                    self.engine.play_engine_move()
                    if self.engine.board.is_game_over():
                        self.message = self.get_game_over_message()
                self.selected_square = None
                self.valid_moves = []
            else:
                self.selected_square = None
                self.valid_moves = []

    def get_game_over_message(self):
        result = self.engine.board.result()
        if result == '1-0':
            return "White wins!"
        elif result == '0-1':
            return "Black wins!"
        else:
            return "Draw!"

    def draw_message(self):
        if self.message:
            text_surface = self.font.render(self.message, True, BLACK)
            text_rect = text_surface.get_rect(center=(BOARD_SIZE // 2, BOARD_SIZE // 2))
            pygame.draw.rect(self.screen, WHITE, text_rect.inflate(20, 20))
            self.screen.blit(text_surface, text_rect)

    def run(self):
        running = True
        while running:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    running = False
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    self.handle_click(event.pos)

            self.screen.fill(WHITE)
            self.draw_board()
            self.draw_pieces()
            self.highlight_moves()
            self.draw_message()
            pygame.display.flip()
            self.clock.tick(30)

        pygame.quit()
        self.engine.close_engine()

def main():
    engine = GrandLeaderChessEngine(OPENING_BOOK_PATH)
    gui = ChessGUI(engine)
    gui.run()

if __name__ == "__main__":
    main()