summaryrefslogtreecommitdiff
path: root/chess-game.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2002-04-03 02:11:46 +0000
committerJohn Wiegley <johnw@newartisans.com>2002-04-03 02:11:46 +0000
commitbc1b6e4f3789f4401ac5fe9bb9708459648345b0 (patch)
tree61016ff5f23823fe740c16755ebf800cc6d6bb9b /chess-game.el
parentf4e9c77bc700222590ada4799c619152354244f2 (diff)
More work to get engines working.
Diffstat (limited to 'chess-game.el')
-rw-r--r--chess-game.el17
1 files changed, 11 insertions, 6 deletions
diff --git a/chess-game.el b/chess-game.el
index 1177b18..b321bd1 100644
--- a/chess-game.el
+++ b/chess-game.el
@@ -86,11 +86,14 @@
(nth index (chess-game-plies game))
(car (last (chess-game-plies game)))))
-(defsubst chess-game-add-ply (game ply)
+(defun chess-game-add-ply (game ply)
"Return the position related to GAME's INDEX position."
- (nconc (chess-game-plies game) (list ply)))
+ (let ((plies (chess-game-plies game)))
+ (if plies
+ (nconc plies (list ply))
+ (chess-game-set-plies game (list ply)))))
-(defun chess-game-pos (game &optional index)
+(defsubst chess-game-pos (game &optional index)
"Return the position related to GAME's INDEX position."
(car (chess-game-ply game index)))
@@ -102,13 +105,15 @@ SEARCH-FUNC specifies the function used to test the legality of moves.
TAGS is the starting set of game tags (which can always be changed
later using the various tag-related methods)."
(let ((game (list tags
- (or search-func 'chess-standard-search-position)
- (or position (chess-pos-create)))))
+ (or search-func 'chess-standard-search-position))))
(dolist (tag (cons (cons "Date" (format-time-string "%Y.%m.%d"))
chess-game-default-tags))
(unless (chess-game-tag game (car tag))
(chess-game-set-tag game (car tag) (cdr tag))))
- (chess-game-add-ply game (chess-ply-create (or position (chess-pos-create))))
+ (chess-game-add-ply game (chess-ply-create
+ (or (and position
+ (chess-pos-copy position))
+ (chess-pos-create))))
(if position
(chess-game-set-tag game "FEN" (chess-pos-to-fen position)))
game))