diff options
| author | John Wiegley <johnw@newartisans.com> | 2018-08-29 22:49:20 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-29 22:49:20 -0700 |
| commit | 67339d896aa65d75272b80134a8128276c8c6a0f (patch) | |
| tree | 09eb145ffcbaf89d873c89e8346ee8d38a88ebbe /chess-ply.el | |
| parent | 29dd9bb233e149cae62a2277020074f8fec1eec8 (diff) | |
| parent | 800dd7677276f9e425c5db37b3e31e56ab1dad32 (diff) | |
Merge pull request #23 from dickmao/fix-castling-legality
Add tests for castling legality and ics response handling.
Diffstat (limited to 'chess-ply.el')
| -rw-r--r-- | chess-ply.el | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/chess-ply.el b/chess-ply.el index f49c7ad..165befa 100644 --- a/chess-ply.el +++ b/chess-ply.el @@ -209,7 +209,7 @@ maneuver." ;; validate that `changes' can be legally applied to the given ;; position (when (or valid-p - (chess-legal-plies position :any :index (car changes) + (chess-legal-plies position :index (car changes) :target (cadr changes))) (unless chess-ply-checking-mate (setq piece (chess-pos-piece position (car changes))) @@ -445,16 +445,20 @@ position object passed in." candidate))) (if changes (if chess-ply-throw-if-any - (throw 'any-found t) - (push (cons position changes) plies))))) + (throw 'any-found t) + (if (or (not specific-target) + (= specific-target (cadr changes))) + (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))))))) + (throw 'any-found t) + (if (or (not specific-target) + (= specific-target (cadr changes))) + (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 |
