[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 15/255: board display
From: |
Eric Schulte |
Subject: |
[elpa] 15/255: board display |
Date: |
Sun, 16 Mar 2014 01:02:10 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit 0d0055454a406ae0d8e1b8281ac41fc5bebd6006
Author: Eric Schulte <address@hidden>
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)
- [elpa] 04/255: parse-many macro, (continued)
- [elpa] 04/255: parse-many macro, Eric Schulte, 2014/03/15
- [elpa] 05/255: parse-nodes, Eric Schulte, 2014/03/15
- [elpa] 03/255: parse-prop -> parse-props, Eric Schulte, 2014/03/15
- [elpa] 08/255: parsing simple trees, Eric Schulte, 2014/03/15
- [elpa] 06/255: passing all tests, Eric Schulte, 2014/03/15
- [elpa] 07/255: some fixes, Eric Schulte, 2014/03/15
- [elpa] 11/255: ignore data directory, Eric Schulte, 2014/03/15
- [elpa] 14/255: processing simple/core properties, Eric Schulte, 2014/03/15
- [elpa] 13/255: splitting into sections & stubbing out parsing, Eric Schulte, 2014/03/15
- [elpa] 12/255: headers, Eric Schulte, 2014/03/15
- [elpa] 15/255: board display,
Eric Schulte <=
- [elpa] 22/255: example sgf file generated using gcoban, Eric Schulte, 2014/03/15
- [elpa] 17/255: not using "I" as an index, Eric Schulte, 2014/03/15
- [elpa] 20/255: alright "i" *is* a valid position identifier, Eric Schulte, 2014/03/15
- [elpa] 16/255: cleaned up board printing, Eric Schulte, 2014/03/15
- [elpa] 09/255: parsing more complex trees, Eric Schulte, 2014/03/15
- [elpa] 19/255: moving games/ -> sgf-files/, Eric Schulte, 2014/03/15
- [elpa] 10/255: helper functions, Eric Schulte, 2014/03/15
- [elpa] 24/255: right and left implemented but buggy, Eric Schulte, 2014/03/15
- [elpa] 23/255: more complex but more intuitive and useful `range', Eric Schulte, 2014/03/15
- [elpa] 21/255: display sgf file as a go board in a buffer, Eric Schulte, 2014/03/15