From 8ac89522d46a29b61ab32254861762ab1a43f514 Mon Sep 17 00:00:00 2001 From: Mario Lang Date: Sat, 10 Jan 2004 16:12:14 +0000 Subject: Use Crafty's xboard protocol layer for communication: Since recent >19.x crafty, there is something strange going on with display nogeneral. Another bug which appears sometimes is that crafty (in its own mode of displaying stuff) echos the oponent move (our move) which raises an error (obviously). xboard mode is really a lot easier to parse, and I even managed to keep the 'evaluate event without any problems. --- chess-crafty.el | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/chess-crafty.el b/chess-crafty.el index 1f892ee..b6b0dac 100644 --- a/chess-crafty.el +++ b/chess-crafty.el @@ -21,17 +21,21 @@ (defvar chess-crafty-regexp-alist (list - (cons (concat "\\(White\\|Black\\)\\s-*([0-9]+):\\s-+\\(" + (cons (concat "move\\s-+\\(" chess-algebraic-regexp "\\)\\s-*$") (function (lambda () (funcall chess-engine-response-handler 'move - (chess-engine-convert-algebraic (match-string 2) t))))) + (chess-engine-convert-algebraic (match-string 1) t))))) (cons "total evaluation\\.+\\s-+\\([-+0-9.]+\\)" (function (lambda () (setq chess-crafty-evaluation (string-to-number (match-string 1)))))) + (cons "tellicsnoalias kibitz Hello from\\s-+\\(.+\\)$" + (function + (lambda () + (setq chess-engine-opponent-name (match-string 1))))) (cons "{\\(Black\\|White\\) resigns}" (function (lambda () @@ -52,20 +56,8 @@ (let ((proc (chess-common-handler game 'initialize "crafty"))) (when (and proc (processp proc) (eq (process-status proc) 'run)) - (process-send-string proc (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")) - (setq chess-engine-process proc - chess-engine-opponent-name "Crafty") + (process-send-string proc (concat "xboard\n")) + (setq chess-engine-process proc) t))) ((eq event 'setup-pos) @@ -94,8 +86,8 @@ (chess-engine-send nil "resign -1\n"))) ((eq (car args) 'ponder) (if (cadr args) - (chess-engine-send nil "ponder on\n") - (chess-engine-send nil "ponder off\n"))))) + (chess-engine-send nil "hard\n") + (chess-engine-send nil "easy\n"))))) (t (if (and (eq event 'undo) -- cgit v1.2.3