[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 24/255: right and left implemented but buggy
From: |
Eric Schulte |
Subject: |
[elpa] 24/255: right and left implemented but buggy |
Date: |
Sun, 16 Mar 2014 01:02:12 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit 3385b62066edb35426aad815add3a73a3bdb6722
Author: Eric Schulte <address@hidden>
Date: Tue May 15 19:50:49 2012 -0400
right and left implemented but buggy
---
sgf.el | 45 +++++++++++++++++++++++++++++----------------
1 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/sgf.el b/sgf.el
index 712b6fb..8fc0d79 100644
--- a/sgf.el
+++ b/sgf.el
@@ -303,28 +303,41 @@
part))
(defun up ())
+
(defun down ())
-(defun left ())
+
+(defun left (&optional num)
+ (interactive "p")
+ (prog1 (dotimes (n num n)
+ (decf (car (last *index*)))
+ (unless (sgf-ref *sgf* *index*)
+ (update-display)
+ (error "sgf: no more backwards moves."))
+ (revert-moves *board* (sgf-ref *sgf* *index*)))
+ (update-display)))
+
(defun right (&optional num)
(interactive "p")
- (incf (car (last *index*)) num)
- (unless (sgf-ref *sgf* *index*)
- (error "sgf: no more forward moves."))
- (apply-move *board* (sgf-ref *sgf* *index*))
- (update-display))
+ (prog1 (dotimes (n num n)
+ (incf (car (last *index*)))
+ (unless (sgf-ref *sgf* *index*)
+ (update-display)
+ (error "sgf: no more forward moves."))
+ (apply-moves *board* (sgf-ref *sgf* *index*)))
+ (update-display)))
;;; Board manipulation functions
-(defun apply-move (board move)
- (setf (aref board (pos-to-index (cdr move) (board-size board)))
- (cond ((string= "B" (car move)) :b)
- ((string= "W" (car move)) :w)
- (t (error "sgf: invalid move %s" (car move)))))
- board)
+(defun apply-moves (board moves)
+ (dolist (move moves board)
+ (setf (aref board (pos-to-index (cdr move) (board-size board)))
+ (cond ((string= "B" (car move)) :b)
+ ((string= "W" (car move)) :w)
+ (t (error "sgf: invalid move %s" (car move)))))))
-(defun revert-move (board move)
- (setf (aref board (pos-to-index (cdr move) (board-size board))) nil)
- board)
+(defun revert-moves (board moves)
+ (dolist (move moves board)
+ (setf (aref board (pos-to-index (cdr move) (board-size board))) nil)))
;;; Tests
@@ -436,7 +449,7 @@
" 1 . . . . . . . . . . . . . . . . . . . 1\n"
" A B C D E F G H J K L M N O P Q R S T")))
(dolist (moves rest)
- (apply-move board (car moves)))
+ (apply-moves board moves))
(board-to-string board)
(should t)))
- [elpa] 13/255: splitting into sections & stubbing out parsing, (continued)
- [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, 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 <=
- [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
- [elpa] 28/255: adding a major mode for board navigation keys, Eric Schulte, 2014/03/15
- [elpa] 27/255: implementation notes, Eric Schulte, 2014/03/15
- [elpa] 31/255: a test to protect against unwanted state changes, Eric Schulte, 2014/03/15
- [elpa] 33/255: removing dead pieces after moves, Eric Schulte, 2014/03/15
- [elpa] 35/255: compiled and caught some minor issues, Eric Schulte, 2014/03/15
- [elpa] 32/255: consolidating utility functions, Eric Schulte, 2014/03/15