[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo 273da4b 098/357: [gnugo sgf] Normalize PASS inter
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo 273da4b 098/357: [gnugo sgf] Normalize PASS internal rep on read, as "". |
Date: |
Sun, 29 Nov 2020 14:50:57 -0500 (EST) |
branch: externals/gnugo
commit 273da4be7bdd32f9def6adc155b50156b782ebb8
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[gnugo sgf] Normalize PASS internal rep on read, as "".
* packages/gnugo/gnugo.el
(gnugo-move-history as-pos): Expect "" for PASS.
(gnugo-note mog): Produce "" for PASS.
(gnugo-read-sgf-file): Don't normalize PASS to "tt".
(gnugo/sgf-read-file): Keep track of SZ property.
(gnugo/sgf-read-file one): For ‘stone’, ‘point’ and ‘move’
types, substitute "tt" with "" if we know ‘SZ’ and it's <= 19.
(gnugo/sgf-read-file NODE): Save SZ property value if found.
---
NEWS | 1 +
gnugo.el | 32 ++++++++++++++++++++------------
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/NEWS b/NEWS
index 38220a7..5c0c5bc 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ Hint: (highlight-phrase
"[0-9][.][0-9][.][0-9]+\\|[0-9]+[.][.][0-9]+"
- display "resign" as "resign" in move history (amazing!)
- avoid clobbering SGF property ‘EV’ on resignation
- follow main line in subtrees on read
+ - PASS for SZ <= 19 normalized to "" on read, written as ""
- new keybinding for ‘gnugo-undo-one-move’: M-u
- ‘gnugo-undo-one-move’ can optionally arrange for you to play next
- ‘gnugo-move-history’ returns last two moves w/ RSEL ‘two’
diff --git a/gnugo.el b/gnugo.el
index 4ff6621..faefa8a 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -649,7 +649,7 @@ For all other values of RSEL, do nothing and return nil."
col
acc node mprop move)
(cl-labels
- ((as-pos (cc) (if (string= "tt" cc)
+ ((as-pos (cc) (if (string= "" cc)
"PASS"
(setq col (aref cc 0))
(format "%c%d"
@@ -695,7 +695,7 @@ For all other values of RSEL, do nothing and return nil."
(let ((sz (gnugo-get :SZ)))
(cl-labels
((mog (pos) (if (gnugo--passp pos)
- "tt"
+ ""
(let* ((col (aref pos 0))
(one (+ ?a (- col (if (< ?H col) 1 0) ?A)))
(two (+ ?a (- sz (string-to-number
@@ -1341,19 +1341,15 @@ If FILENAME already exists, Emacs confirms that you
wish to overwrite it."
(gnugo--SZ! (gnugo--root-prop :SZ tree))
(let* ((loc tree)
(count 0)
- mem node play game-over)
+ mem node game-over)
(while (setq node (car loc))
;; A gametree must have at least one node prior to the first
;; sub-gametree (if any), so we need check the CAR only once.
(unless (gnugo--nodep node)
(setq loc node
node (car loc)))
- (when (setq play (or (assq :B node)
- (assq :W node)))
- ;; SGF[4] allows "" to mean PASS. For now,
- ;; we normalize here instead of at the lower layer.
- (when (string= "" (cdr play))
- (setcdr play "tt"))
+ (when (or (assq :B node)
+ (assq :W node))
(incf count)
(push loc mem))
(setq loc (cdr loc)))
@@ -2092,7 +2088,8 @@ starting a new one. See `gnugo-board-mode' documentation
for more info."
(put 'gnugo/sgf-*r4-properties* :specs
(mapcar (lambda (full)
(cons (car full) (cdddr full)))
- gnugo/sgf-*r4-properties*)))))
+ gnugo/sgf-*r4-properties*))))
+ SZ)
(cl-labels
((sw () (skip-chars-forward " \t\n"))
(x (end) (let ((beg (point))
@@ -2117,7 +2114,15 @@ starting a new one. See `gnugo-board-mode'
documentation for more info."
(forward-char 1)
(x end))))
(case type
- ((stone point move simpletext color) s)
+ ((stone point move)
+ ;; blech, begone bu"tt"-ugly blatherings
+ ;; (but bide brobdingnagian boards)...
+ (if (and (string= "tt" s)
+ SZ
+ (>= 19 SZ))
+ ""
+ s))
+ ((simpletext color) s)
((number real double) (string-to-number s))
((text) s)
((none) "")
@@ -2176,7 +2181,10 @@ starting a new one. See `gnugo-board-mode'
documentation for more info."
(NODE () (when (seek-into ?\;)
(loop with prop
while (setq prop (PROP))
- collect prop)))
+ collect (progn
+ (when (eq :SZ (car prop))
+ (setq SZ (cdr prop)))
+ prop))))
(TREE (lev) (prog1
;; hmm
;; ‘append’ => ([NODE...] [SUBTREE...])
- [elpa] externals/gnugo f0aa02d 033/357: [gnugo int] Zonk unused local var., (continued)
- [elpa] externals/gnugo f0aa02d 033/357: [gnugo int] Zonk unused local var., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 74ff909 038/357: [gnugo] Fix bug: Relax sync regexp., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo f09af15 058/357: [gnugo maint] Reindent; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 052ea8a 045/357: [gnugo] New command: ‘A’ (gnugo-switch-to-another), Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 6e26e76 061/357: [gnugo int] Add abstraction: gnugo--begin-exchange, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo b6bb24d 057/357: [gnugo int] Use ‘eq’ less., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo ae25c81 050/357: [gnugo maint] Update NEWS, HACKING; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo f282ec7 063/357: [gnugo int] Associate process w/ buffer immediately., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 8e3f44e 070/357: [gnugo] Make ‘C-u M-u’ switch roles., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo d02a500 095/357: [gnugo maint] NEWS futzing; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 273da4b 098/357: [gnugo sgf] Normalize PASS internal rep on read, as "".,
Stefan Monnier <=
- [elpa] externals/gnugo 61be18a 022/357: [gnugo maint] Add .dir-locals.el file, link in HACKING; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 0c7bc82 025/357: [gnugo int] Use cl-{plus, minus}p more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 6d835b3 023/357: [gnugo int] Drop unused local var., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 2a75447 034/357: [gnugo int] Use ‘set-process-query-on-exit-flag’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo bd4d40f 028/357: [gnugo int] Drop leading "*" in docstrings., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 7ef5c66 036/357: [gnugo int] Revamp gnugo-{put, get} doc / indentation decl., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo d41a581 029/357: [gnugo] Indicate buffer not modified after load., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 80a22a5 032/357: [gnugo] Use ‘user-error’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 423683d 055/357: [gnugo int] Use ‘dolist’, ‘destructuring-bind’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 7c3a30f 100/357: [gnugo int] Use ‘pop’ more., Stefan Monnier, 2020/11/29