diff options
| author | Mario Lang <mlang@delysid.org> | 2014-04-09 14:55:03 +0200 |
|---|---|---|
| committer | Mario Lang <mlang@delysid.org> | 2014-04-09 14:55:03 +0200 |
| commit | 5e495b2b8d50f35c7f595205531110375fd754b6 (patch) | |
| tree | 691610fa55052e2782c24dd2762734777b333806 | |
| parent | 50dc110f467a57f305954370aff4df0e37ba1bf1 (diff) | |
chess-legal-plies: If chess-ply-allow-interactive-query is nil, generate Q and N promotions.
| -rw-r--r-- | chess-ply.el | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/chess-ply.el b/chess-ply.el index ad9423c..804bc9d 100644 --- a/chess-ply.el +++ b/chess-ply.el @@ -299,9 +299,23 @@ maneuver." (list candidate))) (if chess-ply-throw-if-any (throw 'any-found t) - (let ((ply (chess-ply-create position t candidate target))) - (if ply - (push ply plies))))))) + (if (not chess-ply-allow-interactive-query) + (let ((promotion (and (chess-pos-piece-p position candidate + (if color ?P ?p)) + (= (chess-index-rank target) + (if color 0 7))))) + (if promotion + (progn + (let ((ply (chess-ply-create position t candidate target + :promote ?Q))) + (when ply (push ply plies))) + (let ((ply (chess-ply-create position t candidate target + :promote ?N))) + (when ply (push ply plies)))) + (let ((ply (chess-ply-create position t candidate target))) + (when ply (push ply plies))))) + (let ((ply (chess-ply-create position t candidate target))) + (when ply (push ply plies)))))))) (defun chess-legal-plies (position &rest keywords) "Return a list of all legal plies in POSITION. @@ -477,7 +491,7 @@ position object passed in." (t (chess-error 'piece-unrecognized)))) - (delq nil plies))))) + plies)))) (provide 'chess-ply) |
