diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 15:01:51 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 15:01:51 -0700 |
commit | f344b250f6f062a1a1902bf69b23ebf9b565de0e (patch) | |
tree | 199bd32a9aee198d5028b1c21b83d2cf0944b2b6 /html/chessboard.mu.html | |
parent | 897ae8c1855f830d8819759ea327d147f28a09bf (diff) | |
download | mu-f344b250f6f062a1a1902bf69b23ebf9b565de0e.tar.gz |
3395
Diffstat (limited to 'html/chessboard.mu.html')
-rw-r--r-- | html/chessboard.mu.html | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/html/chessboard.mu.html b/html/chessboard.mu.html index 72986d0c..8d7e5c0c 100644 --- a/html/chessboard.mu.html +++ b/html/chessboard.mu.html @@ -65,9 +65,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ <span class="Constant">local-scope</span> - screen:address:screen, console:address:console<span class="Special"> <- </span>chessboard screen:address:screen, console:address:console + screen:&:screen, console:&:console<span class="Special"> <- </span>chessboard screen:&:screen, console:&:console <span class="Comment"># icon for the cursor</span> - cursor-icon:character<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor-icon:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> screen<span class="Special"> <- </span>print screen, cursor-icon ] screen-should-contain [ @@ -98,17 +98,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="SalientComment">## Here's how 'chessboard' is implemented.</span> -type board = address:array:address:array:character +type board = address:@:&:@:char -<span class="muRecipe">def</span> chessboard screen:address:screen, console:address:console<span class="muRecipe"> -> </span>screen:address:screen, console:address:console [ +<span class="muRecipe">def</span> chessboard screen:&:screen, console:&:console<span class="muRecipe"> -> </span>screen:&:screen, console:&:console [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> board:board<span class="Special"> <- </span>initial-position <span class="Comment"># hook up stdin</span> - stdin-in:address:source:character, stdin-out:address:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> + stdin-in:&:source:char, stdin-out:&:sink:char<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> start-running send-keys-to-channel, console, stdin-out, screen <span class="Comment"># buffer lines in stdin</span> - buffered-stdin-in:address:source:character, buffered-stdin-out:address:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> + buffered-stdin-in:&:source:char, buffered-stdin-out:&:sink:char<span class="Special"> <- </span>new-channel <span class="Constant">10/capacity</span> start-running buffer-lines, stdin-in, buffered-stdin-out <span class="Delimiter">{</span> print screen, <span class="Constant">[Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves.</span> @@ -124,7 +124,7 @@ type board = address:array:address:array:character <span class="Delimiter">{</span> cursor-to-next-line screen screen<span class="Special"> <- </span>print screen, <span class="Constant">[move: ]</span> - m:address:move, quit:boolean, error:boolean<span class="Special"> <- </span>read-move buffered-stdin-in, screen + m:&:move, quit:boolean, error:boolean<span class="Special"> <- </span>read-move buffered-stdin-in, screen <span class="muControl">break-if</span> quit, <span class="Constant">+quit:label</span> buffered-stdin-in<span class="Special"> <- </span>clear buffered-stdin-in <span class="Comment"># cleanup after error. todo: test this?</span> <span class="muControl">loop-if</span> error @@ -138,36 +138,36 @@ type board = address:array:address:array:character <span class="SalientComment">## a board is an array of files, a file is an array of characters (squares)</span> -<span class="muRecipe">def</span> new-board initial-position:address:array:character<span class="muRecipe"> -> </span>board:board [ +<span class="muRecipe">def</span> new-board initial-position:&:@:char<span class="muRecipe"> -> </span>board:board [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># assert(length(initial-position) == 64)</span> - len:number<span class="Special"> <- </span>length *initial-position + len:num<span class="Special"> <- </span>length *initial-position correct-length?:boolean<span class="Special"> <- </span>equal len, <span class="Constant">64</span> assert correct-length?, <span class="Constant">[chessboard had incorrect size]</span> <span class="Comment"># board is an array of pointers to files; file is an array of characters</span> board<span class="Special"> <- </span>new <span class="Delimiter">{</span>(address array character): type<span class="Delimiter">}</span>, <span class="Constant">8</span> - col:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + col:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>equal col, <span class="Constant">8</span> <span class="muControl">break-if</span> done? - file:address:array:character<span class="Special"> <- </span>new-file initial-position, col + file:&:@:char<span class="Special"> <- </span>new-file initial-position, col *board<span class="Special"> <- </span>put-index *board, col, file col<span class="Special"> <- </span>add col, <span class="Constant">1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> new-file position:address:array:character, index:number<span class="muRecipe"> -> </span>result:address:array:character [ +<span class="muRecipe">def</span> new-file position:&:@:char, index:num<span class="muRecipe"> -> </span>result:&:@:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> index<span class="Special"> <- </span>multiply index, <span class="Constant">8</span> result<span class="Special"> <- </span>new <span class="Constant">character:type</span>, <span class="Constant">8</span> - row:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + row:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>equal row, <span class="Constant">8</span> <span class="muControl">break-if</span> done? - square:character<span class="Special"> <- </span>index *position, index + square:char<span class="Special"> <- </span>index *position, index *result<span class="Special"> <- </span>put-index *result, row, square row<span class="Special"> <- </span>add row, <span class="Constant">1</span> index<span class="Special"> <- </span>add index, <span class="Constant">1</span> @@ -175,26 +175,26 @@ type board = address:array:address:array:character <span class="Delimiter">}</span> ] -<span class="muRecipe">def</span> print-board screen:address:screen, board:board<span class="muRecipe"> -> </span>screen:address:screen [ +<span class="muRecipe">def</span> print-board screen:&:screen, board:board<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - row:number<span class="Special"> <- </span>copy <span class="Constant">7</span> <span class="Comment"># start printing from the top of the board</span> - space:character<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + row:num<span class="Special"> <- </span>copy <span class="Constant">7</span> <span class="Comment"># start printing from the top of the board</span> + space:char<span class="Special"> <- </span>copy <span class="Constant">32/space</span> <span class="Comment"># print each row</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>lesser-than row, <span class="Constant">0</span> <span class="muControl">break-if</span> done? <span class="Comment"># print rank number as a legend</span> - rank:number<span class="Special"> <- </span>add row, <span class="Constant">1</span> + rank:num<span class="Special"> <- </span>add row, <span class="Constant">1</span> print-integer screen, rank print screen, <span class="Constant">[ | ]</span> <span class="Comment"># print each square in the row</span> - col:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + col:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>equal col:number, <span class="Constant">8</span> + done?:boolean<span class="Special"> <- </span>equal col:num, <span class="Constant">8</span> <span class="muControl">break-if</span> done?:boolean - f:address:array:character<span class="Special"> <- </span>index *board, col - c:character<span class="Special"> <- </span>index *f, row + f:&:@:char<span class="Special"> <- </span>index *board, col + c:char<span class="Special"> <- </span>index *f, row print screen, c print screen, space col<span class="Special"> <- </span>add col, <span class="Constant">1</span> @@ -222,7 +222,7 @@ type board = address:array:address:array:character <span class="Comment"># B P _ _ _ _ p B</span> <span class="Comment"># N P _ _ _ _ p n</span> <span class="Comment"># R P _ _ _ _ p r</span> - initial-position:address:array:character<span class="Special"> <- </span>new-array <span class="Constant">82/R</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">114/r</span>, <span class="Constant">78/N</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">110/n</span>, <span class="Constant">66/B</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">98/b</span>, <span class="Constant">81/Q</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">113/q</span>, <span class="Constant">75/K</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">107/k</span>, <span class="Constant">66/B</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">98/b</span>, <span class="Constant">78/N</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">110/n</span>, <span class="Constant">82/R</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">114/r</span> + initial-position:&:@:char<span class="Special"> <- </span>new-array <span class="Constant">82/R</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">114/r</span>, <span class="Constant">78/N</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">110/n</span>, <span class="Constant">66/B</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">98/b</span>, <span class="Constant">81/Q</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">113/q</span>, <span class="Constant">75/K</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">107/k</span>, <span class="Constant">66/B</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">98/b</span>, <span class="Constant">78/N</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">110/n</span>, <span class="Constant">82/R</span>, <span class="Constant">80/P</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">32/blank</span>, <span class="Constant">112/p</span>, <span class="Constant">114/r</span> <span class="CommentedCode">#? 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r,</span> <span class="CommentedCode">#? 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n,</span> <span class="CommentedCode">#? 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, </span> @@ -239,7 +239,7 @@ type board = address:array:address:array:character run [ <span class="Constant">local-scope</span> board:board<span class="Special"> <- </span>initial-position - screen:address:screen<span class="Special"> <- </span>print-board screen:address:screen, board + screen:&:screen<span class="Special"> <- </span>print-board screen:&:screen, board ] screen-should-contain [ <span class="Comment"># 012345678901234567890123456789</span> @@ -262,33 +262,33 @@ type board = address:array:address:array:character <span class="muData">container</span> move [ <span class="Comment"># valid range: 0-7</span> - from-file:number - from-rank:number - to-file:number - to-rank:number + from-file:num + from-rank:num + to-file:num + to-rank:num ] <span class="Comment"># prints only error messages to screen</span> -<span class="muRecipe">def</span> read-move stdin:address:source:character, screen:address:screen<span class="muRecipe"> -> </span>result:address:move, quit?:boolean, error?:boolean, stdin:address:source:character, screen:address:screen [ +<span class="muRecipe">def</span> read-move stdin:&:source:char, screen:&:screen<span class="muRecipe"> -> </span>result:&:move, quit?:boolean, error?:boolean, stdin:&:source:char, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - from-file:number, quit?:boolean, error?:boolean<span class="Special"> <- </span>read-file stdin, screen + from-file:num, quit?:boolean, error?:boolean<span class="Special"> <- </span>read-file stdin, screen <span class="muControl">return-if</span> quit?, <span class="Constant">0/dummy</span> <span class="muControl">return-if</span> error?, <span class="Constant">0/dummy</span> <span class="Comment"># construct the move object</span> - result:address:move<span class="Special"> <- </span>new <span class="Constant">move:type</span> + result:&:move<span class="Special"> <- </span>new <span class="Constant">move:type</span> *result<span class="Special"> <- </span>put *result, <span class="Constant">from-file:offset</span>, from-file - from-rank:number, quit?, error?<span class="Special"> <- </span>read-rank stdin, screen + from-rank:num, quit?, error?<span class="Special"> <- </span>read-rank stdin, screen <span class="muControl">return-if</span> quit?, <span class="Constant">0/dummy</span> <span class="muControl">return-if</span> error?, <span class="Constant">0/dummy</span> *result<span class="Special"> <- </span>put *result, <span class="Constant">from-rank:offset</span>, from-rank error?<span class="Special"> <- </span>expect-from-channel stdin, <span class="Constant">45/dash</span>, screen <span class="muControl">return-if</span> error?, <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span> - to-file:number, quit?, error?<span class="Special"> <- </span>read-file stdin, screen + to-file:num, quit?, error?<span class="Special"> <- </span>read-file stdin, screen <span class="muControl">return-if</span> quit?:boolean, <span class="Constant">0/dummy</span> <span class="muControl">return-if</span> error?:boolean, <span class="Constant">0/dummy</span> *result<span class="Special"> <- </span>put *result, <span class="Constant">to-file:offset</span>, to-file - to-rank:number, quit?, error?<span class="Special"> <- </span>read-rank stdin, screen + to-rank:num, quit?, error?<span class="Special"> <- </span>read-rank stdin, screen <span class="muControl">return-if</span> quit?, <span class="Constant">0/dummy</span> <span class="muControl">return-if</span> error?, <span class="Constant">0/dummy</span> *result<span class="Special"> <- </span>put *result, <span class="Constant">to-rank:offset</span>, to-rank @@ -297,10 +297,10 @@ type board = address:array:address:array:character ] <span class="Comment"># valid values for file: 0-7</span> -<span class="muRecipe">def</span> read-file stdin:address:source:character, screen:address:screen<span class="muRecipe"> -> </span>file:number, quit:boolean, error:boolean, stdin:address:source:character, screen:address:screen [ +<span class="muRecipe">def</span> read-file stdin:&:source:char, screen:&:screen<span class="muRecipe"> -> </span>file:num, quit:boolean, error:boolean, stdin:&:source:char, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - c:character, eof?:boolean, stdin<span class="Special"> <- </span>read stdin + c:char, eof?:boolean, stdin<span class="Special"> <- </span>read stdin <span class="muControl">return-if</span> eof?, <span class="Constant">0/dummy</span>, <span class="Constant">1/quit</span>, <span class="Constant">0/error</span> <span class="Delimiter">{</span> q-pressed?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">81/Q</span> @@ -323,7 +323,7 @@ type board = address:array:address:array:character print screen, <span class="Constant">[that's not enough]</span> <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span>, <span class="Constant">1/error</span> <span class="Delimiter">}</span> - file:number<span class="Special"> <- </span>subtract c, <span class="Constant">97/a</span> + file:num<span class="Special"> <- </span>subtract c, <span class="Constant">97/a</span> <span class="Comment"># 'a' <= file <= 'h'</span> <span class="Delimiter">{</span> above-min:boolean<span class="Special"> <- </span>greater-or-equal file, <span class="Constant">0</span> @@ -344,10 +344,10 @@ type board = address:array:address:array:character ] <span class="Comment"># valid values for rank: 0-7</span> -<span class="muRecipe">def</span> read-rank stdin:address:source:character, screen:address:screen<span class="muRecipe"> -> </span>rank:number, quit?:boolean, error?:boolean, stdin:address:source:character, screen:address:screen [ +<span class="muRecipe">def</span> read-rank stdin:&:source:char, screen:&:screen<span class="muRecipe"> -> </span>rank:num, quit?:boolean, error?:boolean, stdin:&:source:char, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - c:character, eof?:boolean, stdin<span class="Special"> <- </span>read stdin + c:char, eof?:boolean, stdin<span class="Special"> <- </span>read stdin <span class="muControl">return-if</span> eof?, <span class="Constant">0/dummy</span>, <span class="Constant">1/quit</span>, <span class="Constant">0/error</span> <span class="Delimiter">{</span> q-pressed?:boolean<span class="Special"> <- </span>equal c, <span class="Constant">8/Q</span> @@ -365,7 +365,7 @@ type board = address:array:address:array:character print screen, <span class="Constant">[that's not enough]</span> <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span>, <span class="Constant">1/error</span> <span class="Delimiter">}</span> - rank:number<span class="Special"> <- </span>subtract c, <span class="Constant">49/'1'</span> + rank:num<span class="Special"> <- </span>subtract c, <span class="Constant">49/'1'</span> <span class="Comment"># assert'1' <= rank <= '8'</span> <span class="Delimiter">{</span> above-min:boolean<span class="Special"> <- </span>greater-or-equal rank, <span class="Constant">0</span> @@ -386,10 +386,10 @@ type board = address:array:address:array:character <span class="Comment"># read a character from the given channel and check that it's what we expect</span> <span class="Comment"># return true on error</span> -<span class="muRecipe">def</span> expect-from-channel stdin:address:source:character, expected:character, screen:address:screen<span class="muRecipe"> -> </span>result:boolean, stdin:address:source:character, screen:address:screen [ +<span class="muRecipe">def</span> expect-from-channel stdin:&:source:char, expected:char, screen:&:screen<span class="muRecipe"> -> </span>result:boolean, stdin:&:source:char, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - c:character, eof?:boolean, stdin<span class="Special"> <- </span>read stdin + c:char, eof?:boolean, stdin<span class="Special"> <- </span>read stdin <span class="muControl">return-if</span> eof? <span class="Constant">1/true</span> <span class="Delimiter">{</span> match?:boolean<span class="Special"> <- </span>equal c, expected @@ -403,11 +403,11 @@ type board = address:array:address:array:character assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> run [ <span class="Constant">local-scope</span> - source:address:source:character, sink:address:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">2/capacity</span> - read-move-routine:number/routine<span class="Special"> <- </span>start-running read-move, source, screen:address:screen + source:&:source:char, sink:&:sink:char<span class="Special"> <- </span>new-channel <span class="Constant">2/capacity</span> + read-move-routine:num/routine<span class="Special"> <- </span>start-running read-move, source, screen:&:screen <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine-to-block read-move-routine - read-move-state:number<span class="Special"> <- </span>routine-state read-move-routine + read-move-state:num<span class="Special"> <- </span>routine-state read-move-routine waiting?:boolean<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-blocking: routine failed to pause after coming up (before any keys were pressed)]</span> @@ -476,11 +476,11 @@ type board = address:array:address:array:character assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> run [ <span class="Constant">local-scope</span> - source:address:source:character, sink:address:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">2/capacity</span> - read-move-routine:number<span class="Special"> <- </span>start-running read-move, source, screen:address:screen + source:&:source:char, sink:&:sink:char<span class="Special"> <- </span>new-channel <span class="Constant">2/capacity</span> + read-move-routine:num<span class="Special"> <- </span>start-running read-move, source, screen:&:screen <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine-to-block read-move-routine - read-move-state:number<span class="Special"> <- </span>routine-state read-move-routine + read-move-state:num<span class="Special"> <- </span>routine-state read-move-routine waiting?:boolean<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-quit: routine failed to pause after coming up (before any keys were pressed)]</span> @@ -504,11 +504,11 @@ type board = address:array:address:array:character assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> run [ <span class="Constant">local-scope</span> - source:address:source:character, sink:address:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">2/capacity</span> - read-move-routine:number<span class="Special"> <- </span>start-running read-move, source, screen:address:screen + source:&:source:char, sink:&:sink:char<span class="Special"> <- </span>new-channel <span class="Constant">2/capacity</span> + read-move-routine:num<span class="Special"> <- </span>start-running read-move, source, screen:&:screen <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine-to-block read-move-routine - read-move-state:number<span class="Special"> <- </span>routine-state read-move-routine + read-move-state:num<span class="Special"> <- </span>routine-state read-move-routine waiting?:boolean<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-illegal-file: routine failed to pause after coming up (before any keys were pressed)]</span> @@ -526,11 +526,11 @@ type board = address:array:address:array:character assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> run [ <span class="Constant">local-scope</span> - source:address:source:character, sink:address:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">2/capacity</span> - read-move-routine:number<span class="Special"> <- </span>start-running read-move, source, screen:address:screen + source:&:source:char, sink:&:sink:char<span class="Special"> <- </span>new-channel <span class="Constant">2/capacity</span> + read-move-routine:num<span class="Special"> <- </span>start-running read-move, source, screen:&:screen <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine-to-block read-move-routine - read-move-state:number<span class="Special"> <- </span>routine-state read-move-routine + read-move-state:num<span class="Special"> <- </span>routine-state read-move-routine waiting?:boolean<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-illegal-rank: routine failed to pause after coming up (before any keys were pressed)]</span> @@ -549,11 +549,11 @@ type board = address:array:address:array:character assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> run [ <span class="Constant">local-scope</span> - source:address:source:character, sink:address:sink:character<span class="Special"> <- </span>new-channel <span class="Constant">2/capacity</span> - read-move-routine:number<span class="Special"> <- </span>start-running read-move, source, screen:address:screen + source:&:source:char, sink:&:sink:char<span class="Special"> <- </span>new-channel <span class="Constant">2/capacity</span> + read-move-routine:num<span class="Special"> <- </span>start-running read-move, source, screen:&:screen <span class="Comment"># 'read-move' is waiting for input</span> wait-for-routine-to-block read-move-routine - read-move-state:number<span class="Special"> <- </span>routine-state read-move-routine + read-move-state:num<span class="Special"> <- </span>routine-state read-move-routine waiting?:boolean<span class="Special"> <- </span>not-equal read-move-state, <span class="Constant">2/discontinued</span> assert waiting?, <span class="Constant">[ </span> <span class="Constant">F read-move-empty: routine failed to pause after coming up (before any keys were pressed)]</span> @@ -568,16 +568,16 @@ type board = address:array:address:array:character ] ] -<span class="muRecipe">def</span> make-move board:board, m:address:move<span class="muRecipe"> -> </span>board:board [ +<span class="muRecipe">def</span> make-move board:board, m:&:move<span class="muRecipe"> -> </span>board:board [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - from-file:number<span class="Special"> <- </span>get *m, <span class="Constant">from-file:offset</span> - from-rank:number<span class="Special"> <- </span>get *m, <span class="Constant">from-rank:offset</span> - to-file:number<span class="Special"> <- </span>get *m, <span class="Constant">to-file:offset</span> - to-rank:number<span class="Special"> <- </span>get *m, <span class="Constant">to-rank:offset</span> - from-f:address:array:character<span class="Special"> <- </span>index *board, from-file - to-f:address:array:character<span class="Special"> <- </span>index *board, to-file - src:character/square<span class="Special"> <- </span>index *from-f, from-rank + from-file:num<span class="Special"> <- </span>get *m, <span class="Constant">from-file:offset</span> + from-rank:num<span class="Special"> <- </span>get *m, <span class="Constant">from-rank:offset</span> + to-file:num<span class="Special"> <- </span>get *m, <span class="Constant">to-file:offset</span> + to-rank:num<span class="Special"> <- </span>get *m, <span class="Constant">to-rank:offset</span> + from-f:&:@:char<span class="Special"> <- </span>index *board, from-file + to-f:&:@:char<span class="Special"> <- </span>index *board, to-file + src:char/square<span class="Special"> <- </span>index *from-f, from-rank *to-f<span class="Special"> <- </span>put-index *to-f, to-rank, src *from-f<span class="Special"> <- </span>put-index *from-f, from-rank, <span class="Constant">32/space</span> ] @@ -587,10 +587,10 @@ type board = address:array:address:array:character run [ <span class="Constant">local-scope</span> board:board<span class="Special"> <- </span>initial-position - move:address:move<span class="Special"> <- </span>new <span class="Constant">move:type</span> + move:&:move<span class="Special"> <- </span>new <span class="Constant">move:type</span> *move<span class="Special"> <- </span>merge <span class="Constant">6/g</span>, <span class="Constant">1/'2'</span>, <span class="Constant">6/g</span>, <span class="Constant">3/'4'</span> board<span class="Special"> <- </span>make-move board, move - screen:address:screen<span class="Special"> <- </span>print-board screen:address:screen, board + screen:&:screen<span class="Special"> <- </span>print-board screen:&:screen, board ] screen-should-contain [ <span class="Comment"># 012345678901234567890123456789</span> |