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

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

[elpa] 01/03: [gnugo maint] Add some debugging aids to HACKING; nfc.


From: Thien-Thi Nguyen
Subject: [elpa] 01/03: [gnugo maint] Add some debugging aids to HACKING; nfc.
Date: Thu, 03 Apr 2014 10:21:37 +0000

ttn pushed a commit to branch master
in repository elpa.

commit a50ddf42752df94490da46a0f70b7c3b5f23c075
Author: Thien-Thi Nguyen <address@hidden>
Date:   Thu Apr 3 11:51:50 2014 +0200

    [gnugo maint] Add some debugging aids to HACKING; nfc.
---
 packages/gnugo/HACKING |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/packages/gnugo/HACKING b/packages/gnugo/HACKING
index c0e05c4..f096de8 100644
--- a/packages/gnugo/HACKING
+++ b/packages/gnugo/HACKING
@@ -11,6 +11,37 @@ This file is both a guide for newcomers and a todo list for 
oldstayers.
 *** [[file:gnugo.el::defun.gnugo-toggle-dead-group][gnugo-toggle-dead-group]] 
only half-complete
 *** no error-handling in SGF parsing
 *** performance -- ‘compare-strings’ approach too clever/slow :-/
+* debugging aids
+*** swizzling branches for frolicking fun
+(defun SWIZ (a b)
+  (let* ((tree (gnugo-get :sgf-gametree))
+         (monkey (gnugo-get :monkey))
+         (bidx (aref monkey 1)))
+    (rotatef (aref tree a)
+             (aref tree b))
+    (cond ((= a bidx) (aset monkey 1 b))
+          ((= b bidx) (aset monkey 1 a)))))
+
+(defun SWIZ-RANDOM ()
+  (interactive)
+  (let* ((n (length (gnugo-get :sgf-gametree)))
+         (one (random n))
+         (two (if (= 1 n)
+                  one
+                (loop with try
+                      while (= one (setq try (random n)))
+                      finally return try))))
+    (SWIZ one two)
+    (message "%d <-> %d" one two)))
+
+(defun UNSWIZ ()
+  (interactive)
+  (let* ((monkey (gnugo-get :monkey))
+         (cur (aref monkey 1)))
+    (if (zerop cur)
+        (message "(nothing to do)")
+      (SWIZ 0 cur)
+      (message "0 <-> %d" cur))))
 * ideas / wishlist
 *** set ‘lexical-binding’ (if possible!)
     Hmm, lots of symbol trickery going on; initial attempts FAIL.



reply via email to

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