diff options
| author | Mario Lang <mlang@delysid.org> | 2014-04-21 10:24:47 +0200 |
|---|---|---|
| committer | Mario Lang <mlang@delysid.org> | 2014-04-21 10:24:47 +0200 |
| commit | 705227d73d3b0761c72372126ed6f9d0097a64a2 (patch) | |
| tree | 1b87eb170608c3ebe2314ffe67f08a69004bef9e | |
| parent | a4027d3a8e8f471f128164e9896a024eac92f7aa (diff) | |
chess-search-position: Move castling check for rooks out of the direction loop.
| -rw-r--r-- | chess-pos.el | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/chess-pos.el b/chess-pos.el index 9588a70..ae06c26 100644 --- a/chess-pos.el +++ b/chess-pos.el @@ -908,21 +908,20 @@ If NO-CASTLING is non-nil, do not consider castling moves." (progn (chess--add-candidate pos) (setq pos nil)) - (setq pos (and (eq pos-piece ? ) (chess-next-index pos dir)))))) - - ;; test whether the rook can move to the target by castling - (if (and (= test-piece ?R) (not no-castling)) - (let (rook) - (if (and (= target (if color ?\075 ?\005)) + (setq pos (and (eq pos-piece ? ) (chess-next-index pos dir))))))) + ;; test whether the rook can move to the target by castling + (if (and (= test-piece ?R) (not no-castling)) + (let (rook) + (if (and (= target (if color ?\075 ?\005)) + (setq rook (chess-pos-can-castle position + (if color ?K ?k))) + (chess-ply-castling-changes position)) + (chess--add-candidate rook) + (if (and (= target (if color ?\073 ?\003)) (setq rook (chess-pos-can-castle position - (if color ?K ?k))) - (chess-ply-castling-changes position)) - (chess--add-candidate rook) - (if (and (= target (if color ?\073 ?\003)) - (setq rook (chess-pos-can-castle position - (if color ?Q ?q))) - (chess-ply-castling-changes position t)) - (chess--add-candidate rook))))))) + (if color ?Q ?q))) + (chess-ply-castling-changes position t)) + (chess--add-candidate rook)))))) ;; the king is a trivial case of the queen, except when castling ((= test-piece ?K) |
