summaryrefslogtreecommitdiff
path: root/chess-fen.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2002-04-15 02:07:36 +0000
committerJohn Wiegley <johnw@newartisans.com>2002-04-15 02:07:36 +0000
commitb24315b28140dac7cf10828394ff347c4ad3e985 (patch)
tree8fa41f8fc2a953f1c9fcf8c9e11cd290299e265f /chess-fen.el
parent7365cd3c961dece991bc67017afcc917359be69a (diff)
*** no comment ***
Diffstat (limited to 'chess-fen.el')
-rw-r--r--chess-fen.el31
1 files changed, 20 insertions, 11 deletions
diff --git a/chess-fen.el b/chess-fen.el
index b104f06..bd540a3 100644
--- a/chess-fen.el
+++ b/chess-fen.el
@@ -46,9 +46,10 @@
(let ((i 0) (l (length fen))
(rank 0) (file 0) (c ?0)
(position (chess-pos-create t))
- error number)
- (while (and (null error) (/= c ? ) (< i l))
- (setq c (aref fen i))
+ error (space-count 0))
+ (setq c (aref fen i))
+ (while (and (null error)
+ (/= c ? ) (< i l))
(cond
((= c ?/)
(setq file 0 rank (1+ rank)))
@@ -57,15 +58,22 @@
((memq (upcase c) '(?K ?Q ?B ?N ?R ?P))
(chess-pos-set-piece position (chess-rf-to-index rank file) c)
(setq file (1+ file)))
- (t (setq error t)))
- (setq i (1+ i)))
+ (t
+ (setq error t)))
+ (setq i (1+ i) c (aref fen i)))
+ (if (= (aref fen i) ? )
+ (setq i (1+ i)))
(if (memq (aref fen i) '(?b ?w))
- (chess-pos-set-side-to-move position (= (aref fen i) ?w))
+ (progn
+ (chess-pos-set-side-to-move position (= (aref fen i) ?w))
+ (setq i (+ i 2)))
(setq error t))
- (setq i (+ i 2) number nil)
- (while (and (null error) (< i l))
- (setq c (aref fen i))
+ (setq c (aref fen i))
+ (while (and (null error)
+ (< space-count 2) (< i l))
(cond
+ ((= c ?-))
+ ((= c ? ) (setq space-count (1+ space-count)))
((= c ?K) (chess-pos-set-can-castle position ?K t))
((= c ?Q) (chess-pos-set-can-castle position ?Q t))
((= c ?k) (chess-pos-set-can-castle position ?k t))
@@ -74,8 +82,9 @@
(chess-pos-set-en-passant position (chess-coord-to-index
(substring fen i (+ i 2))))
(setq i (1+ i)))
- (t (setq error t)))
- (setq i (1+ i)))
+ (t
+ (setq error t)))
+ (setq i (1+ i) c (aref fen i)))
(unless error
position)))