summaryrefslogtreecommitdiff
path: root/chess-pos.el
diff options
context:
space:
mode:
authorMario Lang <mlang@delysid.org>2014-03-30 20:03:11 +0200
committerMario Lang <mlang@delysid.org>2014-03-30 20:03:11 +0200
commit0d02c90b1ff556c7e86330f34af05a39f6faed32 (patch)
tree2986eaef141d4cb08193e1534058178a65a2eb21 /chess-pos.el
parent045a93cb98dfd320e756ea9d9799ea92f0900bc6 (diff)
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.
Diffstat (limited to 'chess-pos.el')
-rw-r--r--chess-pos.el6
1 files changed, 6 insertions, 0 deletions
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))