From 0d02c90b1ff556c7e86330f34af05a39f6faed32 Mon Sep 17 00:00:00 2001 From: Mario Lang Date: Sun, 30 Mar 2014 20:03:11 +0200 Subject: Fix a rather serious bug in chess-pos-move: We were checking for king or rook moves to remove our castling flags if necessary, but we did not remove the opponents castling flags if we took one of their rooks. This led to rather invalid positions. You could castle with your king and the opponents piece. --- chess-pos.el | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/chess-pos.el b/chess-pos.el index 0956fe5..2b2a913 100644 --- a/chess-pos.el +++ b/chess-pos.el @@ -643,6 +643,12 @@ trying to move a blank square." (= (car changes) (chess-pos-can-castle position (if color ?K ?k)))) (chess-pos-set-can-castle position (if color ?K ?k) nil)))) + ((let ((can-castle (chess-pos-can-castle position (if color ?q ?Q)))) + (and can-castle (= (cadr changes) can-castle))) + (chess-pos-set-can-castle position (if color ?q ?Q) nil)) + ((let ((can-castle (chess-pos-can-castle position (if color ?k ?K)))) + (and can-castle (= (cadr changes) can-castle))) + (chess-pos-set-can-castle position (if color ?k ?K) nil)) ((and (= piece ?p) (> (abs (- (chess-index-rank (cadr changes)) -- cgit v1.2.3