summaryrefslogtreecommitdiff
path: root/chess-crafty.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2002-04-10 21:08:12 +0000
committerJohn Wiegley <johnw@newartisans.com>2002-04-10 21:08:12 +0000
commitd50c928242180a7f3e75d9d4deebca1a4dc8141c (patch)
treefb01390359731d1397cb52f927161bcad9cf22b3 /chess-crafty.el
parentfa6d9924972f0472c2f05d10d2909e20e8af7b4b (diff)
lots of work, several new event types, better support in chess-engine
for establishing the starting game position
Diffstat (limited to 'chess-crafty.el')
-rw-r--r--chess-crafty.el22
1 files changed, 20 insertions, 2 deletions
diff --git a/chess-crafty.el b/chess-crafty.el
index 3b58f11..260ebb5 100644
--- a/chess-crafty.el
+++ b/chess-crafty.el
@@ -18,6 +18,9 @@
:type 'file
:group 'chess-crafty)
+(defvar chess-crafty-temp-files nil)
+(make-variable-buffer-local 'chess-crafty-temp-files)
+
(defvar chess-crafty-regexp-alist
(list (cons (concat "\\s-*\\(White\\|Black\\)\\s-*([0-9]+):\\s-+\\("
chess-algebraic-regexp "\\)\\s-*$")
@@ -55,12 +58,27 @@
proc))
((eq event 'shutdown)
- (chess-engine-send nil "quit\n"))
+ (chess-engine-send nil "quit\n")
+ (dolist (file chess-crafty-temp-files)
+ (if (file-exists-p file)
+ (delete-file file))))
+
+ ((eq event 'ready)
+ (let ((game (chess-engine-game nil)))
+ (if game
+ (chess-game-set-data game 'active t))))
- ((eq event 'setup)
+ ((eq event 'setup-pos)
(chess-engine-send nil (format "setboard %s\n"
(chess-pos-to-fen (car args)))))
+ ((eq event 'setup-game)
+ (let ((file (make-temp-file "cra")))
+ (with-temp-file file
+ (insert (chess-game-to-string (car args)) ?\n))
+ (chess-engine-send nil (format "read %s\n" file))
+ (push file chess-crafty-temp-files)))
+
((eq event 'pass)
(chess-engine-send nil "go\n"))