summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chess-crafty.el18
1 files changed, 13 insertions, 5 deletions
diff --git a/chess-crafty.el b/chess-crafty.el
index a88a831..d3f1da0 100644
--- a/chess-crafty.el
+++ b/chess-crafty.el
@@ -8,6 +8,8 @@
(require 'chess-fen)
(require 'chess-algebraic)
+(defvar chess-crafty-now-moving nil)
+
(defvar chess-crafty-regexp-alist
(list (cons
(concat "\\s-*\\(White\\|Black\\)\\s-*([0-9]+):\\s-+\\("
@@ -23,7 +25,8 @@
(setq ply (chess-algebraic-to-ply position move))
(unless ply
(error "Could not convert engine move: %s" move))
- (funcall chess-engine-response-handler 'move ply))))))
+ (let ((chess-crafty-now-moving t))
+ (funcall chess-engine-response-handler 'move ply)))))))
(cons "Illegal move:\\s-*\\(.*\\)"
(function
(lambda ()
@@ -51,18 +54,23 @@
"alarm off\n"
"ansi off\n"))
proc))
+
((eq event 'shutdown)
(chess-engine-send nil "quit\n"))
+
((eq event 'setup)
(chess-engine-send nil (format "setboard %s\n"
(chess-pos-to-fen (car args)))))
+
((eq event 'pass)
(chess-engine-send nil "go\n"))
+
((eq event 'move)
- (chess-engine-send
- nil (concat (chess-ply-to-algebraic
- (car args) nil
- (chess-engine-search-function nil)) "\n")))))
+ (unless chess-crafty-now-moving
+ (chess-engine-send
+ nil (concat (chess-ply-to-algebraic
+ (car args) nil
+ (chess-engine-search-function nil)) "\n"))))))
(provide 'chess-crafty)