[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo 7705eca 126/357: [gnugo int] Drop :monkey COUNT;
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo 7705eca 126/357: [gnugo int] Drop :monkey COUNT; use node's tree MNUM directly. |
Date: |
Sun, 29 Nov 2020 14:51:04 -0500 (EST) |
branch: externals/gnugo
commit 7705ecad7946174623f5c15e3bc749896b57f462
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[gnugo int] Drop :monkey COUNT; use node's tree MNUM directly.
* packages/gnugo/gnugo.el (gnugo-put): Update :monkey description.
(gnugo-describe-internal-properties):
Use ‘gnugo--tree-mnum’; don't bother w/ :monkey COUNT.
(gnugo-move-history): Use first node's tree MNUM directly.
(gnugo-frolic-in-the-leaves): Compute ‘max-move-num’
from ‘ends’ nodes' tree MNUM directly; drop hash table ‘order’.
(gnugo-note, gnugo-magic-undo): Don't update :monkey COUNT.
(gnugo-read-sgf-file, gnugo-board-mode): Don't init :monkey COUNT.
---
gnugo.el | 46 +++++++++++++++++-----------------------------
1 file changed, 17 insertions(+), 29 deletions(-)
diff --git a/gnugo.el b/gnugo.el
index acd42f4..f8da28b 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -206,10 +206,9 @@ you may never really understand to any degree of personal
satisfaction\".
:sgf-gametree -- one of the gametrees in :sgf-collection
- :monkey -- vector of three elements:
+ :monkey -- vector of two elements:
MEM, a pointer to one of the branches in the gametree;
- BIDX, the index of the \"current branch\"; and
- COUNT, the number of moves from the beginning of the game
+ BIDX, the index of the \"current branch\"
:gnugo-color -- either \"black\" or \"white\"
:user-color
@@ -278,14 +277,13 @@ Handle the big, slow-to-render, and/or uninteresting ones
specially."
(length val))
(:sgf-gametree
(list (hash-table-count
- (aref val 0))
+ (gnugo--tree-mnum val))
(hash-table-count
(aref val 1))
(gnugo--tree-ends val)))
(:monkey
(let ((mem (aref val 0)))
(list (aref val 1)
- (aref val 2)
(car mem))))
(t val)))
acc))
@@ -708,7 +706,8 @@ For all other values of RSEL, do nothing and return nil."
(`nil (finish nil))
(`car (car (nn)))
(`cadr (nn) (car (nn)))
- (`count (aref monkey 2))
+ (`count (gethash (car mem) (gnugo--tree-mnum
+ (gnugo-get :sgf-gametree))))
(`two (nn) (nn) acc)
(_ nil)))))
@@ -749,6 +748,7 @@ are dimmed. The buffer is in View minor mode."
:foreground "gray50"))
(tree (gnugo-get :sgf-gametree))
(ends (gnugo--tree-ends tree))
+ (mnum (gnugo--tree-mnum tree))
(seen (gnugo--mkht))
(soil (gnugo--mkht))
(width (length ends))
@@ -757,7 +757,9 @@ are dimmed. The buffer is in View minor mode."
(as-pos (gnugo--as-pos-func (gnugo-get :SZ)))
(at (car (aref monkey 0)))
(bidx (aref monkey 1))
- (max-move-num (aref monkey 2))
+ (max-move-num (loop for bx in lanes
+ maximize (gethash (car (aref ends bx))
+ mnum)))
(eert (make-vector width nil))
finish)
(cl-flet
@@ -768,18 +770,14 @@ are dimmed. The buffer is in View minor mode."
(fsi (fmt &rest args)
(insert (apply 'format fmt args))))
;; breathe in
- (let ((order (gnugo--mkht))
- (monkey-on-main-line (zerop bidx))
+ (let ((monkey-on-main-line (zerop bidx))
fixup)
;; monkey knows a lot
- (loop with move-num = (1+ max-move-num)
- with acc
+ (loop with acc
for node in (aref monkey 0)
do (puthash node bidx seen)
if (gnugo--move-prop node)
- do (progn
- (push node acc)
- (puthash node (decf move-num) order))
+ do (push node acc)
finally do (progn
(unless monkey-on-main-line
(setq fixup (apply 'vector acc)))
@@ -795,7 +793,7 @@ are dimmed. The buffer is in View minor mode."
(cl-flet
((link (other)
(push other (gethash node soil))))
- (let ((move-num (gethash node order)))
+ (let ((move-num (gethash node mnum)))
(when (< bx fork)
(assert (and (not monkey-on-main-line)
(= fork bidx)))
@@ -809,11 +807,6 @@ are dimmed. The buffer is in View minor mode."
(setcdr (nthcdr (1- move-num) bef)
acc))
(aset eert bx (or bef acc))
- (dolist (node acc)
- (puthash node (incf move-num)
- order))
- (setq max-move-num (max max-move-num
- move-num))
(when acc
(link (car acc)))))
(puthash node bx seen)
@@ -1021,8 +1014,7 @@ are dimmed. The buffer is in View minor mode."
(puthash fruit (1+ (gethash tip mnum)) mnum)
(push fruit mem)
(aset ends bidx mem)))
- (setf (aref monkey 0) mem)
- (incf (aref monkey 2)))
+ (setf (aref monkey 0) mem))
(setcdr (last tip) fruit))))
(defun gnugo-close-game (end-time resign)
@@ -1646,13 +1638,10 @@ If FILENAME already exists, Emacs confirms that you
wish to overwrite it."
coll))
(gnugo-put :sgf-collection coll)
(gnugo-put :sgf-gametree tree)
+ (gnugo-put :monkey (vector (aref (gnugo--tree-ends tree) 0) 0))
;; This is deliberately undocumented for now.
(gnugo--SZ! (gnugo--root-prop :SZ tree))
- (let* ((mem (aref (gnugo--tree-ends tree) 0))
- game-over)
- (gnugo-put :monkey
- (vector mem 0 (loop for node in mem
- count (gnugo--move-prop node))))
+ (let (game-over)
(gnugo-put :game-over
(setq game-over
(or (gnugo--root-prop :RE tree)
@@ -1723,7 +1712,6 @@ when play resumes."
(setq ans (gnugo--q "undo"))
(unless (= ?= (aref ans 0))
(user-error "%s" ans))
- (decf (aref monkey 2))
(pop (aref monkey 0))
(gnugo-put :last-mover (gnugo-other (gnugo-get :last-mover)))
(gnugo-merge-showboard-results) ; all
@@ -2097,7 +2085,7 @@ In this mode, keys do not self insert.
(tree (car coll)))
(gnugo-put :sgf-gametree tree)
(gnugo-put :sgf-collection coll)
- (gnugo-put :monkey (vector (aref (gnugo--tree-ends tree) 0) 0 0)))
+ (gnugo-put :monkey (vector (aref (gnugo--tree-ends tree) 0) 0)))
(gnugo--SZ! board-size)
(loop with gb = (gnugo--blackp (gnugo-other user-color))
for (property value &optional mogrifyp) in
- [elpa] externals/gnugo 7f380e4 006/357: [gnugo] Presume working time-date.el., (continued)
- [elpa] externals/gnugo 7f380e4 006/357: [gnugo] Presume working time-date.el., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 74b839a 066/357: [gnugo int] Use ‘incf’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo ad774f4 074/357: [gnugo sgf] Move gratuitous newline from after to before (sub)trees., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a44da1b 073/357: [gnugo sgf int] Add abstractions: >>prop, >>node, >>tree, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a7f01be 083/357: [gnugo int] Add abstraction: nn, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a07cf7c 109/357: [gnugo int] Use ‘gnugo--as-pos-func’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 71f163d 111/357: [gnugo int] Support growth also off of main line., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 0b08017 114/357: [gnugo int] Avoid double list-reverse., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 08c3378 116/357: [gnugo int] Use ‘gnugo/sgf-create’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 44c2dc4 118/357: [gnugo int] Make ‘gnugo--no-regrets’ take ENDS directly., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 7705eca 126/357: [gnugo int] Drop :monkey COUNT; use node's tree MNUM directly.,
Stefan Monnier <=
- [elpa] externals/gnugo 4b24b56 142/357: [gnugo frolic int] Don't go through ‘gnugo-frolic-quit’ for refresh., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo dfc130d 136/357: [gnugo frolic] Add backward/forward branch navigation commands., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e75eb8a 135/357: [gnugo frolic] Add some branch swizzling commands., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo f279f99 146/357: [gnugo frolic int] Regularize keymap decl + init., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo f810771 162/357: [gnugo int] Decruft: Delete unused local vars., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo b0d3543 171/357: fixup! [gnugo frolic] Add previous/next move navigation commands., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo bcc7fef 166/357: [gnugo maint] Update HACKING; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 9589d64 167/357: [gnugo int] Add abstraction: gnugo--as-cc-func, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo d71bab7 174/357: [gnugo int] Add abstractions: gnugo--{user-}play-stone, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e3a50ca 014/357: [gnugo int] Use ‘display’ property more., Stefan Monnier, 2020/11/29