about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-01-18 01:55:25 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-01-18 01:55:25 -0800
commit445a1494b793cade004118ad0e71bdbf5a8992da (patch)
treef3a5f9aaaecd54adf7f173e4c29df648ba37aec5
parent04463b74aea8e19d466d15d62b89963f79d2bbab (diff)
downloadmu-445a1494b793cade004118ad0e71bdbf5a8992da.tar.gz
591
I don't remember what exactly we wanted to test in the second move.
But we can write it next time we need it.
-rw-r--r--chessboard-cursor.arc.t59
-rw-r--r--chessboard-cursor.mu7
2 files changed, 60 insertions, 6 deletions
diff --git a/chessboard-cursor.arc.t b/chessboard-cursor.arc.t
index 384aa7c5..43e6890b 100644
--- a/chessboard-cursor.arc.t
+++ b/chessboard-cursor.arc.t
@@ -168,6 +168,63 @@
              "1 | R N B Q K B N R "
              "  +---------------- "
              "    a b c d e f g h "))
-  (prn "F - print-board doesn't work; chessboard begins at @memory*.5"))
+  (prn "F - print-board works; chessboard begins at @memory*.5"))
+
+; todo: how to fold this more elegantly with the previous test?
+(reset)
+(new-trace "make-move")
+(add-code:readfile "chessboard-cursor.mu")
+(add-code
+  '((function! main [
+      (default-space:space-address <- new space:literal 30:literal/capacity)
+      ; hook up stdin
+      (1:channel-address/raw <- init-channel 1:literal)
+      ; fake screen
+      (screen:terminal-address <- init-fake-terminal 20:literal 10:literal)
+      ; initial position
+      (initial-position:list-address <- init-list ((#\R literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\r literal))
+                                                  ((#\N literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\n literal))
+                                                  ((#\B literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\b literal))
+                                                  ((#\Q literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\q literal))
+                                                  ((#\K literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\k literal))
+                                                  ((#\B literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\b literal))
+                                                  ((#\N literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\n literal))
+                                                  ((#\R literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\r literal)))
+      (b:board-address <- init-board initial-position:list-address)
+      ; move: a2-a4
+      (m:move-address <- new move:literal)
+      (f:integer-integer-pair-address <- get-address m:move-address/deref from:offset)
+      (dest:integer-address <- get-address f:integer-integer-pair-address/deref 0:offset)
+      (dest:integer-address/deref <- copy 0:literal)  ; from-file: a
+      (dest:integer-address <- get-address f:integer-integer-pair-address/deref 1:offset)
+      (dest:integer-address/deref <- copy 1:literal)  ; from-rank: 2
+      (t0:integer-integer-pair-address <- get-address m:move-address/deref to:offset)
+      (dest:integer-address <- get-address t0:integer-integer-pair-address/deref 0:offset)
+      (dest:integer-address/deref <- copy 0:literal)  ; to-file: a
+      (dest:integer-address <- get-address t0:integer-integer-pair-address/deref 1:offset)
+      (dest:integer-address/deref <- copy 3:literal)  ; to-rank: 4
+      (b:board-address <- make-move b:board-address m:move-address)
+      (print-board screen:terminal-address b:board-address)
+      (5:string-address/raw <- get screen:terminal-address/deref data:offset)
+     ])))
+;? (set dump-trace*)
+;? (= dump-trace* (obj whitelist '("run")))
+(run 'main)
+(each routine completed-routines*
+  (awhen rep.routine!error
+    (prn "error - " it)))
+;? (prn memory*.5)
+(when (~memory-contains-array memory*.5
+          (+ "8 | r n b q k b n r "
+             "7 | p p p p p p p p "
+             "6 | _ _ _ _ _ _ _ _ "
+             "5 | _ _ _ _ _ _ _ _ "
+             "4 | P _ _ _ _ _ _ _ "
+             "3 | _ _ _ _ _ _ _ _ "
+             "2 | _ P P P P P P P "
+             "1 | R N B Q K B N R "
+             "  +---------------- "
+             "    a b c d e f g h "))
+  (prn "F - make-move works; chessboard begins at @memory*.5"))
 
 (reset)
diff --git a/chessboard-cursor.mu b/chessboard-cursor.mu
index e80c9530..6d230384 100644
--- a/chessboard-cursor.mu
+++ b/chessboard-cursor.mu
@@ -196,7 +196,7 @@
   (f:file-address <- index b:board-address/deref to-file:integer)
   (dest:square-address <- index-address f:file-address/deref to-rank:integer)
   (dest:square-address/deref <- copy src:square-address/deref)
-  (src:square-address/deref <- copy _:literal)
+  (src:square-address/deref <- copy ((#\_ literal)))
   (reply b:board-address)
 ])
 
@@ -236,8 +236,5 @@
   (cursor-to-next-line)
 ])
 
-; tests todo:
-;   board updates on move
-;   'q' exits on second move
-;
+; todo:
 ;   backspace, ctrl-u