summaryrefslogtreecommitdiff
path: root/chess-crafty.el
diff options
context:
space:
mode:
Diffstat (limited to 'chess-crafty.el')
-rw-r--r--chess-crafty.el17
1 files changed, 10 insertions, 7 deletions
diff --git a/chess-crafty.el b/chess-crafty.el
index d9038db..a88a831 100644
--- a/chess-crafty.el
+++ b/chess-crafty.el
@@ -14,13 +14,16 @@
chess-algebraic-regexp "\\)\\s-*$")
(function
(lambda ()
- (let ((position (chess-engine-position nil)))
- (if (string= (if (chess-pos-side-to-move position)
- "White" "Black")
- (match-string 1))
- (funcall chess-engine-response-handler 'move
- (chess-algebraic-to-ply position
- (match-string 2))))))))
+ (let ((position (chess-engine-position nil))
+ (move (match-string 2))
+ ply)
+ (when (string= (if (chess-pos-side-to-move position)
+ "White" "Black")
+ (match-string 1))
+ (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))))))
(cons "Illegal move:\\s-*\\(.*\\)"
(function
(lambda ()