[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 17/255: not using "I" as an index
From: |
Eric Schulte |
Subject: |
[elpa] 17/255: not using "I" as an index |
Date: |
Sun, 16 Mar 2014 01:02:11 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit 3eb012cd34fead96543d39187662d399319360de
Author: Eric Schulte <address@hidden>
Date: Tue May 15 17:35:11 2012 -0400
not using "I" as an index
---
sgf.el | 46 ++++++++++++++++++++++++++++++++++++++++------
1 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/sgf.el b/sgf.el
index 3dd0466..0198af0 100644
--- a/sgf.el
+++ b/sgf.el
@@ -164,9 +164,14 @@
(defun process-position (position-string)
(flet ((char-to-pos (char)
(cond
- ((or (< char ?A) (> char ?z)) (error "sgf: invalid char %s" char))
- ((< char ?a) (+ 26 (- char ?A)))
- (t (- char ?a)))))
+ ((or (< char ?A) (< ?z char))
+ (error "sgf: invalid char %s" char))
+ ((< char ?I) (+ 26 (- char ?A)))
+ ((= char ?I) (error "sgf: \"I\" is an invalid char"))
+ ((< char ?a) (+ 27 (- char ?A)))
+ ((< char ?i) (- char $a))
+ ((= char ?i) (error "sgf: \"i\" is an invalid char"))
+ (t (+ 1 (- char ?a))))))
(cons (char-to-pos (aref position-string 0))
(char-to-pos (aref position-string 1)))))
@@ -205,7 +210,11 @@
(defun board-header (board)
(let ((size (board-size board)))
(concat " "
- (mapconcat (lambda (n) (string (+ ?A n)))
+ (mapconcat (lambda (n)
+ (let ((char (+ ?A n)))
+ (when (>= char ?I)
+ (setq char (+ 1 char)))
+ (string char)))
(range size) " "))))
(defun board-pos-to-string (board pos)
@@ -296,7 +305,7 @@
(ert-deftest sgf-empty-board-to-string-test ()
(let ((board (make-vector (* 19 19) nil))
- (string (concat " A B C D E F G H I J K L M N O P Q R S\n"
+ (string (concat " A B C D E F G H J K L M N O P Q R S T\n"
" 19 . . . . . . . . . . . . . . . . . . . 19\n"
" 18 . . . . . . . . . . . . . . . . . . . 18\n"
" 17 . . . . . . . . . . . . . . . . . . . 17\n"
@@ -316,5 +325,30 @@
" 3 . . . . . . . . . . . . . . . . . . . 3\n"
" 2 . . . . . . . . . . . . . . . . . . . 2\n"
" 1 . . . . . . . . . . . . . . . . . . . 1\n"
- " A B C D E F G H I J K L M N O P Q R S")))
+ " A B C D E F G H J K L M N O P Q R S T")))
(should (string= string (board-to-string board)))))
+
+(ert-deftest sgf-non-empty-board-to-string-test ()
+ (let ((board (make-vector (* 19 19) nil))
+ (string (concat " A B C D E F G H J K L M N O P Q R S T\n"
+ " 19 . . . . . . . . . . . . . . . . . . . 19\n"
+ " 18 . . . . . . . . . . . . . . . . . . . 18\n"
+ " 17 . . . . . . . . . . . . . . . . . . . 17\n"
+ " 16 . . . + . . . . . + . . . . . + . . . 16\n"
+ " 15 . . . . . . . . . . . . . . . . . . . 15\n"
+ " 14 . . . . . . . . . . . . . . . . . . . 14\n"
+ " 13 . . . . . . . . . . . . . . . . . . . 13\n"
+ " 12 . . . . . . . . . . . . . . . . . . . 12\n"
+ " 11 . . . . . . . . . . . . . . . . . . . 11\n"
+ " 10 . . . + . . . . . + . . . . . + . . . 10\n"
+ " 9 . . . . . . . . . . . . . . . . . . . 9\n"
+ " 8 . . . . . . . . . . . . . . . . . . . 8\n"
+ " 7 . . . . . . . . . . . . . . . . . . . 7\n"
+ " 6 . . . . . . . . . . . . . . . . . . . 6\n"
+ " 5 . . . . . . . . . . . . . . . . . . . 5\n"
+ " 4 . . . + . . . . . + . . . . . + . . . 4\n"
+ " 3 . . . . . . . . . . . . . . . . . . . 3\n"
+ " 2 . . . . . . . . . . . . . . . . . . . 2\n"
+ " 1 . . . . . . . . . . . . . . . . . . . 1\n"
+ " A B C D E F G H J K L M N O P Q R S T")))
+ (should t)))
- [elpa] 03/255: parse-prop -> parse-props, (continued)
- [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, 2014/03/15
- [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 <=
- [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
- [elpa] 25/255: right and left are mainly working, Eric Schulte, 2014/03/15
- [elpa] 29/255: q now quits a sgf display buffer, Eric Schulte, 2014/03/15