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

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

[elpa] 01/01: [gnugo int] Incorporate *-pla y-stone into ‘gnugo-push-mov


From: Thien-Thi Nguyen
Subject: [elpa] 01/01: [gnugo int] Incorporate *-pla y-stone into ‘gnugo-push-move’.
Date: Mon, 14 Apr 2014 08:53:10 +0000

ttn pushed a commit to branch master
in repository elpa.

commit f42a8819e6eeb8bba01496970f8159fcf7725414
Author: Thien-Thi Nguyen <address@hidden>
Date:   Mon Apr 14 10:51:00 2014 +0200

    [gnugo int] Incorporate *-play-stone into ‘gnugo-push-move’.
    
    U (X) ≡ "Don't call X".
    * packages/gnugo/gnugo.el (gnugo--play-stone): Delete func.
    (gnugo--user-play-stone): Delete defsubst.
    (gnugo-push-move): Do GTP "play COLOR MOVE" here.
    (gnugo-get-move-insertion-filter): U (gnugo--play-stone);
    make USERP arg to ‘gnugo-push-move’ depend on :waiting color.
    (gnugo-move, gnugo-pass): U (gnugo--user-play-stone).
    (gnugo-okay): U (gnugo--play-stone); decruft local vars.
    (gnugo-display-final-score): U (gnugo--play-stone).
---
 packages/gnugo/gnugo.el |   29 ++++++++---------------------
 1 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 09c2c76..bd1437a 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -419,14 +419,6 @@ when you are sure the command cannot fail."
       (push (cons prop value)
             (cdr (last root))))))
 
-(defun gnugo--play-stone (color pos-or-PASS)
-  (let ((accept (gnugo--q (format "play %s %s" color pos-or-PASS))))
-    (unless (= ?= (aref accept 0))
-      (user-error "%s" accept))))
-
-(defsubst gnugo--user-play-stone (pos-or-PASS)
-  (gnugo--play-stone (gnugo-get :user-color) pos-or-PASS))
-
 (defun gnugo-goto-pos (pos)
   "Move point to board position POS, a letter-number string."
   (goto-char (point-min))
@@ -1239,6 +1231,10 @@ This fails if the monkey is on the current branch
          (head (gnugo-move-history 'car))
          (onep (and head (gnugo--passp head)))
          (donep (or resignp (and onep passp))))
+    (unless resignp
+      (let ((accept (gnugo--q (format "play %s %s" color move))))
+        (unless (= ?= (aref accept 0))
+          (user-error "%s" accept))))
     (unless passp
       (gnugo-merge-showboard-results))
     (gnugo-put :last-mover color)
@@ -1559,8 +1555,8 @@ its move."
               (color (gnugo-get :waiting)))
           (gnugo-put :get-move-string nil)
           (gnugo-put :waiting nil)
-          (gnugo--play-stone color pos-or-pass)
-          (gnugo-push-move nil pos-or-pass)
+          (gnugo-push-move (string= color (gnugo-get :user-color))
+                           pos-or-pass)
           (let ((buf (current-buffer)))
             (let (gnugo-inhibit-refresh)
               (run-hooks 'gnugo-post-move-hook)
@@ -1610,7 +1606,6 @@ To start a game try M-x gnugo."
   (gnugo-gate t)
   (let* ((buf (current-buffer))
          (pos (gnugo-position)))
-    (gnugo--user-play-stone pos)
     (gnugo-push-move t pos)             ; value always nil for non-pass move
     (let (gnugo-inhibit-refresh)
       (run-hooks 'gnugo-post-move-hook)
@@ -1633,7 +1628,6 @@ Signal error if done out-of-turn or if game-over.
 To start a game try M-x gnugo."
   (interactive)
   (gnugo-gate t)
-  (gnugo--user-play-stone "PASS")
   (let ((donep (gnugo-push-move t "PASS"))
         (buf (current-buffer)))
     (let (gnugo-inhibit-refresh)
@@ -1965,7 +1959,6 @@ Prefix arg means to redo all the undone moves."
              (bidx (aref monkey 1))
              (end (aref ends bidx))
              (ucolor (gnugo-get :user-color))
-             (gcolor (gnugo-other ucolor))
              (uprop (if (gnugo--blackp ucolor)
                         :B :W)))
         (cl-flet ((mvno (node) (gethash node mnum)))
@@ -1980,16 +1973,14 @@ Prefix arg means to redo all the undone moves."
                       move (gnugo--move-prop node))
                 (when (and move (>= ok (mvno node)))
                   (let ((userp (eq uprop (car move))))
-                    (push (list (if userp ucolor gcolor)
-                                userp
+                    (push (list userp
                                 (funcall as-pos (cdr move)))
                           todo))))
            until (eq mem (cdr ls))
            finally do
            (loop
-            for (color userp pos) in todo
+            for (userp pos) in todo
             do (progn
-                 (gnugo--play-stone color pos)
                  (gnugo-push-move userp pos)
                  (gnugo-refresh)
                  (redisplay)))))))))
@@ -2011,10 +2002,6 @@ Also, add the `:RE' SGF property to the root node of the 
game tree."
                  (message "Playing PASS for %s ..."
                           (gnugo-get (if userp :user-color :gnugo-color)))
                  (sit-for 1)
-                 (gnugo--play-stone (gnugo-get (if userp
-                                                   :user-color
-                                                 :gnugo-color))
-                                    "PASS")
                  (gnugo-push-move userp "PASS")))
         (unless (pass t)
           (pass nil)))



reply via email to

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