diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-04-16 22:48:12 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-04-16 22:48:12 +0000 |
| commit | bc2e50417174e3d96489951eef50d4250bca1843 (patch) | |
| tree | af11d83b6a5676faf66cfe028b6f9d943166388f /chess-game.el | |
| parent | 63e44a6be978999ff23b8ba754d8ad3c9fc78969 (diff) | |
More efficiency improvements.
Diffstat (limited to 'chess-game.el')
| -rw-r--r-- | chess-game.el | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/chess-game.el b/chess-game.el index f39a3e2..a34d6a3 100644 --- a/chess-game.el +++ b/chess-game.el @@ -144,8 +144,7 @@ matches." (defun chess-game-status (game &optional index) "Return a symbol, such as :checkmate, :resign, etc. This conveys the status of the game at the given index." - (or (car (chess-pos-status - (chess-game-pos chess-module-game index))) + (or (chess-pos-status (chess-game-pos chess-module-game index)) (let ((final (chess-ply-final-p (chess-game-ply chess-module-game index)))) (and (memq final '(:resign :draw :perpetual :repetition)) @@ -239,20 +238,18 @@ progress (nil), if it is drawn, resigned, mate, etc." (chess-ply-set-changes current-ply changes) (chess-game-add-ply game (chess-ply-create* (chess-ply-next-pos current-ply) t)) - (cond - ((chess-ply-any-keyword ply :draw :perpetual :repetition :stalemate) - (chess-game-set-tag game "Result" "1/2-1/2") - (chess-game-run-hooks game 'game-drawn)) - - ((chess-ply-any-keyword ply :resign :checkmate) - (let ((color (chess-game-side-to-move game))) - (chess-game-set-tag game "Result" (if color "0-1" "1-0")) - (if (chess-ply-keyword ply :resign) - (chess-game-run-hooks game 'resign color) - (chess-game-run-hooks game 'move current-ply)))) - - (t - (chess-game-run-hooks game 'move current-ply))) + (if (> (length changes) 2) + (if (chess-ply-any-keyword ply :resign :checkmate) + (let ((color (chess-game-side-to-move game))) + (chess-game-set-tag game "Result" (if color "0-1" "1-0")) + (if (chess-ply-keyword ply :resign) + (chess-game-run-hooks game 'resign color) + (chess-game-run-hooks game 'move current-ply))) + (when (chess-ply-any-keyword ply :draw :perpetual :repetition + :stalemate) + (chess-game-set-tag game "Result" "1/2-1/2") + (chess-game-run-hooks game 'drawn))) + (chess-game-run-hooks game 'move current-ply)) (chess-game-run-hooks game 'post-move))) (defsubst chess-game-end (game keyword) |
