From 5e495b2b8d50f35c7f595205531110375fd754b6 Mon Sep 17 00:00:00 2001 From: Mario Lang Date: Wed, 9 Apr 2014 14:55:03 +0200 Subject: chess-legal-plies: If chess-ply-allow-interactive-query is nil, generate Q and N promotions. --- chess-ply.el | 22 ++++++++++++++++++---- 1 file 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) -- cgit v1.2.3