emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 01/01: [gnugo] Move "1 or 2" cal culation into ‘gnugo-magic-undo’


From: Thien-Thi Nguyen
Subject: [elpa] 01/01: [gnugo] Move "1 or 2" cal culation into ‘gnugo-magic-undo’.
Date: Fri, 28 Mar 2014 11:49:35 +0000

ttn pushed a commit to branch master
in repository elpa.

commit aa415e399694a1cfddba1bc1e05bdc31aeeb35d9
Author: Thien-Thi Nguyen <address@hidden>
Date:   Fri Mar 28 12:24:44 2014 +0100

    [gnugo] Move "1 or 2" calculation into ‘gnugo-magic-undo’.
    
    * packages/gnugo/gnugo.el (gnugo-magic-undo): ...here.
    (gnugo-undo-two-moves): Update call to ‘gnugo-magic-undo’.
---
 packages/gnugo/NEWS     |    1 +
 packages/gnugo/gnugo.el |   16 ++++++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/packages/gnugo/NEWS b/packages/gnugo/NEWS
index 9e52778..47f570b 100644
--- a/packages/gnugo/NEWS
+++ b/packages/gnugo/NEWS
@@ -19,6 +19,7 @@ NB: "RCS: X..Y " means that the particular release includes
   - performance improvements
   - of interest to hackers (see source, BI => backward incompatible)
     - ‘:sgf-gametree’ internal representation inverted (BI)
+    - ‘gnugo-magic-undo’ handles SPEC ‘0’
 
 - 2.3.1 | 2014-02-27
   - portability fixes
diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 4e58013..9cd05fc 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -1364,6 +1364,8 @@ check that the position is occupied by a stone of the 
user's color,
 and if so, remove moves from the history until that position is clear.
 If SPEC is a positive number, remove exactly that many moves from the
 history, signaling an error if the history is exhausted before finishing.
+If SPEC Is 0 (zero), remove either one or two moves,
+so that you are to play next.
 If SPEC is not recognized, signal \"bad spec\" error.
 
 Refresh the board for each move undone.  If (in the case where SPEC is
@@ -1377,8 +1379,13 @@ turn to play.  Optional second arg NOALT non-nil 
inhibits this."
          (user-color (gnugo-get :user-color))
          (monkey (gnugo-get :monkey))
          done ans)
-    (cond ((and (numberp spec) (cl-plusp spec))
-           (setq n spec done (lambda () (zerop n))))
+    (cond ((numberp spec)
+           (setq n (if (zerop spec)
+                       (if (string= user-color (gnugo-get :last-mover))
+                           1
+                         2)
+                     spec)
+                 done (lambda () (zerop n))))
           ((string-match "^[a-z]" spec)
            (let ((pos (upcase spec)))
              (setq done `(lambda ()
@@ -1446,10 +1453,7 @@ However, if you are the last mover, undo only one move.
 Regardless, after undoing, it is your turn to play again."
   (interactive)
   (gnugo-gate)
-  (gnugo-magic-undo (if (string= (gnugo-get :user-color)
-                                 (gnugo-get :last-mover))
-                        1
-                      2)))
+  (gnugo-magic-undo 0))
 
 (defun gnugo-display-final-score ()
   "Display final score and other info in another buffer (when game over).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]