[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 195/255: query backend for territory
From: |
Eric Schulte |
Subject: |
[elpa] 195/255: query backend for territory |
Date: |
Sun, 16 Mar 2014 01:02:47 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit 7cf25156af355e4e092478fb885274db381843a2
Author: Eric Schulte <address@hidden>
Date: Mon May 20 14:50:01 2013 -0600
query backend for territory
---
back-ends/gtp.el | 11 +++++++++++
back-ends/igs.el | 3 +++
back-ends/sgf.el | 3 +++
go-api.el | 3 ++-
go-board.el | 9 +++++----
5 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/back-ends/gtp.el b/back-ends/gtp.el
index 4343edc..cbb247b 100644
--- a/back-ends/gtp.el
+++ b/back-ends/gtp.el
@@ -58,6 +58,14 @@
(:KM (format "komi %s" val))
(t nil))))
+(defun gtp-territory (gtp color)
+ (let ((output (ecase color
+ (:B (gtp-command gtp "final_status_list black_territory"))
+ (:W (gtp-command gtp "final_status_list white_territory")))))
+ (mapcar (lambda (gtp-point) (gtp-to-pos color gtp-point))
+ (mapcar #'symbol-name
+ (read (format "(%s)" output))))))
+
;;; Class and interface
(defclass gtp nil nil "Class for the GTP GO GO back end.")
@@ -136,4 +144,7 @@
(defmethod go-score ((gtp gtp)) (gtp-command gtp "final_score"))
+(defmethod go-territory ((gtp gtp))
+ (append (gtp-territory gtp :B) (gtp-territory gtp :W)))
+
(provide 'gtp)
diff --git a/back-ends/igs.el b/back-ends/igs.el
index 8ab9799..0c29097 100644
--- a/back-ends/igs.el
+++ b/back-ends/igs.el
@@ -458,4 +458,7 @@ This is used to re-send messages to keep the IGS server
from timing out.")
(defmethod go-score ((igs igs))
(signal 'unsupported-back-end-command (list igs :score)))
+(defmethod go-territory ((igs igs))
+ (signal 'unsupported-back-end-command (list igs :territory)))
+
(provide 'igs)
diff --git a/back-ends/sgf.el b/back-ends/sgf.el
index 185753b..6048dc3 100644
--- a/back-ends/sgf.el
+++ b/back-ends/sgf.el
@@ -191,4 +191,7 @@
(defmethod go-score ((sgf sgf))
(signal 'unsupported-back-end-command (list sgf :score)))
+(defmethod go-territory ((sgf sgf))
+ (signal 'unsupported-back-end-command (list sgf :territory)))
+
(provide 'sgf)
diff --git a/go-api.el b/go-api.el
index 13cd9f4..45908c4 100644
--- a/go-api.el
+++ b/go-api.el
@@ -75,6 +75,7 @@
(defgeneric go-resign (back-end) "Send resign to BACK-END.")
(defgeneric go-reset (back-end) "Send reset to BACK-END.")
(defgeneric go-quit (back-end) "Quit the BACK-END.")
-(defgeneric go-score (back-end) "Ask BACK-END to report the final score.")
+(defgeneric go-score (back-end) "Ask BACK-END to report the score.")
+(defgeneric go-territory (back-end) "Ask BACK-END to report the territory.")
(provide 'go-api)
diff --git a/go-board.el b/go-board.el
index 89e5e05..916a7b2 100644
--- a/go-board.el
+++ b/go-board.el
@@ -391,9 +391,10 @@
(setf *turn* (other-color *turn*))
(when *autoplay*
(when (equalp :pass (go-board-next))
- ;; TODO: print the score
- (message "final score: %s"
- (with-backends back (go-score back)))))))
+ (message "final score: %s territory:%s"
+ (with-backends back (go-score back))
+ ;; TODO: mark the territory
+ (with-backends back (go-territory back)))))))
(defun go-board-undo (&optional num)
(interactive "p")
@@ -404,7 +405,7 @@
(defun go-board-comment (&optional comment)
(interactive "MComment: ")
- (message "comment: %S" comment))
+ (with-backends back (setf (go-comment back) comment)))
(defun go-board-level (&optional level)
(interactive "nLevel: ")
- [elpa] 178/255: process igs "tell" messages, (continued)
- [elpa] 178/255: process igs "tell" messages, Eric Schulte, 2014/03/15
- [elpa] 181/255: NOTES #+option, Eric Schulte, 2014/03/15
- [elpa] 193/255: calculate the final score, Eric Schulte, 2014/03/15
- [elpa] 194/255: notes on scaling image sizes, Eric Schulte, 2014/03/15
- [elpa] 198/255: don't mutate hidden state, Eric Schulte, 2014/03/15
- [elpa] 196/255: mark an overlay with a black or white cross, Eric Schulte, 2014/03/15
- [elpa] 187/255: don't commit if process already quit, Eric Schulte, 2014/03/15
- [elpa] 188/255: adding README, Eric Schulte, 2014/03/15
- [elpa] 199/255: marking captured territory when game ends, Eric Schulte, 2014/03/15
- [elpa] 197/255: use new mark machinery to apply labels, Eric Schulte, 2014/03/15
- [elpa] 195/255: query backend for territory,
Eric Schulte <=
- [elpa] 201/255: print score after marking territory, Eric Schulte, 2014/03/15
- [elpa] 189/255: replace flet with cl-flet, Eric Schulte, 2014/03/15
- [elpa] 190/255: set level (mainly for playing GNUGO), Eric Schulte, 2014/03/15
- [elpa] 204/255: prefix external names with package name, Eric Schulte, 2014/03/15
- [elpa] 165/255: working on placing backgrounds behind pieces, Eric Schulte, 2014/03/15
- [elpa] 202/255: added interface function to view an SGF file, Eric Schulte, 2014/03/15
- [elpa] 205/255: update the README, Eric Schulte, 2014/03/15
- [elpa] 206/255: ensure prisoners are 0 at the start of a new game, Eric Schulte, 2014/03/15
- [elpa] 208/255: support for viewing lists in a buffer, Eric Schulte, 2014/03/15
- [elpa] 207/255: robustly handle prematurely quitting process, Eric Schulte, 2014/03/15