summaryrefslogtreecommitdiff
path: root/chess-pos.el
diff options
context:
space:
mode:
authorMario Lang <mlang@delysid.org>2004-01-26 12:35:51 +0000
committerMario Lang <mlang@delysid.org>2004-01-26 12:35:51 +0000
commitc4dfc98b7cb5f9cfee689a852549022b80345033 (patch)
tree06dc478beccf58a4aa82182111b1cab8ccfb5c7f /chess-pos.el
parent6360b76b4f874fd3325f8eb441f516d3904bfcf9 (diff)
(chess-pos-move): There was a bug in castling removal when a Rook moved, now compare chess-pos-can-castle and the source square of the moving piece to figure out if we need to remove castling priveledges
Diffstat (limited to 'chess-pos.el')
-rw-r--r--chess-pos.el17
1 files changed, 8 insertions, 9 deletions
diff --git a/chess-pos.el b/chess-pos.el
index bd6d400..ccfb0fb 100644
--- a/chess-pos.el
+++ b/chess-pos.el
@@ -556,7 +556,7 @@ This string should have been created by `chess-pos-to-string'."
'((move-from-blank . "Attempted piece move from blank square %s")))
(defun chess-pos-move (position &rest changes)
- "Move a piece on the POSITION directly, using the indices FROM and TO.
+ "Move a piece on the POSITION directly, using the indices in CHANGES.
This function does not check any rules, it only makes sure you are not
trying to move a blank square."
(assert (vectorp position))
@@ -579,7 +579,6 @@ trying to move a blank square."
;; now fix up the resulting position
(let ((color (chess-pos-side-to-move position)))
-
;; if the move was en-passant, remove the captured pawn
(if (memq :en-passant changes)
(chess-pos-set-piece position
@@ -599,13 +598,13 @@ trying to move a blank square."
(chess-pos-set-can-castle position (if color ?Q ?q) nil))
((= piece ?r)
- (let ((king (chess-pos-king-index position color)))
- (if (and (chess-pos-can-castle position (if color ?Q ?q))
- (< (chess-index-file (car changes)) king))
- (chess-pos-set-can-castle position (if color ?Q ?q) nil)
- (if (and (chess-pos-can-castle position (if color ?K ?k))
- (> (chess-index-file (car changes)) king))
- (chess-pos-set-can-castle position (if color ?K ?k) nil)))))
+ (if (and (chess-pos-can-castle position (if color ?Q ?q))
+ (= (car changes) (chess-pos-can-castle position (if color ?Q ?q))))
+ (chess-pos-set-can-castle position (if color ?Q ?q) nil)
+ (if (and (chess-pos-can-castle position (if color ?K ?k))
+ (= (car changes) (chess-pos-can-castle position
+ (if color ?K ?k))))
+ (chess-pos-set-can-castle position (if color ?K ?k) nil))))
((and (= piece ?p)
(> (abs (- (chess-index-rank (cadr changes))