summaryrefslogtreecommitdiff
path: root/chess-ply.el
diff options
context:
space:
mode:
authordickmao <rchiang@cs.stonybrook.edu>2018-08-28 21:48:31 -0400
committerdickmao <dick.r.chiang@gmail.com>2018-08-30 00:14:42 -0400
commit800dd7677276f9e425c5db37b3e31e56ab1dad32 (patch)
tree09eb145ffcbaf89d873c89e8346ee8d38a88ebbe /chess-ply.el
parent5bd1e7248bb9bf3b335cbd6bec250866bd165af1 (diff)
Add tests for castling legality and ics response handling.
Fixes misinterpretation of "e1-b1" as a valid queenside castle, and makes more sense of ics basic response handling #21. `make test` should run the historic.pgn test and the new ecukes tests.
Diffstat (limited to 'chess-ply.el')
-rw-r--r--chess-ply.el14
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