summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PLAN6
-rw-r--r--chess-display.el24
-rw-r--r--chess-engine.el2
-rw-r--r--chess-ics.el96
4 files changed, 92 insertions, 36 deletions
diff --git a/PLAN b/PLAN
index c57d083..324a163 100644
--- a/PLAN
+++ b/PLAN
@@ -16,13 +16,17 @@ chess-epd
chess-ics
- detect draw/resign/retract, etc.
- add support for ICS observing
-- set the "Site" tag after logging in
chess-clock
- when a clock runs down, indicate this in the modeline, and allow the
user to call-flag in order to win on time; note: the user should be
allowed to try anyway, in case our clock has become out-of-sync with
the server's
+- when the clock goes under, it starts counting up! Need a "-0".
+
+chess-images
+- in a generic emacs, with a light background, there are white lines
+ in wierd places on the chessboard
The PGN chapter of the manual is not fully representative of the
original, owing to the lack of subsubsubsection in texinfo.
diff --git a/chess-display.el b/chess-display.el
index f38fc7a..6bf858b 100644
--- a/chess-display.el
+++ b/chess-display.el
@@ -469,18 +469,20 @@ See `chess-display-type' for the different kinds of displays."
(define-key map [? ] 'chess-display-pass)
(define-key map [??] 'describe-mode)
(define-key map [?@] 'chess-display-remote)
+ (define-key map [?A] 'chess-display-manual-move)
(define-key map [(control ?c) (control ?a)] 'chess-display-abort)
(define-key map [?C] 'chess-display-duplicate)
- (define-key map [?D] 'chess-display-duplicate)
+ (define-key map [?D] 'chess-display-decline)
(define-key map [(control ?c) (control ?d)] 'chess-display-draw)
(define-key map [?E] 'chess-display-edit-board)
(define-key map [?F] 'chess-display-set-from-fen)
- ;;(define-key map [?M] 'chess-display-manual-move)
(define-key map [?M] 'chess-display-match)
(define-key map [(control ?c) (control ?r)] 'chess-display-resign)
+ (define-key map [?R] 'chess-display-retract)
(define-key map [?S] 'chess-display-shuffle)
(define-key map [(control ?c) (control ?t)] 'chess-display-undo)
(define-key map [?X] 'chess-display-quit)
+ (define-key map [?Y] 'chess-display-accept)
(define-key map [?\{] 'chess-display-annotate)
(define-key map [?\"] 'chess-display-chat)
@@ -758,6 +760,24 @@ Basically, it means we are playing, not editing or reviewing."
(interactive)
(chess-game-run-hooks chess-module-game 'match))
+(defun chess-display-accept ()
+ (interactive)
+ (if (chess-display-active-p)
+ (chess-game-run-hooks chess-module-game 'accept)
+ (ding)))
+
+(defun chess-display-decline ()
+ (interactive)
+ (if (chess-display-active-p)
+ (chess-game-run-hooks chess-module-game 'decline)
+ (ding)))
+
+(defun chess-display-retract ()
+ (interactive)
+ (if (chess-display-active-p)
+ (chess-game-run-hooks chess-module-game 'retract)
+ (ding)))
+
(defun chess-display-resign ()
"Resign the current game."
(interactive)
diff --git a/chess-engine.el b/chess-engine.el
index aac40a6..14cae60 100644
--- a/chess-engine.el
+++ b/chess-engine.el
@@ -213,6 +213,8 @@
((eq chess-engine-pending-offer 'undo)
(chess-message 'opp-undo-acc chess-engine-pending-arg)
+ (chess-game-undo game (car args)))
+ ((eq chess-engine-pending-offer 'my-undo)
(chess-game-undo game (car args))))))
(setq chess-engine-pending-offer nil
chess-engine-pending-arg nil)
diff --git a/chess-ics.el b/chess-ics.el
index 6f41537..c38f5d1 100644
--- a/chess-ics.el
+++ b/chess-ics.el
@@ -74,6 +74,15 @@ The format of each entry is:
(funcall chess-engine-response-handler 'accept)))))
(cons "<12> \\(.+\\)"
'chess-ics-handle-move)
+ (cons "\\S-+ accepts the takeback request\\."
+ (function
+ (lambda ()
+ (funcall chess-engine-response-handler 'accept))))
+ (cons "You accept the takeback request from \\S-+\\."
+ (function
+ (lambda ()
+ (let ((chess-engine-pending-offer 'my-undo))
+ (funcall chess-engine-response-handler 'accept)))))
(cons "Illegal move (\\([^)]+\\))\\."
(function
(lambda ()
@@ -162,7 +171,8 @@ who is black."
;; -1 I am playing, it is my opponent's move
;; 1 I am playing and it is my move
;; 0 I am observing a game being played
- (setq parts (cdr parts))
+ (setq status (string-to-int (car parts))
+ parts (cdr parts))
;; initial time (in seconds) of the match
(setq parts (cdr parts))
@@ -203,47 +213,67 @@ who is black."
(setq parts (cdr parts))
(setq parts (cdr parts))
- (list position move white black white-time black-time)))
+ (list position move white black white-time black-time status)))
-;; <12> -k------ p-p----- -p------ ----n-R- ---N--p- ---P---- PPP-r--- -K---r-- W -1 0 0 0 0 1 160 GuestLKMM MiloBot 1 15 0 12 17 774 898 26 R/f8-f1 (0:00) Rf1# 0 1 0
-
-;; error in process filter: Assertion failed: (equal (car info) (chess-engine-position nil))
+(chess-message-catalog 'english
+ '((ics-server-prompt . "Connect to chess server: ")
+ (ics-connecting . "Connecting to Internet Chess Server '%s'...")
+ (ics-connected . "Connecting to Internet Chess Server '%s'...done")
+ (challenge-whom . "Whom would you like challenge? ")
+ (failed-ics-parse . "Failed to parse ICS move string (%s): %s")))
(defun chess-ics-handle-move ()
(let ((chess-engine-handling-event t)
(begin (match-beginning 0))
(end (match-end 0))
(info (chess-ics12-parse (match-string 1)))
- (game (chess-engine-game nil)))
- (if (chess-game-data game 'active)
- (when (and (cadr info)
- (eq (chess-pos-side-to-move (car info))
- (chess-game-data game 'my-color)))
- (let ((ply (chess-algebraic-to-ply
- (chess-ply-pos (car (last (chess-game-plies game))))
- (cadr info) t)))
- (chess-game-set-data game 'white-remaining (nth 4 info))
- (chess-game-set-data game 'black-remaining (nth 5 info))
- (chess-game-move game ply)))
- (let ((chess-game-inhibit-events t) plies)
- (chess-game-set-data game 'my-color
- (string= (nth 2 info) chess-ics-handle))
- (chess-game-set-data game 'active t)
- (chess-game-set-tag game "Site" (car chess-ics-server))
- (chess-game-set-start-position game (car info)))
- (chess-game-run-hooks game 'orient))
- (goto-char begin)
- (delete-region begin end)
- ;; we need to counter the `forward-line' in `chess-engine-filter'
- (forward-line -1)
+ (game (chess-engine-game nil))
+ error)
+ (unwind-protect
+ (if (nth 1 info)
+ ;; each move gives the _position occurring after the ply_,
+ ;; which means that if the move says W, it is telling us
+ ;; what our opponents move was
+ (if (and (setq error 'comparing-colors)
+ (eq (chess-pos-side-to-move (nth 0 info))
+ (chess-game-data game 'my-color)))
+ (let ((ign (setq error 'converting-ply))
+ (ply (chess-algebraic-to-ply
+ (chess-ply-pos
+ ;; jww (2002-04-25): change this, once I
+ ;; allow position to refer to their
+ ;; causal ply
+ (car (last (chess-game-plies game))))
+ (nth 1 info) t)))
+ (setq error 'setting-white-remaining)
+ (chess-game-set-data game 'white-remaining (nth 4 info))
+ (setq error 'setting-black-remaining)
+ (chess-game-set-data game 'black-remaining (nth 5 info))
+ (setq error 'applying-move)
+ (chess-game-move game ply)
+ (setq error nil))
+ (setq error nil))
+ (let ((chess-game-inhibit-events t) plies)
+ (when (or (= 1 (nth 6 info)) (= -1 (nth 6 info)))
+ (chess-game-set-data game 'my-color (= 1 (nth 6 info)))
+ (chess-game-set-data game 'active t))
+ (chess-game-set-tag game "White" (nth 2 info))
+ (chess-game-set-tag game "Black" (nth 3 info))
+ (chess-game-set-tag game "Site" (car chess-ics-server))
+ (setq error 'setting-start-position)
+ (chess-game-set-start-position game (car info)))
+ (setq error 'orienting-board)
+ (chess-game-run-hooks game 'orient)
+ (setq error nil))
+ (if error
+ (chess-message 'failed-ics-parse error
+ (buffer-substring-no-properties begin end)))
+ (goto-char begin)
+ (delete-region begin end)
+ ;; we need to counter the forward-line in chess-engine-filter
+ (forward-line -1))
t))
-(chess-message-catalog 'english
- '((ics-server-prompt . "Connect to chess server: ")
- (ics-connecting . "Connecting to Internet Chess Server '%s'...")
- (ics-connected . "Connecting to Internet Chess Server '%s'...done")
- (challenge-whom . "Whom would you like challenge? ")))
-
(defun chess-ics-handler (game event &rest args)
(unless chess-engine-handling-event
(cond