summaryrefslogtreecommitdiff
path: root/chess-crafty.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2002-04-15 05:40:38 +0000
committerJohn Wiegley <johnw@newartisans.com>2002-04-15 05:40:38 +0000
commitef7c29d679c6aaf8dda55772e65800097c46f163 (patch)
tree543f39f09bfaa6d44606804c18babff26470d4f8 /chess-crafty.el
parent6fbcc92505250d896b5d408483822b115bc614c7 (diff)
*** no comment ***
Diffstat (limited to 'chess-crafty.el')
-rw-r--r--chess-crafty.el81
1 files changed, 46 insertions, 35 deletions
diff --git a/chess-crafty.el b/chess-crafty.el
index be1e25b..204effe 100644
--- a/chess-crafty.el
+++ b/chess-crafty.el
@@ -37,46 +37,57 @@
(cons "\\(Illegal move\\|unrecognized/illegal command\\):\\s-*\\(.*\\)"
(function
(lambda ()
- (error (match-string 1)))))))
+ (error (match-string 1)))))
+ (cons "command not legal now"
+ (function
+ (lambda ()
+ (error (match-string 0)))))))
+
+(defun chess-crafty-handler (game event &rest args)
+ (unless chess-engine-handling-event
+ (cond
+ ((eq event 'initialize)
+ (let ((proc (chess-common-handler game 'initialize "crafty")))
+ (when (and (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"))
+ t)))
-(defun chess-crafty-handler (event &rest args)
- (cond
- ((eq event 'initialize)
- (let ((proc (chess-common-handler 'initialize "crafty")))
- (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"))
- proc))
+ ((eq event 'setup-pos)
+ (chess-engine-send nil (format "setboard %s\n"
+ (chess-pos-to-string (car args)))))
- ((eq event 'setup-pos)
- (chess-engine-send nil (format "setboard %s\n"
- (chess-pos-to-string (car args)))))
+ ((eq event 'evaluate)
+ (setq chess-crafty-evaluation nil)
+ (chess-engine-send nil "display general\nscore\ndisplay nogeneral\n")
+ (let ((limit 50))
+ (while (and (null chess-crafty-evaluation)
+ (> (setq limit (1- limit)) 0))
+ (sit-for 0 100 t))
+ chess-crafty-evaluation))
- ((eq event 'evaluate)
- (setq chess-crafty-evaluation nil)
- (chess-engine-send nil "display general\nscore\ndisplay nogeneral\n")
- (let ((limit 50))
- (while (and (null chess-crafty-evaluation)
- (> (setq limit (1- limit)) 0))
- (sit-for 0 100 t))
- chess-crafty-evaluation))
+ ((eq event 'setup-game)
+ (let ((file (chess-with-temp-file
+ (insert (chess-game-to-string (car args)) ?\n))))
+ (chess-engine-send nil (format "read %s\n" file))))
- ((eq event 'setup-game)
- (let ((file (chess-with-temp-file
- (insert (chess-game-to-string (car args)) ?\n))))
- (chess-engine-send nil (format "read %s\n" file))))
+ (t
+ (if (and (eq event 'undo)
+ (= 1 (mod (car args) 2)))
+ (error "Cannot undo until after crafty moves"))
- (t
- (apply 'chess-common-handler event args))))
+ (apply 'chess-common-handler game event args)))))
(provide 'chess-crafty)