Prevented loading of empty or undersized PolyGlot book files by releasing buffers, keeping the feature disabled, and reporting an informative message to UCI clients.
Added a guard in find_first_key to stop early when no book entries are available, avoiding null dereferences.
Introduced an interactive regression test that creates an empty .bin book, loads it through the UCI option, and verifies the engine still produces a mov.
Updated PolyBook::probe to skip invalid Polyglot moves, recompute weighted candidates using only valid entries, and avoid invoking check_draw on illegal moves.
Added regression coverage in tests/instrumented.py that builds an artificial book containing an invalid move, ensures the engine falls back to a legal book move, and adjusted imports accordingly.