diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-03-29 00:16:04 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-03-29 00:16:04 +0000 |
| commit | 64c93c53e491a6586b8eef6b0b532cb42aa44f46 (patch) | |
| tree | 0071e5bb0bf444f09252e7f9a19bb95b50b36b17 /chess-game.el | |
| parent | 3fb06cec99edf60ae82dcd3f807ee2b21c90fe8d (diff) | |
changed interface to chess-game-create
Diffstat (limited to 'chess-game.el')
| -rw-r--r-- | chess-game.el | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/chess-game.el b/chess-game.el index e6b70fa..034bbe9 100644 --- a/chess-game.el +++ b/chess-game.el @@ -11,6 +11,7 @@ (require 'chess-ply) (require 'chess-algebraic) +(require 'chess-fen) (defvar chess-illegal nil) (put 'chess-illegal 'error-conditions '(error)) @@ -93,24 +94,22 @@ "Return the position related to GAME's INDEX position." (car (chess-game-ply game index))) -(defun chess-game-create (&rest keywords) +(defun chess-game-create (&optional position search-func tags) "Create a new chess game object. -Keywords may be specified to customize the game object. The supported -keywords are: - - :position POS ; set the start position - :search FUNC ; function used to search chess positions - :tags ALIST" - (let ((game (list (cdr (assq ':tags keywords)) - (or (cdr (assq ':search keywords)) - 'chess-standard-search-position)))) +Optionally use the given starting POSITION (which is recorded using +the game's FEN tag). +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)))) (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 (cdr (assq ':position keywords)) - (chess-pos-create)))) + (chess-game-add-ply game (chess-ply-create (or position (chess-pos-create)))) + (if position + (chess-game-set-tag game "FEN" (chess-pos-to-fen position))) game)) (defun chess-game-move (game ply) |
