mlang pushed a commit to branch externals/chess in repository elpa. commit 4ab6c335594387cf66efb28c528946a3d3c1db8f Author: Mario Lang <ml...@delysid.org> Date: Sat Jun 28 13:27:58 2014 +0200
* chess-pos.el (chess-pos-search*) * chess-input.el (chess-input-display-moves): cl-delete-duplicates -> delete-dups. * chess-pos.el (chess-pos-piece-p, chess-pos-search*) (chess-search-position) * chess-ply.el (chess-ply-create, chess-legal-plies) * chess-plain.el (chess-plain-piece-text) * chess-fen.el (chess-pos-to-fen) * chess-display.el (chess-display-select-piece) * chess-algebraic.el (chess-algebraic-to-ply): Use `=' instead of `eq' to compare pieces. --- ChangeLog | 15 +++++++++++++++ chess-algebraic.el | 2 +- chess-display.el | 2 +- chess-fen.el | 8 ++++---- chess-input.el | 2 +- chess-plain.el | 2 +- chess-ply.el | 4 ++-- chess-pos.el | 22 +++++++++++----------- 8 files changed, 36 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5b9a71..e597fa6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2014-06-25 Mario Lang <ml...@delysid.org> + + * chess-pos.el (chess-pos-search*) + * chess-input.el (chess-input-display-moves): cl-delete-duplicates -> + delete-dups. + + * chess-pos.el (chess-pos-piece-p, chess-pos-search*) + (chess-search-position) + * chess-ply.el (chess-ply-create, chess-legal-plies) + * chess-plain.el (chess-plain-piece-text) + * chess-fen.el (chess-pos-to-fen) + * chess-display.el (chess-display-select-piece) + * chess-algebraic.el (chess-algebraic-to-ply): Use `=' instead of `eq' + to compare pieces. + 2014-06-24 Mario Lang <ml...@delysid.org> * chess-ply.el (chess-ply-p): New function. diff --git a/chess-algebraic.el b/chess-algebraic.el index 5ca7895..808d3e0 100644 --- a/chess-algebraic.el +++ b/chess-algebraic.el @@ -102,7 +102,7 @@ This regexp matches short, long and figurine notation.") (mate (match-string 8 move)) (piece (aref move 0)) changes type) - (if (or (eq piece ?O) (eq piece ?0)) + (if (or (= piece ?O) (= piece ?0)) (setq changes (chess-ply-castling-changes position (= (length (match-string 1 move)) 5))) (let ((promotion (match-string 7 move))) diff --git a/chess-display.el b/chess-display.el index 537ac6c..fa4358c 100644 --- a/chess-display.el +++ b/chess-display.el @@ -1233,7 +1233,7 @@ Clicking once on a piece selects it; then click on the target location." (setq chess-display-last-selected nil)) (let ((piece (chess-pos-piece position coord))) (cond - ((eq piece ? ) + ((= piece ? ) (throw 'message (chess-string 'selected-empty))) ((not (or chess-display-edit-mode (not (chess-display-active-p)) diff --git a/chess-fen.el b/chess-fen.el index f3a2eb0..52bdf9e 100644 --- a/chess-fen.el +++ b/chess-fen.el @@ -145,11 +145,11 @@ If FULL is non-nil, represent trailing spaces as well." (if (and index (let ((pawn (if (chess-pos-side-to-move position) ?P ?p))) (or (and (chess-incr-index index 0 -1) - (eq (chess-pos-piece position (chess-incr-index - index 0 -1)) pawn)) + (chess-pos-piece-p position (chess-incr-index + index 0 -1) pawn)) (and (chess-incr-index index 0 1) - (eq (chess-pos-piece position (chess-incr-index - index 0 1)) pawn))))) + (chess-pos-piece-p position (chess-incr-index + index 0 1) pawn))))) (concat str (chess-index-to-coord (if (chess-pos-side-to-move position) (chess-incr-index index -1 0) diff --git a/chess-input.el b/chess-input.el index f3cc893..500fd21 100644 --- a/chess-input.el +++ b/chess-input.el @@ -83,7 +83,7 @@ (when (> (length chess-input-move-string) 0) (when chess-display-highlight-legal (apply #'chess-display-highlight - nil (cl-delete-duplicates (mapcar #'chess-ply-target move-list)))) + nil (delete-dups (mapcar #'chess-ply-target move-list)))) (message "[%s] %s" chess-input-move-string (mapconcat (lambda (ply) (chess-ply-to-algebraic ply chess-input-notation-type)) diff --git a/chess-plain.el b/chess-plain.el index e5e1412..190d263 100644 --- a/chess-plain.el +++ b/chess-plain.el @@ -256,7 +256,7 @@ modify `chess-plain-piece-chars' to avoid real confusion.)" (defun chess-plain-piece-text (piece rank file) (let ((white-square (zerop (% (+ file rank) 2)))) - (if (eq piece ? ) + (if (= piece ? ) (if white-square chess-plain-white-square-char chess-plain-black-square-char) diff --git a/chess-ply.el b/chess-ply.el index 46cba39..35b30c9 100644 --- a/chess-ply.el +++ b/chess-ply.el @@ -221,7 +221,7 @@ maneuver." (car changes)))) (setcdr ply new-changes))) - (when (eq piece (if color ?P ?p)) + (when (= piece (if color ?P ?p)) ;; is this a pawn move to the ultimate rank? if so, check ;; that the :promote keyword is present. (when (and (not (memq :promote changes)) @@ -345,7 +345,7 @@ position object passed in." (upcase (or piece (chess-pos-piece position (cadr (memq :index keywords)))))) - (ep (when (eq test-piece ?P) (chess-pos-en-passant position))) + (ep (when (= test-piece ?P) (chess-pos-en-passant position))) pos plies file) ;; since we're looking for moves of a particular piece, do a ;; more focused search diff --git a/chess-pos.el b/chess-pos.el index e369866..76a4bc9 100644 --- a/chess-pos.el +++ b/chess-pos.el @@ -287,7 +287,7 @@ color will do." (cl-check-type piece-or-color (member t nil ? ?K ?Q ?N ?B ?R ?P ?k ?q ?n ?b ?r ?p)) (let ((p (chess-pos-piece position index))) (cond - ((= p ? ) (eq p piece-or-color)) + ((= p ? ) (and (numberp piece-or-color) (= p piece-or-color))) ((eq piece-or-color t) (< p ?a)) ((eq piece-or-color nil) (> p ?a)) (t (= p piece-or-color))))) @@ -486,12 +486,12 @@ alist, but the `cdr' of their entries will be nil." (when ok (memq piece '(?P ?N ?B ?R ?Q ?K ?p ?n ?b ?r ?q ?k)))) pieces :initial-value t)) - (cl-assert (= (length pieces) (length (cl-delete-duplicates pieces)))) + (cl-assert (equal pieces (delete-dups pieces))) (let ((alist (mapcar #'list pieces))) (dotimes (index 64) (let ((piece (chess-pos-piece position index))) - (unless (eq piece ? ) - (let ((entry (assq piece alist))) + (unless (= piece ? ) + (let ((entry (assoc piece alist))) (when entry (push index (cdr entry))))))) alist)) @@ -911,7 +911,7 @@ If NO-CASTLING is non-nil, do not consider castling moves." (let ((pos-piece (chess-pos-piece position (caar ray)))) (setq ray (cond ((memq pos-piece (cdar ray)) (chess--add-candidate (caar ray)) nil) - ((eq pos-piece ? ) (cdr ray))))))) + ((= pos-piece ? ) (cdr ray))))))) ;; test for knights and pawns (dolist (p (if piece '(?P ?N) '(?p ?n))) @@ -943,10 +943,10 @@ If NO-CASTLING is non-nil, do not consider castling moves." ;; pawn movement, which is diagonal 1 when taking, but forward ;; 1 or 2 when moving (the most complex piece, actually) - ((eq test-piece ?P) + ((= test-piece ?P) (let ((p (chess-pos-piece position target)) (backward (if color chess-direction-south chess-direction-north))) - (if (if (eq p ? ) + (if (if (= p ? ) ;; check for en passant (and (= (chess-index-rank target) (if color 2 5)) (let ((ep (chess-pos-en-passant position))) @@ -978,9 +978,9 @@ If NO-CASTLING is non-nil, do not consider castling moves." (chess--add-candidate pos))) (if (setq pos (chess-next-index target backward)) (let ((pos-piece (chess-pos-piece position pos))) - (if (eq pos-piece piece) + (if (= pos-piece piece) (chess--add-candidate pos) - (if (and (eq pos-piece ? ) + (if (and (= pos-piece ? ) (= (if color 4 3) (chess-index-rank target)) (setq pos (funcall (if color #'+ #'-) pos 8)) (chess-pos-piece-p position pos piece)) @@ -997,11 +997,11 @@ If NO-CASTLING is non-nil, do not consider castling moves." (setq pos (chess-next-index target dir)) (while pos (let ((pos-piece (chess-pos-piece position pos))) - (if (eq pos-piece piece) + (if (= pos-piece piece) (progn (chess--add-candidate pos) (setq pos nil)) - (setq pos (and (eq pos-piece ? ) (chess-next-index pos dir))))))) + (setq pos (and (= 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)