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

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

[elpa] 175/255: support for playing different types of games


From: Eric Schulte
Subject: [elpa] 175/255: support for playing different types of games
Date: Sun, 16 Mar 2014 01:02:43 +0000

eschulte pushed a commit to branch go
in repository elpa.

commit 06bc8914702961417ec21b9a3ad32d59a2790cc9
Author: Eric Schulte <address@hidden>
Date:   Sat Jun 9 18:32:24 2012 -0600

    support for playing different types of games
---
 go.el |   37 +++++++++++++++++++++++++------------
 1 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/go.el b/go.el
index 5980172..6389417 100644
--- a/go.el
+++ b/go.el
@@ -46,17 +46,30 @@
 (require 'sgf2el          "back-ends/sgf2el.el")
 (require 'igs             "back-ends/igs.el")
 
-(defun play-go (&optional level)
-  "Play a game of GO against gnugo.
-Optional argument LEVEL specifies gnugo's level of play."
-  (interactive "P")
-  (with-current-buffer
-      (go-board
-       (make-instance 'gnugo
-         :buffer (apply #'gnugo-start-process
-                        (when level
-                          (list "--level" (number-to-string level)))))
-       (make-instance 'sgf))
-    (setq *autoplay* t)))
+(defun go-instantiate (back-end)
+  (interactive)
+  ;; TODO: read and set handicap.
+  (let ((it (make-instance back-end))
+        (size (read (org-icompleting-read
+                     "board size: "
+                     (mapcar #'number-to-string '(9 13 19)))))
+        (name (read-from-minibuffer "name: ")))
+    (setf (go-size it) size)
+    (ignoring-unsupported (setf (go-name it) name))
+    it))
+
+(defun play-go ()
+  "Play a game of GO."
+  (interactive)
+  (let ((back-end (case (intern (org-icompleting-read
+                                 "play against: " '("gnugo" "person")))
+                    (gnugo  (go-instantiate 'gnugo))
+                    (person (go-instantiate 'sgf)))))
+    (with-current-buffer (apply #'go-board
+                                (cons back-end
+                                      (unless (equal (class-of back-end) 'sgf)
+                                        (list (make-instance 'sgf)))))
+      (unless (equal (class-of back-end) 'sgf)
+        (setq *autoplay* t)))))
 
 (provide 'go)



reply via email to

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