diff options
| author | Mario Lang <mlang@delysid.org> | 2014-03-29 19:10:16 +0100 |
|---|---|---|
| committer | Mario Lang <mlang@delysid.org> | 2014-03-29 19:10:16 +0100 |
| commit | 35f132ddbdd096c2977c9f50ccbbbbea0f259476 (patch) | |
| tree | 9c5ccabfa243016b85c3c0d1bb287ef2380de4a7 | |
| parent | 422859f583703c4344d6f6fe0d78f445150263fb (diff) | |
chess-uci.el: Use the post-move event to work around a display bug when the handler directly replies with a move because it was found in the book.
| -rw-r--r-- | chess-uci.el | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/chess-uci.el b/chess-uci.el index e164f72..e421f71 100644 --- a/chess-uci.el +++ b/chess-uci.el @@ -26,6 +26,7 @@ ;;; Code: +(eval-when-compile (require 'cl-lib)) (require 'chess-common) (require 'chess-polyglot) @@ -56,8 +57,8 @@ See `chess-uci-polyglot-book-file' for details on how to enable this.") (defun chess-uci-long-algebraic-to-ply (position move) "Convert the long algebraic notation MOVE for POSITION to a ply." - (assert (vectorp position)) - (assert (stringp move)) + (cl-assert (vectorp position)) + (cl-assert (stringp move)) (let ((case-fold-search nil)) (when (string-match chess-uci-long-algebraic-regexp move) (let ((color (chess-pos-side-to-move position)) @@ -123,11 +124,22 @@ If conversion fails, this function fired an 'illegal event." chess-uci-polyglot-book-file)))) (apply #'chess-common-handler game event args)) + ((eq event 'new) + (chess-engine-send nil "ucinewgame\n") + (chess-engine-set-position nil)) + + ((eq event 'resign) + (chess-game-set-data game 'active nil)) + ((eq event 'move) (when (= 1 (chess-game-index game)) (chess-game-set-tag game "White" chess-full-name) (chess-game-set-tag game "Black" chess-engine-opponent-name)) + (if (chess-game-over-p game) + (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) (chess-polyglot-book-ply @@ -137,10 +149,7 @@ If conversion fails, this function fired an 'illegal event." (if book-ply (let ((chess-display-handling-event nil)) (funcall chess-engine-response-handler 'move book-ply)) - (chess-engine-send nil (concat (chess-uci-position game) "go\n")))) - - (if (chess-game-over-p game) - (chess-game-set-data game 'active nil))) + (chess-engine-send nil (concat (chess-uci-position game) "go\n"))))) (t (apply 'chess-common-handler game event args))))) |
