about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-01-25 00:12:52 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-01-25 00:12:52 -0800
commit3ca957ae49058ca9c899d449465f234af64c0b86 (patch)
tree65e59f30ec9ede073dedf9cfa57c5bda75ca402a
parent09e2e533ed6643cc586de3d9e51c0b1cb3da2e3e (diff)
downloadmu-3ca957ae49058ca9c899d449465f234af64c0b86.tar.gz
617
-rw-r--r--chessboard-retro.mu92
1 files changed, 0 insertions, 92 deletions
diff --git a/chessboard-retro.mu b/chessboard-retro.mu
deleted file mode 100644
index 1c90fc8d..00000000
--- a/chessboard-retro.mu
+++ /dev/null
@@ -1,92 +0,0 @@
-;; data structure: board
-(primitive square)
-(address square-address (square))  ; pointer. verbose but sadly necessary for now
-(array file (square))  ; ranks and files are arrays of squares
-(address file-address (file))
-(address file-address-address (file-address))  ; pointer to a pointer
-(array board (file-address))
-(address board-address (board))
-
-(function read-board [
-  (default-space:space-address <- new space:literal 30:literal)
-  (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)
-  ; assert(length(initial-position) == 64)
-;?   (print-primitive-to-host (("list-length\n" literal)))
-  (len:integer <- list-length initial-position:list-address)
-  (correct-length?:boolean <- equal len:integer 64:literal)
-  (assert correct-length?:boolean "chessboard had incorrect size")
-  (b:board-address <- new board:literal 8:literal)
-  (col:integer <- copy 0:literal)
-  (curr:list-address <- copy initial-position:list-address)
-  { begin
-    (done?:boolean <- equal col:integer 8:literal)
-    (break-if done?:boolean)
-;?     (print-primitive-to-host col:integer)
-;?     (print-primitive-to-host (("\n" literal)))
-    (file:file-address-address <- index-address b:board-address/deref col:integer)
-    (file:file-address-address/deref curr:list-address <- read-file curr:list-address)
-    (col:integer <- add col:integer 1:literal)
-    (loop)
-  }
-  (reply b:board-address)
-])
-
-(function read-file [
-  (default-space:space-address <- new space:literal 30:literal)
-  (cursor:list-address <- next-input)
-  (result:file-address <- new file:literal 8:literal)
-  (row:integer <- copy 0:literal)
-  { begin
-    (done?:boolean <- equal row:integer 8:literal)
-    (break-if done?:boolean)
-;?     (print-primitive-to-host (("  " literal)))
-;?     (print-primitive-to-host row:integer)
-;?     (print-primitive-to-host (("\n" literal)))
-    (src:tagged-value-address <- list-value-address cursor:list-address)
-    (dest:square-address <- index-address result:file-address/deref row:integer)
-    (dest:square-address/deref <- get src:tagged-value-address/deref payload:offset)  ; unsafe typecast
-    (cursor:list-address <- list-next cursor:list-address)
-    (row:integer <- add row:integer 1:literal)
-    (loop)
-  }
-  (reply result:file-address cursor:list-address)
-])
-
-(function print-board [
-  (default-space:space-address <- new space:literal 30:literal)
-  (b:board-address <- next-input)
-  (row:integer <- copy 7:literal)
-  ; print each row
-  { begin
-    (done?:boolean <- less-than row:integer 0:literal)
-    (break-if done?:boolean)
-    ; print each square in the row
-    (col:integer <- copy 0:literal)
-    { begin
-      (done?:boolean <- equal col:integer 8:literal)
-      (break-if done?:boolean)
-      (f:file-address <- index b:board-address/deref col:integer)
-      (s:square <- index f:file-address/deref row:integer)
-      (print-primitive-to-host s:square)
-      (print-primitive-to-host ((" " literal)))
-      (col:integer <- add col:integer 1:literal)
-      (loop)
-    }
-    (print-primitive-to-host (("\n" literal)))
-    (row:integer <- subtract row:integer 1:literal)
-    (loop)
-  }
-])
-
-(function main [
-  (default-space:space-address <- new space:literal 30:literal)
-  (b:board-address <- read-board)
-  (print-board b:board-address)
-])