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

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

[elpa] 01/02: [gnugo int] Support growth also off of main line.


From: Thien-Thi Nguyen
Subject: [elpa] 01/02: [gnugo int] Support growth also off of main line.
Date: Fri, 04 Apr 2014 10:45:39 +0000

ttn pushed a commit to branch master
in repository elpa.

commit 1cf88b8f995a63e71a223d4188b18d8dfa523e8a
Author: Thien-Thi Nguyen <address@hidden>
Date:   Fri Apr 4 12:11:32 2014 +0200

    [gnugo int] Support growth also off of main line.
    
    * packages/gnugo/gnugo.el (gnugo-note):
    For déjà-vu check, don't start w/ ‘bidx’ if no regrets;
    also, copy the old branch immediately to its right,
    instead of placing it at the end of the ends vector.
---
 packages/gnugo/gnugo.el |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index a58313b..ca8042a 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -953,22 +953,21 @@ are dimmed.  The buffer is in View minor mode."
           ;;   X---Y---A         new
           ;;            \
           ;;             --B     old
-          ;;
-          ;; This presumes ‘bidx’ is 0 (main line) and that
-          ;; all growth should occur on the main line.
           (cl-flet
               ((continue-on (bx)
                             (rotatef (aref tree bidx)
                                      (aref tree bx))))
-            ;; ugh, quadratic
             (loop
              with count = (length tree)
              with (bx previous)
              for i
              ;; Start with latest / highest likelihood for hit.
              ;; todo: prune unfeasible candidates
-             from 0 above (- count)
-             if (setq bx (mod i count)
+             from (if (gnugo--no-regrets monkey tree)
+                      1
+                    0)
+             below count
+             if (setq bx (mod (+ bidx i) count)
                       previous
                       ;; todo: early termination based on move number
                       (loop for m on (aref tree bx)
@@ -993,8 +992,10 @@ are dimmed.  The buffer is in View minor mode."
                  ;; <grumble grumble> SGF sez "move" node in the root
                  ;; position of a (sub-)gametree is "bad style".  :-/
                  (let ((where (memq tree (gnugo-get :sgf-collection))))
-                   (setq tree (apply 'vector (append tree (list mem))))
-                   (continue-on count)
+                   (setq tree (let ((ls (append tree nil)))
+                                ;; copy old to the right of new
+                                (push mem (nthcdr bidx ls))
+                                (apply 'vector ls)))
                    (gnugo-put :sgf-gametree tree)
                    (setcar where tree)))
                (push fruit mem)



reply via email to

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