diff options
| author | Mario Lang <mlang@delysid.org> | 2014-04-18 01:14:16 +0200 |
|---|---|---|
| committer | Mario Lang <mlang@delysid.org> | 2014-04-18 01:14:16 +0200 |
| commit | f4fab47ee91e371dfdfce9ebf4c6bcd3a8497564 (patch) | |
| tree | ebe31be309c328fccf2801dc98ad4dc55c7e1f3a /chess-ply.el | |
| parent | 530b3c3cf0727d311582f6b983b966f3598ea8ba (diff) | |
chess-legal-plies: It is illegal to castle if the king is in check right now.
Diffstat (limited to 'chess-ply.el')
| -rw-r--r-- | chess-ply.el | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/chess-ply.el b/chess-ply.el index fef4bc3..7c4d741 100644 --- a/chess-ply.el +++ b/chess-ply.el @@ -440,21 +440,22 @@ position object passed in." (chess-pos-piece-p position pos (not color)))) (chess-ply--add nil nil pos))) - (if (chess-pos-can-castle position (if color ?K ?k)) - (let ((changes (chess-ply-castling-changes position nil - candidate))) - (if changes - (if chess-ply-throw-if-any - (throw 'any-found t) - (push (cons position changes) plies))))) - - (if (chess-pos-can-castle position (if color ?Q ?q)) - (let ((changes (chess-ply-castling-changes position t - candidate))) - (if changes - (if chess-ply-throw-if-any - (throw 'any-found t) - (push (cons position changes) plies)))))) + (unless (chess-search-position position candidate (not color) nil t) + (if (chess-pos-can-castle position (if color ?K ?k)) + (let ((changes (chess-ply-castling-changes position nil + candidate))) + (if changes + (if chess-ply-throw-if-any + (throw 'any-found t) + (push (cons position changes) plies))))) + + (if (chess-pos-can-castle position (if color ?Q ?q)) + (let ((changes (chess-ply-castling-changes position t + candidate))) + (if changes + (if chess-ply-throw-if-any + (throw 'any-found t) + (push (cons position changes) plies))))))) ;; the knight is a zesty little piece; there may be more than ;; one, but at only one possible square in each direction |
