diff options
| author | Mario Lang <mlang@delysid.org> | 2014-04-28 13:14:06 +0200 |
|---|---|---|
| committer | Mario Lang <mlang@delysid.org> | 2014-04-28 13:14:06 +0200 |
| commit | 2f0696b50837a09108ff4964fea138173c6e6adf (patch) | |
| tree | f11c62e657378bf8e49de0ecde111b5043e2b9a9 /chess-ply.el | |
| parent | 543b7d0dd623d7ae59ebfba85c4d8dd8a120379a (diff) | |
Replace a few chess-incr-index calls with chess-next-index.
Diffstat (limited to 'chess-ply.el')
| -rw-r--r-- | chess-ply.el | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/chess-ply.el b/chess-ply.el index 7fe420f..8d25cce 100644 --- a/chess-ply.el +++ b/chess-ply.el @@ -408,34 +408,23 @@ position object passed in." ;; rank and file and/or diagonal for the nearest pieces! ((memq test-piece '(?R ?B ?Q)) (dolist (dir (cond - ((= test-piece ?R) - '( (-1 0) - (0 -1) (0 1) - (1 0))) - ((= test-piece ?B) - '((-1 -1) (-1 1) - - (1 -1) (1 1))) - ((= test-piece ?Q) - '((-1 -1) (-1 0) (-1 1) - (0 -1) (0 1) - (1 -1) (1 0) (1 1))))) - (setq pos (apply 'chess-incr-index candidate dir)) + ((= test-piece ?R) chess-rook-directions) + ((= test-piece ?B) chess-bishop-directions) + ((= test-piece ?Q) chess-queen-directions))) + (setq pos (chess-next-index candidate dir)) (while pos (if (chess-pos-piece-p position pos ? ) (progn (chess-ply--add nil nil pos) - (setq pos (apply 'chess-incr-index pos dir))) + (setq pos (chess-next-index pos dir))) (if (chess-pos-piece-p position pos (not color)) (chess-ply--add nil nil pos)) (setq pos nil))))) ;; the king is a trivial case of the queen, except when castling ((= test-piece ?K) - (dolist (dir '((-1 -1) (-1 0) (-1 1) - (0 -1) (0 1) - (1 -1) (1 0) (1 1))) - (setq pos (apply 'chess-incr-index candidate dir)) + (dolist (dir chess-king-directions) + (setq pos (chess-next-index candidate dir)) (if (and pos (or (chess-pos-piece-p position pos ? ) (chess-pos-piece-p position pos (not color)))) (chess-ply--add nil nil pos))) @@ -460,12 +449,9 @@ position object passed in." ;; the knight is a zesty little piece; there may be more than ;; one, but at only one possible square in each direction ((= test-piece ?N) - (dolist (dir '((-2 -1) (-2 1) - (-1 -2) (-1 2) - (1 -2) (1 2) - (2 -1) (2 1))) + (dolist (dir chess-knight-directions) ;; up the current file - (if (and (setq pos (apply 'chess-incr-index candidate dir)) + (if (and (setq pos (chess-next-index candidate dir)) (or (chess-pos-piece-p position pos ? ) (chess-pos-piece-p position pos (not color)))) (chess-ply--add nil nil pos)))) |
