diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-03-02 04:20:59 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-03-02 04:20:59 +0000 |
| commit | 4cd80196667e882dbff4be03c15292417c142aaa (patch) | |
| tree | 30610d7e3e1357b1116612b2d9a7a680d2b01a45 | |
| parent | 78bc42be23ca642af88dcedc347169ae1ca17b9b (diff) | |
Fix to chess engine support.
| -rw-r--r-- | chess-crafty.el | 37 | ||||
| -rw-r--r-- | chess-gnuchess.el | 29 | ||||
| -rw-r--r-- | chess-process.el | 2 |
3 files changed, 35 insertions, 33 deletions
diff --git a/chess-crafty.el b/chess-crafty.el index 06b5451..d15be54 100644 --- a/chess-crafty.el +++ b/chess-crafty.el @@ -10,7 +10,8 @@ "Interface code for playing against crafty. Uses `chess-process'." :group 'chess) -(defcustom chess-crafty-command "crafty" +(defcustom chess-crafty-command (and (require 'executable) + (executable-find "crafty")) "The name of the crafty program." :type 'string :group 'chess-crafty) @@ -22,25 +23,21 @@ (if (not (eq event 'initialize)) (apply 'chess-process session buffer event args) (with-current-buffer - (chess-process session buffer event - chess-process-triggers - (if (file-name-absolute-p chess-crafty-command) - chess-crafty-command - (executable-find chess-crafty-command))) - (process-send-string - (get-buffer-process (current-buffer)) - (concat "display nogeneral\n" - "display nochanges\n" - "display noextstats\n" - "display nohashstats\n" - "display nomoves\n" - "display nonodes\n" - "display noply1\n" - "display nostats\n" - "display notime\n" - "display novariation\n" - "alarm off\n" - "ansi off\n")) + (chess-process session buffer event chess-process-triggers + chess-crafty-command) + (process-send-string (get-buffer-process (current-buffer)) + (concat "display nogeneral\n" + "display nochanges\n" + "display noextstats\n" + "display nohashstats\n" + "display nomoves\n" + "display nonodes\n" + "display noply1\n" + "display nostats\n" + "display notime\n" + "display novariation\n" + "alarm off\n" + "ansi off\n")) (current-buffer)))) (provide 'chess-crafty) diff --git a/chess-gnuchess.el b/chess-gnuchess.el index ef2e4be..c304a8b 100644 --- a/chess-gnuchess.el +++ b/chess-gnuchess.el @@ -10,23 +10,28 @@ "Interface code for playing against gnuchess. Uses `chess-process'." :group 'chess) -(defcustom chess-gnuchess-command "gnuchess" +(defcustom chess-gnuchess-command (and (require 'executable) + (executable-find "gnuchess")) "The name of the gnuchess program." :type 'string :group 'chess-gnuchess) ;;;###autoload -(defun chess-gnuchess (session process event &rest args) - (chess-process - session process event - (list (list (concat "My move is : \\(" chess-algebraic-regexp "\\)") - (function - (lambda (move) - (chess-game-move chess-process-game move nil))) 1) - '("Illegal move:" (error "Illegal move"))) - (if (file-name-absolute-p chess-gnuchess-command) - chess-gnuchess-command - (executable-find chess-gnuchess-command)))) +(defun chess-gnuchess (session buffer event &rest args) + (if (not (eq event 'initialize)) + (apply 'chess-process session buffer event args) + (chess-process session buffer event + (list (list + (concat "My move is : \\(" + chess-algebraic-regexp "\\)") + (function + (lambda (move) + (chess-session-event + chess-current-session 'move + (chess-algebraic-to-ply + (chess-game-pos chess-process-game) move)))) 1) + '("Illegal move:" (error "Illegal move"))) + chess-gnuchess-command))) (provide 'chess-gnuchess) diff --git a/chess-process.el b/chess-process.el index b5a2544..729cc8b 100644 --- a/chess-process.el +++ b/chess-process.el @@ -50,7 +50,7 @@ related to the resulting process.") (chess-algebraic-to-ply (chess-game-pos chess-process-game) move))))) 1 2) - '(".*Illegal move:\\s-*\\(.*\\)" + '(".*illegal move:\\s-*\\(.*\\)" (signal 'chess-illegal (match-string 1))) '(".+?\015" (replace-match ""))) "A list of regexps and the commands that they trigger. |
