diff options
| author | Mario Lang <mlang@delysid.org> | 2014-03-30 20:03:11 +0200 |
|---|---|---|
| committer | Mario Lang <mlang@delysid.org> | 2014-03-30 20:03:11 +0200 |
| commit | 0d02c90b1ff556c7e86330f34af05a39f6faed32 (patch) | |
| tree | 2986eaef141d4cb08193e1534058178a65a2eb21 /chess-pos.el | |
| parent | 045a93cb98dfd320e756ea9d9799ea92f0900bc6 (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.el | 6 |
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)) |
