summaryrefslogtreecommitdiff
path: root/chess-algebraic.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2002-03-01 08:08:28 +0000
committerJohn Wiegley <johnw@newartisans.com>2002-03-01 08:08:28 +0000
commit059e5edba1175504698637f734eb5bf975b299fa (patch)
tree95e6f08169d73d1ce763ae90945204783c0132eb /chess-algebraic.el
parentf115e4627966ae900aef55cb10f9e6207dbe7adf (diff)
Playing against crafty now works.
Diffstat (limited to 'chess-algebraic.el')
-rw-r--r--chess-algebraic.el17
1 files changed, 9 insertions, 8 deletions
diff --git a/chess-algebraic.el b/chess-algebraic.el
index 6e6ba83..0b041cb 100644
--- a/chess-algebraic.el
+++ b/chess-algebraic.el
@@ -34,16 +34,17 @@
;; $Revision$
(require 'chess-pos)
+(require 'chess-ply)
(defconst chess-algebraic-pieces-regexp "[RNBKQ]")
(defconst chess-algebraic-regexp
(format (concat "\\("
- "O-O\\(-O\\)?\\|"
- "\\(%s\\(\\([a-h]\\|[1-8]\\)?\\|[a-h][1-8]\\)\\)?"
- "\\([x-]\\)?"
- "\\([a-h][1-8]\\)"
- "\\(=\\(%s\\)\\)?"
+ "O-O\\(-O\\)?\\|"
+ "\\(%s?\\(\\([a-h]\\|[1-8]\\)?\\|[a-h][1-8]\\)\\)?"
+ "\\([x-]\\)?"
+ "\\([a-h][1-8]\\)"
+ "\\(=\\(%s\\)\\)?"
"\\)"
"\\([#+]\\)?")
chess-algebraic-pieces-regexp
@@ -54,8 +55,9 @@ This regexp handles both long and short form.")
(defun chess-algebraic-to-ply (position move)
"Convert the algebraic notation MOVE for POSITION to a ply."
(when (string-match chess-algebraic-regexp move)
- (let* ((piece (aref move 0))
+ (let* ((color (chess-pos-side-to-move position))
(mate (match-string 10 move))
+ (piece (aref move 0))
(changes
(if (eq piece ?O)
(let ((rank (if color 7 0))
@@ -68,8 +70,7 @@ This regexp handles both long and short form.")
(target (chess-coord-to-index (match-string 7 move))))
(if (and source (= (length source) 2))
(list (chess-coord-to-index source) target)
- (let ((color (chess-pos-side-to-move position))
- candidates which)
+ (let (candidates which)
(unless (< piece ?a)
(setq piece ?P))
;; we must use our knowledge of how pieces can