eschulte pushed a commit to branch go in repository elpa. commit 0d0055454a406ae0d8e1b8281ac41fc5bebd6006 Author: Eric Schulte <eric.schu...@gmx.com> Date: Tue May 15 10:36:39 2012 -0400
board display --- sgf.el | 32 ++++++++++++++++++++++++++++++-- 1 files changed, 30 insertions(+), 2 deletions(-) diff --git a/sgf.el b/sgf.el index d6c4ecc..49f77a0 100644 --- a/sgf.el +++ b/sgf.el @@ -188,12 +188,40 @@ ;;; Visualization -;; - define a board format array ;; - make buffer to show a board, and notes, etc... -;; - keep a marker in an sgf file +;; - keep an index into the sgf file ;; - write functions for building boards from sgf files (forwards and backwards) ;; - sgf movement keys +;; (defvar *board* (make-vector (* 19 19) nil)) +(defun board-to-string (board) + (let ((size (sqrt (length board)))) + (flet ((header () + (concat + " " + (let ((row "")) + (dotimes (n size row) + (setq row (concat row (string (+ ?A n)) " ")))) + "\n")) + (emph (n) (or (= 3 n) + (= 4 (- size n)) + (= n (/ (- size 1) 2)))) + (body () + (let ((body "")) + (dotimes (m size body) + (setq body + (concat body + (format "%3d" (- size m)) + (let ((row " ")) + (dotimes (n size row) + (setq row (concat row + (if (and (emph n) (emph m)) + "+ " + ". "))))) + (format "%2d" (- size m)) + "\n")))))) + (concat (header) (body) (header))))) + ;;; Tests (require 'ert)