summaryrefslogtreecommitdiff
path: root/chess-gnuchess.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2002-04-09 00:19:40 +0000
committerJohn Wiegley <johnw@newartisans.com>2002-04-09 00:19:40 +0000
commit59c419ce027c0da05a7aebd3a383eef3ccf7b70c (patch)
treee8bd95ef716c6f6cbfca66b14dbad805e1a93bff /chess-gnuchess.el
parentdaa3d1cad1b0be5390bdd570d4c35b45bec13ccd (diff)
added a workaround so that fischer random positions are playable
Diffstat (limited to 'chess-gnuchess.el')
-rw-r--r--chess-gnuchess.el19
1 files changed, 16 insertions, 3 deletions
diff --git a/chess-gnuchess.el b/chess-gnuchess.el
index e7f2aa4..373cac8 100644
--- a/chess-gnuchess.el
+++ b/chess-gnuchess.el
@@ -18,8 +18,11 @@
:group 'chess-gnuchess)
(defvar chess-gnuchess-now-moving nil)
+
(defvar chess-gnuchess-temp-files nil)
+(defvar chess-gnuchess-bad-board nil)
(make-variable-buffer-local 'chess-gnuchess-temp-files)
+(make-variable-buffer-local 'chess-gnuchess-bad-board)
(defvar chess-gnuchess-regexp-alist
(list (cons (concat "My move is : \\(" chess-algebraic-regexp "\\)")
@@ -35,7 +38,14 @@
(cons "Illegal move:"
(function
(lambda ()
- (signal 'chess-illegal "Illegal move"))))))
+ (signal 'chess-illegal "Illegal move"))))
+ (cons "Board is wrong!"
+ (function
+ (lambda ()
+ ;; gnuchess didn't like the given position, which
+ ;; means it won't play against it unless we send a
+ ;; "go" after the user's move
+ (setq chess-gnuchess-bad-board t))))))
(defun chess-gnuchess-handler (event &rest args)
(cond
@@ -71,12 +81,15 @@
(chess-engine-position nil))
"white" "black")
"\n"))
- (chess-engine-send nil "go\n"))
+ (chess-engine-send nil "go\n")
+ (setq chess-gnuchess-bad-board nil))
((eq event 'move)
(unless chess-gnuchess-now-moving
(chess-engine-send nil (concat (chess-ply-to-algebraic (car args))
- "\n"))))))
+ "\n"))
+ (if chess-gnuchess-bad-board
+ (chess-engine-send nil "go\n"))))))
(provide 'chess-gnuchess)