[Top][All Lists]

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

[elpa] externals/gnugo e16a8d5 031/357: [gnugo int] Add abstraction: gnu

From: Stefan Monnier
Subject: [elpa] externals/gnugo e16a8d5 031/357: [gnugo int] Add abstraction: gnugo--unclose-game
Date: Sun, 29 Nov 2020 14:50:41 -0500 (EST)

branch: externals/gnugo
commit e16a8d5b83037e80661d87025ea94e691bd25a20
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>

    [gnugo int] Add abstraction: gnugo--unclose-game
    * packages/gnugo/gnugo.el (gnugo--unclose-game): New func.
    (gnugo-magic-undo): Use it.
    (boardsize, clear_board, fixed_handicap):
    Likewise, in the value of the ‘:post-thunk’ property.
 gnugo.el | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/gnugo.el b/gnugo.el
index 593aba2..8777864 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -695,6 +695,19 @@ For all other values of RSEL, do nothing and return nil."
         `((live ,@live)
           (dead ,@dead))))))
+(defun gnugo--unclose-game ()
+  (dolist (prop '(:game-over            ; all those in -close-game
+                  :scoring-seed
+                  :game-end-time))
+    (gnugo-put prop nil))
+  (let* ((root (car (gnugo-get :sgf-gametree)))
+         (cur (assq :RE root)))
+    (when cur
+      (assert (not (eq cur (car root))) nil
+              ":RE at head of root node: %S"
+              root)
+      (delq cur root))))
 (defun gnugo-push-move (userp move)
   (let* ((color (gnugo-get (if userp :user-color :gnugo-color)))
          (start (gnugo-get :waiting-start))
@@ -1325,7 +1338,7 @@ turn to play.  Optional second arg NOALT non-nil inhibits 
                  (error "%s not occupied by %s" pos u)))))
           (t (error "Bad spec: %S" spec)))
     (when (gnugo-get :game-over)
-      (gnugo-put :game-over nil))
+      (gnugo--unclose-game))
     (while (not (funcall done))
       (setq ans (cdr (gnugo-synchronous-send/return "undo")))
       (unless (= ?= (aref ans 0))
@@ -1904,7 +1917,7 @@ starting a new one.  See `gnugo-board-mode' documentation 
for more info."
       :output :discard
       :post-thunk (lambda ()
-                    (gnugo-put :game-over nil)
+                    (gnugo--unclose-game)
                     (gnugo-put :last-mover nil)
                     (gnugo-refresh t)))

reply via email to

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