about summary refs log tree commit diff stats
path: root/chessboard.mu
diff options
context:
space:
mode:
Diffstat (limited to 'chessboard.mu')
-rw-r--r--chessboard.mu82
1 files changed, 20 insertions, 62 deletions
diff --git a/chessboard.mu b/chessboard.mu
index a91e6da7..638b8367 100644
--- a/chessboard.mu
+++ b/chessboard.mu
@@ -66,17 +66,6 @@ scenario print-board-and-read-move [
   ]
 ]
 
-#? scenario foo [ #? 1
-#?   $print [aaa] #? 1
-#?   run [ #? 1
-#?     1:number <- copy 34:literal #? 1
-#?   ] #? 1
-#?   memory-should-contain [ #? 1
-#?     1 <- 34 #? 1
-#?   ] #? 1
-#?   $print [zzz] #? 1
-#? ] #? 1
-
 ## Here's how 'chessboard' is implemented.
 
 recipe chessboard [
@@ -85,8 +74,7 @@ recipe chessboard [
   local-scope
   screen:address <- next-ingredient
   console:address <- next-ingredient
-#?   $print [screen: ], screen:address, [, console: ], console:address, [ 
-#? ] #? 1
+#?   $print [screen: ], screen:address, [, console: ], console:address, 10:literal/newline
   board:address:array:address:array:character <- initial-position
   # hook up stdin
   stdin:address:channel <- new-channel 10:literal/capacity
@@ -98,31 +86,21 @@ recipe chessboard [
     msg:address:array:character <- new [Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves.
 ]
     print-string screen:address, msg:address:array:character
-#?     $print [aaa
-#? ] #? 1
     cursor-to-next-line screen:address
     print-board screen:address, board:address:array:address:array:character
     cursor-to-next-line screen:address
     msg:address:array:character <- new [Type in your move as <from square>-<to square>. For example: 'a2-a4'. Then press <enter>.
 ]
     print-string screen:address, msg:address:array:character
-#?     $print [bbb
-#? ] #? 1
     cursor-to-next-line screen:address
     msg:address:array:character <- new [Hit 'q' to exit.
 ]
     print-string screen:address, msg:address:array:character
-#?     $print [ccc
-#? ] #? 1
     {
       cursor-to-next-line screen:address
       msg:address:array:character <- new [move: ]
       print-string screen:address, msg:address:array:character
-#?     $print [ddd
-#? ] #? 1
       m:address:move, quit:boolean, error:boolean <- read-move buffered-stdin:address:channel, screen:address
-#?     $print [eee
-#? ] #? 1
       break-if quit:boolean, +quit:offset
       buffered-stdin:address:channel <- clear-channel buffered-stdin:address:channel  # cleanup after error. todo: test this?
       loop-if error:boolean
@@ -132,7 +110,6 @@ recipe chessboard [
     loop
   }
   +quit
-#?   $print [aaa] #? 1
 ]
 
 ## a board is an array of files, a file is an array of characters (squares)
@@ -183,13 +160,11 @@ recipe print-board [
   board:address:array:address:array:character <- next-ingredient
   row:number <- copy 7:literal  # start printing from the top of the board
   # print each row
-#?   $print [printing board to screen ], screen:address, [ 
-#? ] #? 1
+#?   $print [printing board to screen ], screen:address, 10:literal/newline
   {
     done?:boolean <- lesser-than row:number, 0:literal
     break-if done?:boolean
-#?     $print [printing rank ], row:number, [ 
-#? ] #? 1
+#?     $print [printing rank ], row:number, 10:literal/newline
     # print rank number as a legend
     rank:number <- add row:number, 1:literal
     print-integer screen:address, rank:number
@@ -349,8 +324,7 @@ recipe read-file [
     reply 0:literal/dummy, 0:literal/quit, 1:literal/error
   }
   file:number <- subtract c:character, 97:literal  # 'a'
-#?   $print file:number, [ 
-#? ] #? 1
+#?   $print file:number, 10:literal/newline
   # 'a' <= file <= 'h'
   {
     above-min:boolean <- greater-or-equal file:number, 0:literal
@@ -397,8 +371,7 @@ recipe read-rank [
     reply 0:literal/dummy, 0:literal/quit, 1:literal/error
   }
   rank:number <- subtract c:character, 49:literal  # '1'
-#?   $print rank:number, [ 
-#? ] #? 1
+#?   $print rank:number, 10:literal/newline
   # assert'1' <= rank <= '8'
   {
     above-min:boolean <- greater-or-equal rank:number, 0:literal
@@ -442,30 +415,25 @@ scenario read-move-blocking [
   run [
 #?     $start-tracing #? 1
     1:address:channel <- new-channel 2:literal
-#?     $print [aaa channel address: ], 1:address:channel, [ 
-#? ] #? 1
+#?     $print [aaa channel address: ], 1:address:channel, 10:literal/newline
     2:number/routine <- start-running read-move:recipe, 1:address:channel, screen:address
     # 'read-move' is waiting for input
     wait-for-routine 2:number
-#?     $print [bbb channel address: ], 1:address:channel, [ 
-#? ] #? 1
+#?     $print [bbb channel address: ], 1:address:channel, 10:literal/newline
     3:number <- routine-state 2:number/id
-#?     $print [I: routine ], 2:number, [ state ], 3:number [ 
-#? ] #? 1
+#?     $print [I: routine ], 2:number, [ state ], 3:number 10:literal/newline
     4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting
     assert 4:boolean/waiting?, [
 F read-move-blocking: routine failed to pause after coming up (before any keys were pressed)]
     # press 'a'
-#?     $print [ccc channel address: ], 1:address:channel, [ 
-#? ] #? 1
+#?     $print [ccc channel address: ], 1:address:channel, 10:literal/newline
 #?     $exit #? 1
     1:address:channel <- write 1:address:channel, 97:literal  # 'a'
     restart 2:number/routine
     # 'read-move' still waiting for input
     wait-for-routine 2:number
     3:number <- routine-state 2:number/id
-#?     $print [II: routine ], 2:number, [ state ], 3:number [ 
-#? ] #? 1
+#?     $print [II: routine ], 2:number, [ state ], 3:number 10:literal/newline
     4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting
     assert 4:boolean/waiting?, [
 F read-move-blocking: routine failed to pause after rank 'a']
@@ -475,8 +443,7 @@ F read-move-blocking: routine failed to pause after rank 'a']
     # 'read-move' still waiting for input
     wait-for-routine 2:number
     3:number <- routine-state 2:number/id
-#?     $print [III: routine ], 2:number, [ state ], 3:number [ 
-#? ] #? 1
+#?     $print [III: routine ], 2:number, [ state ], 3:number 10:literal/newline
     4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting
     assert 4:boolean/waiting?, [
 F read-move-blocking: routine failed to pause after file 'a2']
@@ -486,8 +453,7 @@ F read-move-blocking: routine failed to pause after file 'a2']
     # 'read-move' still waiting for input
     wait-for-routine 2:number
     3:number <- routine-state 2:number
-#?     $print [IV: routine ], 2:number, [ state ], 3:number [ 
-#? ] #? 1
+#?     $print [IV: routine ], 2:number, [ state ], 3:number 10:literal/newline
     4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting
     assert 4:boolean/waiting?/routine-state, [
 F read-move-blocking: routine failed to pause after hyphen 'a2-']
@@ -497,8 +463,7 @@ F read-move-blocking: routine failed to pause after hyphen 'a2-']
     # 'read-move' still waiting for input
     wait-for-routine 2:number
     3:number <- routine-state 2:number
-#?     $print [V: routine ], 2:number, [ state ], 3:number [ 
-#? ] #? 1
+#?     $print [V: routine ], 2:number, [ state ], 3:number 10:literal/newline
     4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting
     assert 4:boolean/waiting?/routine-state, [
 F read-move-blocking: routine failed to pause after rank 'a2-a']
@@ -508,8 +473,7 @@ F read-move-blocking: routine failed to pause after rank 'a2-a']
     # 'read-move' still waiting for input
     wait-for-routine 2:number
     3:number <- routine-state 2:number
-#?     $print [VI: routine ], 2:number, [ state ], 3:number [ 
-#? ] #? 1
+#?     $print [VI: routine ], 2:number, [ state ], 3:number 10:literal/newline
     4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting
     assert 4:boolean/waiting?, [
 F read-move-blocking: routine failed to pause after file 'a2-a4']
@@ -519,8 +483,7 @@ F read-move-blocking: routine failed to pause after file 'a2-a4']
     # 'read-move' now completes
     wait-for-routine 2:number
     3:number <- routine-state 2:number
-#?     $print [VII: routine ], 2:number, [ state ], 3:number [ 
-#? ] #? 1
+#?     $print [VII: routine ], 2:number, [ state ], 3:number 10:literal/newline
     4:boolean/completed? <- equal 3:number/routine-state, 1:literal/completed
     assert 4:boolean/completed?, [
 F read-move-blocking: routine failed to terminate on newline]
@@ -628,23 +591,18 @@ recipe make-move [
   b:address:array:address:array:character <- next-ingredient
   m:address:move <- next-ingredient
   from-file:number <- get m:address:move/deref, from-file:offset
-#?   $print from-file:number, [ 
-#? ] #? 1
+#?   $print from-file:number, 10:literal/newline
   from-rank:number <- get m:address:move/deref, from-rank:offset
-#?   $print from-rank:number, [ 
-#? ] #? 1
+#?   $print from-rank:number, 10:literal/newline
   to-file:number <- get m:address:move/deref, to-file:offset
-#?   $print to-file:number, [ 
-#? ] #? 1
+#?   $print to-file:number, 10:literal/newline
   to-rank:number <- get m:address:move/deref, to-rank:offset
-#?   $print to-rank:number, [ 
-#? ] #? 1
+#?   $print to-rank:number, 10:literal/newline
   f:address:array:character <- index b:address:array:address:array:character/deref, from-file:number
   src:address:character/square <- index-address f:address:array:character/deref, from-rank:number
   f:address:array:character <- index b:address:array:address:array:character/deref, to-file:number
   dest:address:character/square <- index-address f:address:array:character/deref, to-rank:number
-#?   $print src:address:character/deref, [ 
-#? ] #? 1
+#?   $print src:address:character/deref, 10:literal/newline
   dest:address:character/deref/square <- copy src:address:character/deref/square
   src:address:character/deref/square <- copy 32:literal  # ' '
   reply b:address:array:address:array:character/same-as-ingredient:0