diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-04-09 04:26:02 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-04-09 04:26:02 +0000 |
| commit | 6b8ac5acf330b03e88d0b342c79abbb7d338e0c2 (patch) | |
| tree | 9df6dc3602f81a1acd5f2d6d234b6e4f6a45d57f /chess-crafty.el | |
| parent | 18f22844af74b15732d7fc7dfad318a1ba0c0d99 (diff) | |
Bug fixes and the beginnings of ICS client support
Diffstat (limited to 'chess-crafty.el')
| -rw-r--r-- | chess-crafty.el | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/chess-crafty.el b/chess-crafty.el index 50b4dc0..3b58f11 100644 --- a/chess-crafty.el +++ b/chess-crafty.el @@ -18,30 +18,18 @@ :type 'file :group 'chess-crafty) -(defvar chess-crafty-now-moving nil) - (defvar chess-crafty-regexp-alist - (list (cons - (concat "\\s-*\\(White\\|Black\\)\\s-*([0-9]+):\\s-+\\(" - chess-algebraic-regexp "\\)\\s-*$") - 'chess-crafty-perform-move) + (list (cons (concat "\\s-*\\(White\\|Black\\)\\s-*([0-9]+):\\s-+\\(" + chess-algebraic-regexp "\\)\\s-*$") + (function + (lambda () + (funcall chess-engine-response-handler 'move + (match-string 0))))) (cons "Illegal move:\\s-*\\(.*\\)" (function (lambda () (signal 'chess-illegal (match-string 1))))))) -(defun chess-crafty-perform-move () - (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)) - (let ((chess-crafty-now-moving t)) - (funcall chess-engine-response-handler 'move ply))))) - (defun chess-crafty-handler (event &rest args) (cond ((eq event 'initialize) @@ -77,9 +65,8 @@ (chess-engine-send nil "go\n")) ((eq event 'move) - (unless chess-crafty-now-moving - (chess-engine-send nil (concat (chess-ply-to-algebraic (car args)) - "\n")))))) + (chess-engine-send nil (concat (chess-ply-to-algebraic (car args)) + "\n"))))) (provide 'chess-crafty) |
