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

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

[elpa] externals/gnugo 0f9f540 125/357: [gnugo int] Maintain tree MNUM.


From: Stefan Monnier
Subject: [elpa] externals/gnugo 0f9f540 125/357: [gnugo int] Maintain tree MNUM.
Date: Sun, 29 Nov 2020 14:51:04 -0500 (EST)

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

    [gnugo int] Maintain tree MNUM.
    
    * packages/gnugo/gnugo.el (gnugo--tree-mnum): New defsubst.
    (gnugo-note): Record new node's move number in the tree MNUM.
    (gnugo/sgf-create): Change tree MNUM weakness to ‘key’.
---
 gnugo.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/gnugo.el b/gnugo.el
index a03cfd6..acd42f4 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -248,6 +248,9 @@ As things stabilize probably more info will be added to 
this docstring."
 See `gnugo-put'."
   (gethash key gnugo-state))
 
+(defsubst gnugo--tree-mnum (tree)
+  (aref tree 0))
+
 (defsubst gnugo--tree-ends (tree)
   (aref tree 2))
 
@@ -959,10 +962,12 @@ are dimmed.  The buffer is in View minor mode."
   (let* ((pair (cons property value))
          (fruit (list pair))
          (monkey (gnugo-get :monkey))
-         (mem (aref monkey 0)))
+         (mem (aref monkey 0))
+         (tip (car mem)))
     (if (memq property '(:B :W))
         (let* ((tree (gnugo-get :sgf-gametree))
                (ends (gnugo--tree-ends tree))
+               (mnum (gnugo--tree-mnum tree))
                (bidx (aref monkey 1)))
           ;; Detect déjà-vu.  That is, when placing "A", avoid:
           ;;
@@ -1013,11 +1018,12 @@ are dimmed.  The buffer is in View minor mode."
                        ;; copy old to the right of new
                        (push mem (nthcdr bidx ls))
                        (apply 'vector ls))))
+             (puthash fruit (1+ (gethash tip mnum)) mnum)
              (push fruit mem)
              (aset ends bidx mem)))
           (setf (aref monkey 0) mem)
           (incf (aref monkey 2)))
-      (setcdr (last (car mem)) fruit))))
+      (setcdr (last tip) fruit))))
 
 (defun gnugo-close-game (end-time resign)
   (gnugo-put :game-end-time end-time)
@@ -2543,7 +2549,7 @@ A collection is a list of gametrees, each a vector of 
four elements:
           (insert file-or-data)
           (goto-char (point-min)))
         (loop while (morep)
-              collect (let* ((mnum (gnugo--mkht))
+              collect (let* ((mnum (gnugo--mkht :weakness 'key))
                              (kids (gnugo--mkht))
                              (ends (TREE nil mnum kids))
                              (root (car (last (car ends)))))



reply via email to

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