diff options
| -rw-r--r-- | chess-algebraic.el | 4 | ||||
| -rw-r--r-- | chess-engine.el | 1 | ||||
| -rw-r--r-- | chess-pos.el | 45 |
3 files changed, 27 insertions, 23 deletions
diff --git a/chess-algebraic.el b/chess-algebraic.el index f014a26..25b13a4 100644 --- a/chess-algebraic.el +++ b/chess-algebraic.el @@ -114,7 +114,9 @@ This regexp handles both long and short form.") (defun chess-ply-to-algebraic (ply &optional long) "Convert the given PLY to algebraic notation. If LONG is non-nil, render the move into long notation." - (if (null (car (chess-ply-changes ply))) + (if (let ((first (car (chess-ply-changes ply)))) + (or (null first) + (symbolp first))) "" (let* ((pos (chess-ply-pos ply)) (changes (chess-ply-changes ply)) diff --git a/chess-engine.el b/chess-engine.el index 7768bad..cc3e26e 100644 --- a/chess-engine.el +++ b/chess-engine.el @@ -157,6 +157,7 @@ ((eq event 'resign) (when game + (message "Your opponent has resigned") (chess-game-resign game) (chess-game-set-data game 'active nil) t)) diff --git a/chess-pos.el b/chess-pos.el index fdc5f6d..f326c09 100644 --- a/chess-pos.el +++ b/chess-pos.el @@ -278,28 +278,29 @@ trying to move a blank square." ;; if a king or rook moves, no more castling; also, if a pawn ;; jumps ahead two, mark it en-passantable - (let ((piece (downcase (chess-pos-piece position (cadr changes))))) - (cond - ((and (= piece ?k) - (equal (car changes) - (chess-rf-to-index (if color 7 0) 4))) - (chess-pos-set-can-castle position (if color ?K ?k) nil) - (chess-pos-set-can-castle position (if color ?Q ?q) nil)) - - ((and (= piece ?r) - (equal (car changes) - (chess-rf-to-index (if color 7 0) 0))) - (chess-pos-set-can-castle position (if color ?Q ?q) nil)) - - ((and (= piece ?r) - (equal (car changes) - (chess-rf-to-index (if color 7 0) 7))) - (chess-pos-set-can-castle position (if color ?K ?k) nil)) - - ((and (= piece ?p) - (> (abs (- (chess-index-rank (cadr changes)) - (chess-index-rank (car changes)))) 1)) - (chess-pos-set-en-passant position (cadr changes))))) + (unless (symbolp (car changes)) + (let ((piece (downcase (chess-pos-piece position (cadr changes))))) + (cond + ((and (= piece ?k) + (equal (car changes) + (chess-rf-to-index (if color 7 0) 4))) + (chess-pos-set-can-castle position (if color ?K ?k) nil) + (chess-pos-set-can-castle position (if color ?Q ?q) nil)) + + ((and (= piece ?r) + (equal (car changes) + (chess-rf-to-index (if color 7 0) 0))) + (chess-pos-set-can-castle position (if color ?Q ?q) nil)) + + ((and (= piece ?r) + (equal (car changes) + (chess-rf-to-index (if color 7 0) 7))) + (chess-pos-set-can-castle position (if color ?K ?k) nil)) + + ((and (= piece ?p) + (> (abs (- (chess-index-rank (cadr changes)) + (chess-index-rank (car changes)))) 1)) + (chess-pos-set-en-passant position (cadr changes)))))) ;; toggle the side whose move it is (chess-pos-set-side-to-move position (not color)) |
