diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-04-03 02:11:46 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-04-03 02:11:46 +0000 |
| commit | bc1b6e4f3789f4401ac5fe9bb9708459648345b0 (patch) | |
| tree | 61016ff5f23823fe740c16755ebf800cc6d6bb9b /chess-gnuchess.el | |
| parent | f4e9c77bc700222590ada4799c619152354244f2 (diff) | |
More work to get engines working.
Diffstat (limited to 'chess-gnuchess.el')
| -rw-r--r-- | chess-gnuchess.el | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/chess-gnuchess.el b/chess-gnuchess.el new file mode 100644 index 0000000..4598020 --- /dev/null +++ b/chess-gnuchess.el @@ -0,0 +1,47 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Play against gnuchess! +;; +;; $Revision$ + +(require 'chess-engine) +(require 'chess-fen) +(require 'chess-algebraic) + +(defvar chess-gnuchess-regexp-alist + (list (cons (concat "My move is : \\(" chess-algebraic-regexp "\\)") + (function + (lambda () + (funcall chess-engine-response-handler 'move + (chess-algebraic-to-ply position + (match-string 1)))))) + (cons "Illegal move:" + (function + (lambda () + (signal 'chess-illegal "Illegal move")))))) + +(defun chess-gnuchess-handler (event &rest args) + (cond + ((eq event 'initialize) + (let (proc) + (message "Starting chess program 'gnuchess'...") + (setq proc (start-process "chess-process" (current-buffer) + (executable-find "gnuchess"))) + (message "Starting chess program 'gnuchess'...done") + 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"))))) + +(provide 'chess-gnuchess) + +;;; chess-gnuchess.el ends here |
