summaryrefslogtreecommitdiff
path: root/chess-uci.el
diff options
context:
space:
mode:
Diffstat (limited to 'chess-uci.el')
-rw-r--r--chess-uci.el36
1 files changed, 9 insertions, 27 deletions
diff --git a/chess-uci.el b/chess-uci.el
index e421f71..ff2ec51 100644
--- a/chess-uci.el
+++ b/chess-uci.el
@@ -34,24 +34,6 @@
"Customisations for Chess engines based on the UCI protocol"
:group 'chess)
-(defcustom chess-uci-polyglot-book-file nil
- "The path to a polyglot binary opening book file."
- :group 'chess-uci
- :type '(choice (const :tag "Not specified" nil) (file :must-match t)))
-
-(defcustom chess-uci-polyglot-book-strength 1.0
- "Influence random distribution when picking a ply from the book.
-A value above 1.0 means to prefer known good moves while a value below
-1.0 means to penalize known good moves. 0.0 will stop to consider
-move weights and simply pick a move at random. For simple
-reasons of numerical overflow, this should be strictly less than 4.0."
- :group 'chess-uci
- :type '(float :match (lambda (widget value) (and (>= value 0) (< value 4)))))
-
-(defvar chess-uci-book nil
- "A (polyglot) opening book object.
-See `chess-uci-polyglot-book-file' for details on how to enable this.")
-
(defvar chess-uci-long-algebraic-regexp "\\([a-h][1-8]\\)\\([a-h][1-8]\\)\\([nbrq]\\)?"
"A regular expression matching a UCI log algebraic move.")
@@ -118,10 +100,11 @@ If conversion fails, this function fired an 'illegal event."
(unless chess-engine-handling-event
(cond
((eq event 'initialize)
- (when chess-uci-polyglot-book-file
- (unless chess-uci-book
- (setq chess-uci-book (chess-polyglot-book-open
- chess-uci-polyglot-book-file))))
+ (when (and chess-polyglot-book-file
+ (file-exists-p chess-polyglot-book-file))
+ (unless chess-polyglot-book
+ (setq chess-polyglot-book (chess-polyglot-book-open
+ chess-polyglot-book-file))))
(apply #'chess-common-handler game event args))
((eq event 'new)
@@ -140,12 +123,11 @@ If conversion fails, this function fired an 'illegal event."
(chess-game-set-data game 'active nil)))
((eq event 'post-move)
- (let ((book-ply (and chess-uci-book (bufferp chess-uci-book)
- (buffer-live-p chess-uci-book)
+ (let ((book-ply (and chess-polyglot-book (bufferp chess-polyglot-book)
+ (buffer-live-p chess-polyglot-book)
(chess-polyglot-book-ply
- chess-uci-book
- (chess-game-pos game)
- chess-uci-polyglot-book-strength))))
+ chess-polyglot-book
+ (chess-game-pos game)))))
(if book-ply
(let ((chess-display-handling-event nil))
(funcall chess-engine-response-handler 'move book-ply))