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

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

[elpa] 02/03: [gnugo int] Move precise fanout computation to "breathe in


From: Thien-Thi Nguyen
Subject: [elpa] 02/03: [gnugo int] Move precise fanout computation to "breathe in".
Date: Mon, 07 Apr 2014 12:17:47 +0000

ttn pushed a commit to branch master
in repository elpa.

commit 96eb56ead370239b91308c9d3a37f20313cb8e0a
Author: Thien-Thi Nguyen <address@hidden>
Date:   Mon Apr 7 13:21:16 2014 +0200

    [gnugo int] Move precise fanout computation to "breathe in".
    
    * packages/gnugo/gnugo.el (gnugo-frolic-in-the-leaves link):
    Use ‘pushnew’; push the node's branch number directly.
    (gnugo-frolic-in-the-leaves): Check for continuation node
    prior to appending ‘acc’; link it only on non-empty ‘acc’;
    in "breathe out", accumulate into ‘forks’ directly.
---
 packages/gnugo/gnugo.el |   28 ++++++++++++----------------
 1 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index a953a5c..1ec7b24 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -774,21 +774,23 @@ are dimmed.  The buffer is in View minor mode."
         (loop
          for bx below width
          do (loop
-             with (bef acc node fork cur)
+             with (acc node fork)
              for ls on (aref ends bx)
              do (if (setq node (car ls)
                           fork (on node))
                     (cl-flet
                         ((link (other)
-                               (push other (gethash node soil))))
-                      (let ((move-num (gethash node mnum)))
-                        ;; ugh, wasteful
-                        (when (setq bef (copy-sequence (aref eert fork)))
-                          (setcdr (nthcdr (1- move-num) bef)
-                                  acc))
+                               (pushnew other (gethash node soil))))
+                      (let* ((move-num (gethash node mnum))
+                             (bef (copy-sequence (aref eert fork)))
+                             (cur (nthcdr (1- move-num) bef))
+                             (cont (cdr cur)))
+                        (setcdr cur acc)
                         (aset eert bx (or bef acc))
                         (when acc
-                          (link (car acc)))))
+                          (when cont
+                            (link fork))
+                          (link bx))))
                   (puthash node bx seen)
                   (when (gnugo--move-prop node)
                     (push node acc)))
@@ -823,15 +825,9 @@ are dimmed.  The buffer is in View minor mode."
                   (s (cond ((not node) "")
                            ((not (setq move (gnugo--move-prop node))) "-")
                            (t (funcall as-pos (cdr move))))))
-             ;; todo: move this into "breathe in"
              (when (and ok (setq br (gethash node soil)))
-               (setq br (delq bx (mapcar #'on br)))
-               (when (and br (car (aref eert bx)))
-                 (push bx br))
-               ;; do not point w/ a fist
-               (when br
-                 (push (cons bx (sort br '<))
-                       forks)))
+               (push (cons bx (sort br '<))
+                     forks))
              (fsi " %-5s"
                   (cond ((and (eq at node)
                               (or ok (= bx bidx)))



reply via email to

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