diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-12-27 22:20:43 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-12-27 22:20:43 -0800 |
commit | 97eb971b7574b3f283d7111a567a301faec9912d (patch) | |
tree | 4a1f9d1987ca601efba78865c8b3d1766d23af92 /html/chessboard.mu.html | |
parent | df0c0babff599b0ab85f56cd50ee0b4143f12886 (diff) | |
download | mu-97eb971b7574b3f283d7111a567a301faec9912d.tar.gz |
3725
More improvements to cross-linking example programs. Include their own functions as well in the tags for each program, even as you share the core .mu files everywhere.
Diffstat (limited to 'html/chessboard.mu.html')
-rw-r--r-- | html/chessboard.mu.html | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/html/chessboard.mu.html b/html/chessboard.mu.html index b4bb9426..3abf7bd9 100644 --- a/html/chessboard.mu.html +++ b/html/chessboard.mu.html @@ -63,7 +63,7 @@ if ('onhashchange' in window) { <span id="L1" class="LineNr"> 1 </span><span class="Comment"># Chessboard program: you type in moves in algebraic notation, and it'll</span> <span id="L2" class="LineNr"> 2 </span><span class="Comment"># display the position after each move.</span> <span id="L3" class="LineNr"> 3 </span> -<span id="L4" class="LineNr"> 4 </span><span class="muRecipe">def</span> main [ +<span id="L4" class="LineNr"> 4 </span><span class="muRecipe">def</span> <a href='chessboard.mu.html#L4'>main</a> [ <span id="L5" class="LineNr"> 5 </span> <span class="Constant">local-scope</span> <span id="L6" class="LineNr"> 6 </span> open-console <span class="Comment"># take control of screen, keyboard and mouse</span> <span id="L7" class="LineNr"> 7 </span> @@ -74,7 +74,7 @@ if ('onhashchange' in window) { <span id="L12" class="LineNr"> 12 </span> <span class="Comment">#</span> <span id="L13" class="LineNr"> 13 </span> <span class="Comment"># Here the console and screen are both 0, which usually indicates real</span> <span id="L14" class="LineNr"> 14 </span> <span class="Comment"># hardware rather than a fake for testing as you'll see below.</span> -<span id="L15" class="LineNr"> 15 </span> chessboard <span class="Constant">0/screen</span>, <span class="Constant">0/console</span> +<span id="L15" class="LineNr"> 15 </span> <a href='chessboard.mu.html#L68'>chessboard</a> <span class="Constant">0/screen</span>, <span class="Constant">0/console</span> <span id="L16" class="LineNr"> 16 </span> <span id="L17" class="LineNr"> 17 </span> close-console <span class="Comment"># clean up screen, keyboard and mouse</span> <span id="L18" class="LineNr"> 18 </span>] @@ -92,7 +92,7 @@ if ('onhashchange' in window) { <span id="L30" class="LineNr"> 30 </span><span class="Constant">]</span> <span id="L31" class="LineNr"> 31 </span> ] <span id="L32" class="LineNr"> 32 </span> run [ -<span id="L33" class="LineNr"> 33 </span> <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a>, <a href='084console.mu.html#L23'>console</a>:&:<a href='084console.mu.html#L23'>console</a> <span class="Special"><-</span> chessboard <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a>, <a href='084console.mu.html#L23'>console</a>:&:<a href='084console.mu.html#L23'>console</a> +<span id="L33" class="LineNr"> 33 </span> <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a>, <a href='084console.mu.html#L23'>console</a>:&:<a href='084console.mu.html#L23'>console</a> <span class="Special"><-</span> <a href='chessboard.mu.html#L68'>chessboard</a> <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a>, <a href='084console.mu.html#L23'>console</a>:&:<a href='084console.mu.html#L23'>console</a> <span id="L34" class="LineNr"> 34 </span> <span class="Comment"># icon for the cursor</span> <span id="L35" class="LineNr"> 35 </span> cursor-icon:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> <span id="L36" class="LineNr"> 36 </span> <a href='081print.mu.html#L4'>screen</a> <span class="Special"><-</span> print <a href='081print.mu.html#L4'>screen</a>, cursor-icon @@ -113,7 +113,7 @@ if ('onhashchange' in window) { <span id="L51" class="LineNr"> 51 </span> <span class="Constant"> . +---------------- .</span> <span id="L52" class="LineNr"> 52 </span> <span class="Constant"> . a b c d e f g h .</span> <span id="L53" class="LineNr"> 53 </span> <span class="Constant"> . .</span> -<span id="L54" class="LineNr"> 54 </span> <span class="Constant"> .Type in your move as <from square>-<to square>. For example: 'a2-a4'. Then press <enter>. .</span> +<span id="L54" class="LineNr"> 54 </span> <span class="Constant"> .Type in your <a href='chessboard.mu.html#L228'>move</a> as <from square>-<to square>. For example: 'a2-a4'. Then press <enter>. .</span> <span id="L55" class="LineNr"> 55 </span> <span class="Constant"> . .</span> <span id="L56" class="LineNr"> 56 </span> <span class="Constant"> .Hit 'q' to exit. .</span> <span id="L57" class="LineNr"> 57 </span> <span class="Constant"> . .</span> @@ -127,10 +127,10 @@ if ('onhashchange' in window) { <span id="L65" class="LineNr"> 65 </span> <span id="L66" class="LineNr"> 66 </span><span class="muData">type</span> board = &:@:&:@:char <span class="Comment"># a 2-D array of arrays of characters</span> <span id="L67" class="LineNr"> 67 </span> -<span id="L68" class="LineNr"> 68 </span><span class="muRecipe">def</span> chessboard <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a>, <a href='084console.mu.html#L23'>console</a>:&:<a href='084console.mu.html#L23'>console</a><span class="muRecipe"> -> </span><a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a>, <a href='084console.mu.html#L23'>console</a>:&:<a href='084console.mu.html#L23'>console</a> [ +<span id="L68" class="LineNr"> 68 </span><span class="muRecipe">def</span> <a href='chessboard.mu.html#L68'>chessboard</a> <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a>, <a href='084console.mu.html#L23'>console</a>:&:<a href='084console.mu.html#L23'>console</a><span class="muRecipe"> -> </span><a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a>, <a href='084console.mu.html#L23'>console</a>:&:<a href='084console.mu.html#L23'>console</a> [ <span id="L69" class="LineNr"> 69 </span> <span class="Constant">local-scope</span> <span id="L70" class="LineNr"> 70 </span> <span class="Constant">load-ingredients</span> -<span id="L71" class="LineNr"> 71 </span> board:board <span class="Special"><-</span> initial-position +<span id="L71" class="LineNr"> 71 </span> board:board <span class="Special"><-</span> <a href='chessboard.mu.html#L179'>initial-position</a> <span id="L72" class="LineNr"> 72 </span> <span class="Comment"># hook up stdin</span> <span id="L73" class="LineNr"> 73 </span> stdin-in:&:source:char, stdin-out:&:sink:char <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">10/capacity</span> <span id="L74" class="LineNr"> 74 </span> start-running <a href='084console.mu.html#L73'>send-keys-to-channel</a>, <a href='084console.mu.html#L23'>console</a>, stdin-out, <a href='081print.mu.html#L4'>screen</a> @@ -141,9 +141,9 @@ if ('onhashchange' in window) { <span id="L79" class="LineNr"> 79 </span> print <a href='081print.mu.html#L4'>screen</a>, <span class="Constant">[Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves.</span> <span id="L80" class="LineNr"> 80 </span><span class="Constant">]</span> <span id="L81" class="LineNr"> 81 </span> <a href='081print.mu.html#L567'>cursor-to-next-line</a> <a href='081print.mu.html#L4'>screen</a> -<span id="L82" class="LineNr"> 82 </span> print-board <a href='081print.mu.html#L4'>screen</a>, board +<span id="L82" class="LineNr"> 82 </span> <a href='chessboard.mu.html#L143'>print-board</a> <a href='081print.mu.html#L4'>screen</a>, board <span id="L83" class="LineNr"> 83 </span> <a href='081print.mu.html#L567'>cursor-to-next-line</a> <a href='081print.mu.html#L4'>screen</a> -<span id="L84" class="LineNr"> 84 </span> print <a href='081print.mu.html#L4'>screen</a>, <span class="Constant">[Type in your move as <from square>-<to square>. For example: 'a2-a4'. Then press <enter>.</span> +<span id="L84" class="LineNr"> 84 </span> print <a href='081print.mu.html#L4'>screen</a>, <span class="Constant">[Type in your <a href='chessboard.mu.html#L228'>move</a> as <from square>-<to square>. For example: 'a2-a4'. Then press <enter>.</span> <span id="L85" class="LineNr"> 85 </span><span class="Constant">]</span> <span id="L86" class="LineNr"> 86 </span> <a href='081print.mu.html#L567'>cursor-to-next-line</a> <a href='081print.mu.html#L4'>screen</a> <span id="L87" class="LineNr"> 87 </span> print <a href='081print.mu.html#L4'>screen</a> <span class="Constant">[Hit 'q' to exit.</span> @@ -151,12 +151,12 @@ if ('onhashchange' in window) { <span id="L89" class="LineNr"> 89 </span> <span class="Delimiter">{</span> <span id="L90" class="LineNr"> 90 </span> <a href='081print.mu.html#L567'>cursor-to-next-line</a> <a href='081print.mu.html#L4'>screen</a> <span id="L91" class="LineNr"> 91 </span> <a href='081print.mu.html#L4'>screen</a> <span class="Special"><-</span> print <a href='081print.mu.html#L4'>screen</a>, <span class="Constant">[move: ]</span> -<span id="L92" class="LineNr"> 92 </span> m:&:move, quit:bool, error:bool <span class="Special"><-</span> read-move buffered-stdin-in, <a href='081print.mu.html#L4'>screen</a> +<span id="L92" class="LineNr"> 92 </span> m:&:<a href='chessboard.mu.html#L228'>move</a>, quit:bool, error:bool <span class="Special"><-</span> <a href='chessboard.mu.html#L237'>read-move</a> buffered-stdin-in, <a href='081print.mu.html#L4'>screen</a> <span id="L93" class="LineNr"> 93 </span> <span class="muControl">break-if</span> quit, <span class="Constant">+quit</span> <span id="L94" class="LineNr"> 94 </span> buffered-stdin-in <span class="Special"><-</span> <a href='075channel.mu.html#L161'>clear</a> buffered-stdin-in <span class="Comment"># cleanup after error. todo: test this?</span> <span id="L95" class="LineNr"> 95 </span> <span class="muControl">loop-if</span> error <span id="L96" class="LineNr"> 96 </span> <span class="Delimiter">}</span> -<span id="L97" class="LineNr"> 97 </span> board <span class="Special"><-</span> make-move board, m +<span id="L97" class="LineNr"> 97 </span> board <span class="Special"><-</span> <a href='chessboard.mu.html#L536'>make-move</a> board, m <span id="L98" class="LineNr"> 98 </span> <a href='081print.mu.html#L4'>screen</a> <span class="Special"><-</span> <a href='081print.mu.html#L27'>clear-screen</a> <a href='081print.mu.html#L4'>screen</a> <span id="L99" class="LineNr"> 99 </span> <span class="muControl">loop</span> <span id="L100" class="LineNr">100 </span> <span class="Delimiter">}</span> @@ -165,7 +165,7 @@ if ('onhashchange' in window) { <span id="L103" class="LineNr">103 </span> <span id="L104" class="LineNr">104 </span><span class="SalientComment">## a board is an array of files, a file is an array of characters (squares)</span> <span id="L105" class="LineNr">105 </span> -<span id="L106" class="LineNr">106 </span><span class="muRecipe">def</span> new-board initial-position:&:@:char<span class="muRecipe"> -> </span>board:board [ +<span id="L106" class="LineNr">106 </span><span class="muRecipe">def</span> <a href='chessboard.mu.html#L106'>new-board</a> <a href='chessboard.mu.html#L179'>initial-position</a>:&:@:char<span class="muRecipe"> -> </span>board:board [ <span id="L107" class="LineNr">107 </span> <span class="Constant">local-scope</span> <span id="L108" class="LineNr">108 </span> <span class="Constant">load-ingredients</span> <span id="L109" class="LineNr">109 </span> <span class="Comment"># assert(length(initial-position) == 64)</span> @@ -178,14 +178,14 @@ if ('onhashchange' in window) { <span id="L116" class="LineNr">116 </span> <span class="Delimiter">{</span> <span id="L117" class="LineNr">117 </span> done?:bool <span class="Special"><-</span> equal col,<span class="Constant"> 8</span> <span id="L118" class="LineNr">118 </span> <span class="muControl">break-if</span> done? -<span id="L119" class="LineNr">119 </span> file:&:@:char <span class="Special"><-</span> new-file initial-position, col +<span id="L119" class="LineNr">119 </span> file:&:@:char <span class="Special"><-</span> <a href='chessboard.mu.html#L126'>new-file</a> <a href='chessboard.mu.html#L179'>initial-position</a>, col <span id="L120" class="LineNr">120 </span> *board <span class="Special"><-</span> put-index *board, col, file <span id="L121" class="LineNr">121 </span> col <span class="Special"><-</span> add col,<span class="Constant"> 1</span> <span id="L122" class="LineNr">122 </span> <span class="muControl">loop</span> <span id="L123" class="LineNr">123 </span> <span class="Delimiter">}</span> <span id="L124" class="LineNr">124 </span>] <span id="L125" class="LineNr">125 </span> -<span id="L126" class="LineNr">126 </span><span class="muRecipe">def</span> new-file position:&:@:char, index:num<span class="muRecipe"> -> </span>result:&:@:char [ +<span id="L126" class="LineNr">126 </span><span class="muRecipe">def</span> <a href='chessboard.mu.html#L126'>new-file</a> position:&:@:char, index:num<span class="muRecipe"> -> </span>result:&:@:char [ <span id="L127" class="LineNr">127 </span> <span class="Constant">local-scope</span> <span id="L128" class="LineNr">128 </span> <span class="Constant">load-ingredients</span> <span id="L129" class="LineNr">129 </span> index <span class="Special"><-</span> multiply index,<span class="Constant"> 8</span> @@ -202,7 +202,7 @@ if ('onhashchange' in window) { <span id="L140" class="LineNr">140 </span> <span class="Delimiter">}</span> <span id="L141" class="LineNr">141 </span>] <span id="L142" class="LineNr">142 </span> -<span id="L143" class="LineNr">143 </span><span class="muRecipe">def</span> print-board <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a>, board:board<span class="muRecipe"> -> </span><a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> [ +<span id="L143" class="LineNr">143 </span><span class="muRecipe">def</span> <a href='chessboard.mu.html#L143'>print-board</a> <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a>, board:board<span class="muRecipe"> -> </span><a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> [ <span id="L144" class="LineNr">144 </span> <span class="Constant">local-scope</span> <span id="L145" class="LineNr">145 </span> <span class="Constant">load-ingredients</span> <span id="L146" class="LineNr">146 </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> @@ -238,7 +238,7 @@ if ('onhashchange' in window) { <span id="L176" class="LineNr">176 </span> <a href='081print.mu.html#L567'>cursor-to-next-line</a> <a href='081print.mu.html#L4'>screen</a> <span id="L177" class="LineNr">177 </span>] <span id="L178" class="LineNr">178 </span> -<span id="L179" class="LineNr">179 </span><span class="muRecipe">def</span> initial-position<span class="muRecipe"> -> </span>board:board [ +<span id="L179" class="LineNr">179 </span><span class="muRecipe">def</span> <a href='chessboard.mu.html#L179'>initial-position</a><span class="muRecipe"> -> </span>board:board [ <span id="L180" class="LineNr">180 </span> <span class="Constant">local-scope</span> <span id="L181" class="LineNr">181 </span> <span class="Comment"># layout in memory (in raster order):</span> <span id="L182" class="LineNr">182 </span> <span class="Comment"># R P _ _ _ _ p r</span> @@ -249,7 +249,7 @@ if ('onhashchange' in window) { <span id="L187" class="LineNr">187 </span> <span class="Comment"># B P _ _ _ _ p B</span> <span id="L188" class="LineNr">188 </span> <span class="Comment"># N P _ _ _ _ p n</span> <span id="L189" class="LineNr">189 </span> <span class="Comment"># R P _ _ _ _ p r</span> -<span id="L190" class="LineNr">190 </span> initial-position:&:@:char <span class="Special"><-</span> <a href='063array.mu.html#L16'>new-array</a> <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 id="L190" class="LineNr">190 </span> <a href='chessboard.mu.html#L179'>initial-position</a>:&:@:char <span class="Special"><-</span> <a href='063array.mu.html#L16'>new-array</a> <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 id="L191" class="LineNr">191 </span><span class="CommentedCode">#? 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r,</span> <span id="L192" class="LineNr">192 </span><span class="CommentedCode">#? 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n,</span> <span id="L193" class="LineNr">193 </span><span class="CommentedCode">#? 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, </span> @@ -258,15 +258,15 @@ if ('onhashchange' in window) { <span id="L196" class="LineNr">196 </span><span class="CommentedCode">#? 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b,</span> <span id="L197" class="LineNr">197 </span><span class="CommentedCode">#? 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n,</span> <span id="L198" class="LineNr">198 </span><span class="CommentedCode">#? 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r</span> -<span id="L199" class="LineNr">199 </span> board <span class="Special"><-</span> new-board initial-position +<span id="L199" class="LineNr">199 </span> board <span class="Special"><-</span> <a href='chessboard.mu.html#L106'>new-board</a> <a href='chessboard.mu.html#L179'>initial-position</a> <span id="L200" class="LineNr">200 </span>] <span id="L201" class="LineNr">201 </span> <span id="L202" class="LineNr">202 </span><span class="muScenario">scenario</span> printing-the-board [ <span id="L203" class="LineNr">203 </span> <span class="Constant">local-scope</span> -<span id="L204" class="LineNr">204 </span> board:board <span class="Special"><-</span> initial-position +<span id="L204" class="LineNr">204 </span> board:board <span class="Special"><-</span> <a href='chessboard.mu.html#L179'>initial-position</a> <span id="L205" class="LineNr">205 </span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">12/height</span> <span id="L206" class="LineNr">206 </span> run [ -<span id="L207" class="LineNr">207 </span> <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> <span class="Special"><-</span> print-board <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a>, board +<span id="L207" class="LineNr">207 </span> <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> <span class="Special"><-</span> <a href='chessboard.mu.html#L143'>print-board</a> <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a>, board <span id="L208" class="LineNr">208 </span> ] <span id="L209" class="LineNr">209 </span> screen-should-contain [ <span id="L210" class="LineNr">210 </span> <span class="Comment"># 012345678901234567890123456789</span> @@ -287,7 +287,7 @@ if ('onhashchange' in window) { <span id="L225" class="LineNr">225 </span> <span id="L226" class="LineNr">226 </span><span class="SalientComment">## data structure: move</span> <span id="L227" class="LineNr">227 </span> -<span id="L228" class="LineNr">228 </span><span class="muData">container</span> move [ +<span id="L228" class="LineNr">228 </span><span class="muData">container</span> <a href='chessboard.mu.html#L228'>move</a> [ <span id="L229" class="LineNr">229 </span> <span class="Comment"># valid range: 0-7</span> <span id="L230" class="LineNr">230 </span> from-file:num <span id="L231" class="LineNr">231 </span> from-rank:num @@ -296,35 +296,35 @@ if ('onhashchange' in window) { <span id="L234" class="LineNr">234 </span>] <span id="L235" class="LineNr">235 </span> <span id="L236" class="LineNr">236 </span><span class="Comment"># prints only error messages to screen</span> -<span id="L237" class="LineNr">237 </span><span class="muRecipe">def</span> read-move stdin:&:source:char, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a><span class="muRecipe"> -> </span>result:&:move, quit?:bool, error?:bool, stdin:&:source:char, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> [ +<span id="L237" class="LineNr">237 </span><span class="muRecipe">def</span> <a href='chessboard.mu.html#L237'>read-move</a> stdin:&:source:char, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a><span class="muRecipe"> -> </span>result:&:<a href='chessboard.mu.html#L228'>move</a>, quit?:bool, error?:bool, stdin:&:source:char, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> [ <span id="L238" class="LineNr">238 </span> <span class="Constant">local-scope</span> <span id="L239" class="LineNr">239 </span> <span class="Constant">load-ingredients</span> -<span id="L240" class="LineNr">240 </span> from-file:num, quit?:bool, error?:bool <span class="Special"><-</span> read-file stdin, <a href='081print.mu.html#L4'>screen</a> +<span id="L240" class="LineNr">240 </span> from-file:num, quit?:bool, error?:bool <span class="Special"><-</span> <a href='chessboard.mu.html#L265'>read-file</a> stdin, <a href='081print.mu.html#L4'>screen</a> <span id="L241" class="LineNr">241 </span> <span class="muControl">return-if</span> quit?, <span class="Constant">0/dummy</span> <span id="L242" class="LineNr">242 </span> <span class="muControl">return-if</span> error?, <span class="Constant">0/dummy</span> <span id="L243" class="LineNr">243 </span> <span class="Comment"># construct the move object</span> -<span id="L244" class="LineNr">244 </span> result:&:move <span class="Special"><-</span> new <span class="Constant">move:type</span> +<span id="L244" class="LineNr">244 </span> result:&:<a href='chessboard.mu.html#L228'>move</a> <span class="Special"><-</span> new <span class="Constant"><a href='chessboard.mu.html#L228'>move</a>:type</span> <span id="L245" class="LineNr">245 </span> *result <span class="Special"><-</span> put *result, <span class="Constant">from-file:offset</span>, from-file -<span id="L246" class="LineNr">246 </span> from-rank:num, quit?, error? <span class="Special"><-</span> read-rank stdin, <a href='081print.mu.html#L4'>screen</a> +<span id="L246" class="LineNr">246 </span> from-rank:num, quit?, error? <span class="Special"><-</span> <a href='chessboard.mu.html#L312'>read-rank</a> stdin, <a href='081print.mu.html#L4'>screen</a> <span id="L247" class="LineNr">247 </span> <span class="muControl">return-if</span> quit?, <span class="Constant">0/dummy</span> <span id="L248" class="LineNr">248 </span> <span class="muControl">return-if</span> error?, <span class="Constant">0/dummy</span> <span id="L249" class="LineNr">249 </span> *result <span class="Special"><-</span> put *result, <span class="Constant">from-rank:offset</span>, from-rank -<span id="L250" class="LineNr">250 </span> error? <span class="Special"><-</span> expect-from-channel stdin, <span class="Constant">45/dash</span>, <a href='081print.mu.html#L4'>screen</a> +<span id="L250" class="LineNr">250 </span> error? <span class="Special"><-</span> <a href='chessboard.mu.html#L354'>expect-from-channel</a> stdin, <span class="Constant">45/dash</span>, <a href='081print.mu.html#L4'>screen</a> <span id="L251" class="LineNr">251 </span> <span class="muControl">return-if</span> error?, <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span> -<span id="L252" class="LineNr">252 </span> to-file:num, quit?, error? <span class="Special"><-</span> read-file stdin, <a href='081print.mu.html#L4'>screen</a> +<span id="L252" class="LineNr">252 </span> to-file:num, quit?, error? <span class="Special"><-</span> <a href='chessboard.mu.html#L265'>read-file</a> stdin, <a href='081print.mu.html#L4'>screen</a> <span id="L253" class="LineNr">253 </span> <span class="muControl">return-if</span> quit?:bool, <span class="Constant">0/dummy</span> <span id="L254" class="LineNr">254 </span> <span class="muControl">return-if</span> error?:bool, <span class="Constant">0/dummy</span> <span id="L255" class="LineNr">255 </span> *result <span class="Special"><-</span> put *result, <span class="Constant">to-file:offset</span>, to-file -<span id="L256" class="LineNr">256 </span> to-rank:num, quit?, error? <span class="Special"><-</span> read-rank stdin, <a href='081print.mu.html#L4'>screen</a> +<span id="L256" class="LineNr">256 </span> to-rank:num, quit?, error? <span class="Special"><-</span> <a href='chessboard.mu.html#L312'>read-rank</a> stdin, <a href='081print.mu.html#L4'>screen</a> <span id="L257" class="LineNr">257 </span> <span class="muControl">return-if</span> quit?, <span class="Constant">0/dummy</span> <span id="L258" class="LineNr">258 </span> <span class="muControl">return-if</span> error?, <span class="Constant">0/dummy</span> <span id="L259" class="LineNr">259 </span> *result <span class="Special"><-</span> put *result, <span class="Constant">to-rank:offset</span>, to-rank -<span id="L260" class="LineNr">260 </span> error? <span class="Special"><-</span> expect-from-channel stdin, <span class="Constant">10/newline</span>, <a href='081print.mu.html#L4'>screen</a> +<span id="L260" class="LineNr">260 </span> error? <span class="Special"><-</span> <a href='chessboard.mu.html#L354'>expect-from-channel</a> stdin, <span class="Constant">10/newline</span>, <a href='081print.mu.html#L4'>screen</a> <span id="L261" class="LineNr">261 </span> <span class="muControl">return-if</span> error?, <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span> <span id="L262" class="LineNr">262 </span>] <span id="L263" class="LineNr">263 </span> <span id="L264" class="LineNr">264 </span><span class="Comment"># valid values for file: 0-7</span> -<span id="L265" class="LineNr">265 </span><span class="muRecipe">def</span> read-file stdin:&:source:char, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a><span class="muRecipe"> -> </span>file:num, quit:bool, error:bool, stdin:&:source:char, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> [ +<span id="L265" class="LineNr">265 </span><span class="muRecipe">def</span> <a href='chessboard.mu.html#L265'>read-file</a> stdin:&:source:char, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a><span class="muRecipe"> -> </span>file:num, quit:bool, error:bool, stdin:&:source:char, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> [ <span id="L266" class="LineNr">266 </span> <span class="Constant">local-scope</span> <span id="L267" class="LineNr">267 </span> <span class="Constant">load-ingredients</span> <span id="L268" class="LineNr">268 </span> c:char, eof?:bool, stdin <span class="Special"><-</span> read stdin @@ -371,7 +371,7 @@ if ('onhashchange' in window) { <span id="L309" class="LineNr">309 </span>] <span id="L310" class="LineNr">310 </span> <span id="L311" class="LineNr">311 </span><span class="Comment"># valid values for rank: 0-7</span> -<span id="L312" class="LineNr">312 </span><span class="muRecipe">def</span> read-rank stdin:&:source:char, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a><span class="muRecipe"> -> </span>rank:num, quit?:bool, error?:bool, stdin:&:source:char, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> [ +<span id="L312" class="LineNr">312 </span><span class="muRecipe">def</span> <a href='chessboard.mu.html#L312'>read-rank</a> stdin:&:source:char, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a><span class="muRecipe"> -> </span>rank:num, quit?:bool, error?:bool, stdin:&:source:char, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> [ <span id="L313" class="LineNr">313 </span> <span class="Constant">local-scope</span> <span id="L314" class="LineNr">314 </span> <span class="Constant">load-ingredients</span> <span id="L315" class="LineNr">315 </span> c:char, eof?:bool, stdin <span class="Special"><-</span> read stdin @@ -413,7 +413,7 @@ if ('onhashchange' in window) { <span id="L351" class="LineNr">351 </span> <span id="L352" class="LineNr">352 </span><span class="Comment"># read a character from the given channel and check that it's what we expect</span> <span id="L353" class="LineNr">353 </span><span class="Comment"># return true on error</span> -<span id="L354" class="LineNr">354 </span><span class="muRecipe">def</span> expect-from-channel stdin:&:source:char, expected:char, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a><span class="muRecipe"> -> </span>result:bool, stdin:&:source:char, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> [ +<span id="L354" class="LineNr">354 </span><span class="muRecipe">def</span> <a href='chessboard.mu.html#L354'>expect-from-channel</a> stdin:&:source:char, expected:char, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a><span class="muRecipe"> -> </span>result:bool, stdin:&:source:char, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> [ <span id="L355" class="LineNr">355 </span> <span class="Constant">local-scope</span> <span id="L356" class="LineNr">356 </span> <span class="Constant">load-ingredients</span> <span id="L357" class="LineNr">357 </span> c:char, eof?:bool, stdin <span class="Special"><-</span> read stdin @@ -430,7 +430,7 @@ if ('onhashchange' in window) { <span id="L368" class="LineNr">368 </span> <span class="Constant">local-scope</span> <span id="L369" class="LineNr">369 </span> assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> <span id="L370" class="LineNr">370 </span> source:&:source:char, sink:&:sink:char <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">2/capacity</span> -<span id="L371" class="LineNr">371 </span> read-move-routine:num/routine <span class="Special"><-</span> start-running read-move, source, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> +<span id="L371" class="LineNr">371 </span> read-move-routine:num/routine <span class="Special"><-</span> start-running <a href='chessboard.mu.html#L237'>read-move</a>, source, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> <span id="L372" class="LineNr">372 </span> run [ <span id="L373" class="LineNr">373 </span> <span class="Comment"># 'read-move' is waiting for input</span> <span id="L374" class="LineNr">374 </span> wait-for-routine-to-block read-move-routine @@ -503,7 +503,7 @@ if ('onhashchange' in window) { <span id="L441" class="LineNr">441 </span> <span class="Constant">local-scope</span> <span id="L442" class="LineNr">442 </span> assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> <span id="L443" class="LineNr">443 </span> source:&:source:char, sink:&:sink:char <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">2/capacity</span> -<span id="L444" class="LineNr">444 </span> read-move-routine:num <span class="Special"><-</span> start-running read-move, source, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> +<span id="L444" class="LineNr">444 </span> read-move-routine:num <span class="Special"><-</span> start-running <a href='chessboard.mu.html#L237'>read-move</a>, source, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> <span id="L445" class="LineNr">445 </span> run [ <span id="L446" class="LineNr">446 </span> <span class="Comment"># 'read-move' is waiting for input</span> <span id="L447" class="LineNr">447 </span> wait-for-routine-to-block read-move-routine @@ -531,7 +531,7 @@ if ('onhashchange' in window) { <span id="L469" class="LineNr">469 </span> <span class="Constant">local-scope</span> <span id="L470" class="LineNr">470 </span> assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> <span id="L471" class="LineNr">471 </span> source:&:source:char, sink:&:sink:char <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">2/capacity</span> -<span id="L472" class="LineNr">472 </span> read-move-routine:num <span class="Special"><-</span> start-running read-move, source, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> +<span id="L472" class="LineNr">472 </span> read-move-routine:num <span class="Special"><-</span> start-running <a href='chessboard.mu.html#L237'>read-move</a>, source, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> <span id="L473" class="LineNr">473 </span> run [ <span id="L474" class="LineNr">474 </span> <span class="Comment"># 'read-move' is waiting for input</span> <span id="L475" class="LineNr">475 </span> wait-for-routine-to-block read-move-routine @@ -553,7 +553,7 @@ if ('onhashchange' in window) { <span id="L491" class="LineNr">491 </span> <span class="Constant">local-scope</span> <span id="L492" class="LineNr">492 </span> assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> <span id="L493" class="LineNr">493 </span> source:&:source:char, sink:&:sink:char <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">2/capacity</span> -<span id="L494" class="LineNr">494 </span> read-move-routine:num <span class="Special"><-</span> start-running read-move, source, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> +<span id="L494" class="LineNr">494 </span> read-move-routine:num <span class="Special"><-</span> start-running <a href='chessboard.mu.html#L237'>read-move</a>, source, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> <span id="L495" class="LineNr">495 </span> run [ <span id="L496" class="LineNr">496 </span> <span class="Comment"># 'read-move' is waiting for input</span> <span id="L497" class="LineNr">497 </span> wait-for-routine-to-block read-move-routine @@ -576,7 +576,7 @@ if ('onhashchange' in window) { <span id="L514" class="LineNr">514 </span> <span class="Constant">local-scope</span> <span id="L515" class="LineNr">515 </span> assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span> <span id="L516" class="LineNr">516 </span> source:&:source:char, sink:&:sink:char <span class="Special"><-</span> <a href='075channel.mu.html#L51'>new-channel</a> <span class="Constant">2/capacity</span> -<span id="L517" class="LineNr">517 </span> read-move-routine:num <span class="Special"><-</span> start-running read-move, source, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> +<span id="L517" class="LineNr">517 </span> read-move-routine:num <span class="Special"><-</span> start-running <a href='chessboard.mu.html#L237'>read-move</a>, source, <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> <span id="L518" class="LineNr">518 </span> run [ <span id="L519" class="LineNr">519 </span> <span class="Comment"># 'read-move' is waiting for input</span> <span id="L520" class="LineNr">520 </span> wait-for-routine-to-block read-move-routine @@ -595,7 +595,7 @@ if ('onhashchange' in window) { <span id="L533" class="LineNr">533 </span> ] <span id="L534" class="LineNr">534 </span>] <span id="L535" class="LineNr">535 </span> -<span id="L536" class="LineNr">536 </span><span class="muRecipe">def</span> make-move board:board, m:&:move<span class="muRecipe"> -> </span>board:board [ +<span id="L536" class="LineNr">536 </span><span class="muRecipe">def</span> <a href='chessboard.mu.html#L536'>make-move</a> board:board, m:&:<a href='chessboard.mu.html#L228'>move</a><span class="muRecipe"> -> </span>board:board [ <span id="L537" class="LineNr">537 </span> <span class="Constant">local-scope</span> <span id="L538" class="LineNr">538 </span> <span class="Constant">load-ingredients</span> <span id="L539" class="LineNr">539 </span> from-file:num <span class="Special"><-</span> get *m, <span class="Constant">from-file:offset</span> @@ -612,12 +612,12 @@ if ('onhashchange' in window) { <span id="L550" class="LineNr">550 </span><span class="muScenario">scenario</span> making-a-move [ <span id="L551" class="LineNr">551 </span> <span class="Constant">local-scope</span> <span id="L552" class="LineNr">552 </span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">12/height</span> -<span id="L553" class="LineNr">553 </span> board:board <span class="Special"><-</span> initial-position -<span id="L554" class="LineNr">554 </span> move:&:move <span class="Special"><-</span> new <span class="Constant">move:type</span> +<span id="L553" class="LineNr">553 </span> board:board <span class="Special"><-</span> <a href='chessboard.mu.html#L179'>initial-position</a> +<span id="L554" class="LineNr">554 </span> <a href='chessboard.mu.html#L228'>move</a>:&:<a href='chessboard.mu.html#L228'>move</a> <span class="Special"><-</span> new <span class="Constant"><a href='chessboard.mu.html#L228'>move</a>:type</span> <span id="L555" class="LineNr">555 </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> <span id="L556" class="LineNr">556 </span> run [ -<span id="L557" class="LineNr">557 </span> board <span class="Special"><-</span> make-move board, move -<span id="L558" class="LineNr">558 </span> <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> <span class="Special"><-</span> print-board <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a>, board +<span id="L557" class="LineNr">557 </span> board <span class="Special"><-</span> <a href='chessboard.mu.html#L536'>make-move</a> board, <a href='chessboard.mu.html#L228'>move</a> +<span id="L558" class="LineNr">558 </span> <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a> <span class="Special"><-</span> <a href='chessboard.mu.html#L143'>print-board</a> <a href='081print.mu.html#L4'>screen</a>:&:<a href='081print.mu.html#L4'>screen</a>, board <span id="L559" class="LineNr">559 </span> ] <span id="L560" class="LineNr">560 </span> screen-should-contain [ <span id="L561" class="LineNr">561 </span> <span class="Comment"># 012345678901234567890123456789</span> |