diff options
Diffstat (limited to 'chess-algebraic.el')
| -rw-r--r-- | chess-algebraic.el | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/chess-algebraic.el b/chess-algebraic.el index 3905659..09f8b30 100644 --- a/chess-algebraic.el +++ b/chess-algebraic.el @@ -51,7 +51,7 @@ "A regular expression that matches all possible algebraic moves. This regexp handles both long and short form.") -(defun chess-algebraic-to-ply (position move &optional search-func) +(defun chess-algebraic-to-ply (position move) "Convert the algebraic notation MOVE for POSITION to a ply." (unless (string-match chess-algebraic-regexp move) (error "Cannot parse non-algebraic move notation: %s" move)) @@ -62,12 +62,8 @@ This regexp handles both long and short form.") (if (eq piece ?O) (let ((rank (if color 7 0)) (long (= (length (match-string 1 move)) 5))) - ;; jww (2002-04-07): This should be moderated by - ;; chess-standard!! (list (chess-rf-to-index rank 4) - (chess-rf-to-index rank (if long 2 6)) - (chess-rf-to-index rank (if long 0 7)) - (chess-rf-to-index rank (if long 3 5)))) + (chess-rf-to-index rank (if long 2 6)))) (let ((source (match-string 4 move)) (target (chess-coord-to-index (match-string 7 move)))) (if (and source (= (length source) 2)) @@ -82,10 +78,9 @@ This regexp handles both long and short form.") ;; move, to determine which piece is meant by the ;; piece indicator (when (setq candidates - (funcall (or search-func - 'chess-standard-search-position) - position target (if color piece - (downcase piece)))) + (chess-search-position position target + (if color piece + (downcase piece)))) (if (= (length candidates) 1) (list (car candidates) target) (if (null source) @@ -104,12 +99,11 @@ This regexp handles both long and short form.") (if mate (nconc changes (list (if (equal mate "#") - ':checkmate - ':check)))) - (and changes - (apply 'chess-ply-create position changes)))) + :checkmate + :check)))) + (and changes (apply 'chess-ply-create position changes)))) -(defun chess-ply-to-algebraic (ply &optional long search-func) +(defun chess-ply-to-algebraic (ply &optional long) "Convert the given PLY to algebraic notation. If LONG is non-nil, render the move into long notation." (if (null (car (chess-ply-changes ply))) @@ -129,9 +123,7 @@ If LONG is non-nil, render the move into long notation." (if (= to (chess-rf-to-index (if color 7 0) 2)) "O-O-O")))) str - (let ((candidates (funcall (or search-func - 'chess-standard-search-position) - pos to from-piece)) + (let ((candidates (chess-search-position pos to from-piece)) (rank 0) (file 0) (from-rank (/ from 8)) (from-file (mod from 8)) @@ -162,12 +154,12 @@ If LONG is non-nil, render the move into long notation." (if (/= ? (chess-pos-piece pos to)) "x" (if long "-")) (chess-index-to-coord to) - (let ((promote (memq ':promote changes))) + (let ((promote (memq :promote changes))) (if promote (concat "=" (char-to-string (cadr promote)))))))))) (concat notation - (if (memq ':check changes) "+" - (if (memq ':checkmate changes) "#")))))) + (if (memq :check changes) "+" + (if (memq :checkmate changes) "#")))))) (provide 'chess-algebraic) |
