about summary refs log tree commit diff stats
path: root/html/chessboard.mu.html
blob: 250da96b9e71103465fb518603c8256db659ede8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Mu - chessboard.mu</title>
<meta name="Generator" content="Vim/7.3">
<meta name="plugin-version" content="vim7.3_v6">
<meta name="syntax" content="none">
<meta name="settings" content="use_css">
<style type="text/css">
<!--
pre { font-family: monospace; color: #eeeeee; background-color: #080808; }
body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; }
.muData { color: #ffff00; }
.CommentedCode { color: #6c6c6c; }
.muControl { color: #c0a020; }
.Delimiter { color: #800080; }
.Special { color: #ff6060; }
.muScenario { color: #00af00; }
.SalientComment { color: #00ffff; }
.Constant { color: #00a0a0; }
.muRecipe { color: #ff8700; }
.Comment { color: #9090ff; }
-->
</style>
</head>
<body>
<pre>
<span class="Comment"># Chessboard program: you type in moves in algebraic notation, and it'll</span>
<span class="Comment"># display the position after each move.</span>

<span class="Comment"># recipes are mu's names for functions</span>
<span class="muRecipe">def</span> main [
  open-console  <span class="Comment"># take control of screen, keyboard and mouse</span>

  <span class="Comment"># The chessboard recipe takes keyboard and screen objects as 'ingredients'.</span>
  <span class="Comment">#</span>
  <span class="Comment"># In mu it is good form (though not required) to explicitly show the</span>
  <span class="Comment"># hardware you rely on.</span>
  <span class="Comment">#</span>
  <span class="Comment"># The chessboard also returns the same keyboard and screen objects. In mu it</span>
  <span class="Comment"># is good form to not modify ingredients of a recipe unless they are also</span>
  <span class="Comment"># results. Here we clearly modify both keyboard and screen, so we return</span>
  <span class="Comment"># both.</span>
  <span class="Comment">#</span>
  <span class="Comment"># Here the console and screen are both 0, which usually indicates real</span>
  <span class="Comment"># hardware rather than a fake for testing as you'll see below.</span>
  chessboard <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>

  close-console  <span class="Comment"># cleanup screen, keyboard and mouse</span>
]

<span class="SalientComment">## But enough about mu. Here's what it looks like to run the chessboard program.</span>

<span class="muScenario">scenario</span> print-board-and-read-move [
  trace-until <span class="Constant">100/app</span>
  <span class="Comment"># we'll make the screen really wide because the program currently prints out a long line</span>
  assume-screen <span class="Constant">120/width</span>, <span class="Constant">20/height</span>
  <span class="Comment"># initialize keyboard to type in a move</span>
  assume-console [
    type <span class="Constant">[a2-a4</span>
<span class="Constant">]</span>
  ]
  run [
    screen:address:shared:screen, console:address:shared:console<span class="Special"> &lt;- </span>chessboard screen:address:shared:screen, console:address:shared:console
    <span class="Comment"># icon for the cursor</span>
    screen<span class="Special"> &lt;- </span>print screen, <span class="Constant">9251/␣</span>
  ]
  screen-should-contain [
  <span class="Comment">#            1         2         3         4         5         6         7         8         9         10        11</span>
  <span class="Comment">#  012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789</span>
   <span class="Constant"> .Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves.         .</span>
   <span class="Constant"> .                                                                                                                        .</span>
   <span class="Constant"> .8 | r n b q k b n r                                                                                                     .</span>
   <span class="Constant"> .7 | p p p p p p p p                                                                                                     .</span>
   <span class="Constant"> .6 |                                                                                                                     .</span>
   <span class="Constant"> .5 |                                                                                                                     .</span>
   <span class="Constant"> .4 | P                                                                                                                   .</span>
   <span class="Constant"> .3 |                                                                                                                     .</span>
   <span class="Constant"> .2 |   P P P P P P P                                                                                                     .</span>
   <span class="Constant"> .1 | R N B Q K B N R                                                                                                     .</span>
   <span class="Constant"> .  +----------------                                                                                                     .</span>
   <span class="Constant"> .    a b c d e f g h                                                                                                     .</span>
   <span class="Constant"> .                                                                                                                        .</span>
   <span class="Constant"> .Type in your move as &lt;from square&gt;-&lt;to square&gt;. For example: 'a2-a4'. Then press &lt;enter&gt;.                               .</span>
   <span class="Constant"> .                                                                                                                        .</span>
   <span class="Constant"> .Hit 'q' to exit.                                                                                                        .</span>
   <span class="Constant"> .                                                                                                                        .</span>
   <span class="Constant"> .move: ␣                                                                                                                 .</span>
   <span class="Constant"> .                                                                                                                        .</span>
   <span class="Constant"> .                                                                                                                        .</span>
  ]
]

<span class="SalientComment">## Here's how 'chessboard' is implemented.</span>

<span class="muRecipe">def</span> chessboard screen:address:shared:screen, console:address:shared:console<span class="muRecipe"> -&gt; </span>screen:address:shared:screen, console:address:shared:console [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  board:address:shared:array:address:shared:array:character<span class="Special"> &lt;- </span>initial-position
  <span class="Comment"># hook up stdin</span>
  stdin:address:shared:channel<span class="Special"> &lt;- </span>new-channel <span class="Constant">10/capacity</span>
  start-running send-keys-to-channel, console, stdin, screen
  <span class="Comment"># buffer lines in stdin</span>
  buffered-stdin:address:shared:channel<span class="Special"> &lt;- </span>new-channel <span class="Constant">10/capacity</span>
  start-running buffer-lines, stdin, buffered-stdin
  <span class="Delimiter">{</span>
    msg:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves.</span>
<span class="Constant">]</span>
    print screen, msg
    cursor-to-next-line screen
    print-board screen, board
    cursor-to-next-line screen
    msg<span class="Special"> &lt;- </span>new <span class="Constant">[Type in your move as &lt;from square&gt;-&lt;to square&gt;. For example: 'a2-a4'. Then press &lt;enter&gt;.</span>
<span class="Constant">]</span>
    print screen, msg
    cursor-to-next-line screen
    msg<span class="Special"> &lt;- </span>new <span class="Constant">[Hit 'q' to exit.</span>
<span class="Constant">]</span>
    print screen, msg
    <span class="Delimiter">{</span>
      cursor-to-next-line screen
      msg<span class="Special"> &lt;- </span>new <span class="Constant">[move: ]</span>
      screen<span class="Special"> &lt;- </span>print screen, msg
      m:address:shared:move, quit:boolean, error:boolean<span class="Special"> &lt;- </span>read-move buffered-stdin, screen
      <span class="muControl">break-if</span> quit, <span class="Constant">+quit:label</span>
      buffered-stdin<span class="Special"> &lt;- </span>clear-channel buffered-stdin  <span class="Comment"># cleanup after error. todo: test this?</span>
      <span class="muControl">loop-if</span> error
    <span class="Delimiter">}</span>
    board<span class="Special"> &lt;- </span>make-move board, m
    screen<span class="Special"> &lt;- </span>clear-screen screen
    <span class="muControl">loop</span>
  <span class="Delimiter">}</span>
  msg<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
<span class="Constant">  +quit</span>
]

<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:shared:array:character<span class="muRecipe"> -&gt; </span>board:address:shared:array:address:shared:array:character [
  <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"> &lt;- </span>length *initial-position
  correct-length?:boolean<span class="Special"> &lt;- </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"> &lt;- </span>new <span class="Delimiter">{</span>(address shared array character): type<span class="Delimiter">}</span>, <span class="Constant">8</span>
  col:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
  <span class="Delimiter">{</span>
    done?:boolean<span class="Special"> &lt;- </span>equal col, <span class="Constant">8</span>
    <span class="muControl">break-if</span> done?
    file:address:address:shared:array:character<span class="Special"> &lt;- </span>index-address *board, col
    *file<span class="Special"> &lt;- </span>new-file initial-position, col
    col<span class="Special"> &lt;- </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:shared:array:character, index:number<span class="muRecipe"> -&gt; </span>result:address:shared:array:character [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  index<span class="Special"> &lt;- </span>multiply index, <span class="Constant">8</span>
  result<span class="Special"> &lt;- </span>new <span class="Constant">character:type</span>, <span class="Constant">8</span>
  row:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
  <span class="Delimiter">{</span>
    done?:boolean<span class="Special"> &lt;- </span>equal row, <span class="Constant">8</span>
    <span class="muControl">break-if</span> done?
    dest:address:character<span class="Special"> &lt;- </span>index-address *result, row
    *dest<span class="Special"> &lt;- </span>index *position, index
    row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span>
    index<span class="Special"> &lt;- </span>add index, <span class="Constant">1</span>
    <span class="muControl">loop</span>
  <span class="Delimiter">}</span>
]

<span class="muRecipe">def</span> print-board screen:address:shared:screen, board:address:shared:array:address:shared:array:character<span class="muRecipe"> -&gt; </span>screen:address:shared:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  row:number<span class="Special"> &lt;- </span>copy <span class="Constant">7</span>  <span class="Comment"># start printing from the top of the board</span>
  space:character<span class="Special"> &lt;- </span>copy <span class="Constant">32/space</span>
  <span class="Comment"># print each row</span>
  <span class="Delimiter">{</span>
    done?:boolean<span class="Special"> &lt;- </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"> &lt;- </span>add row, <span class="Constant">1</span>
    print-integer screen, rank
    s:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[ | ]</span>
    print screen, s
    <span class="Comment"># print each square in the row</span>
    col:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
    <span class="Delimiter">{</span>
      done?:boolean<span class="Special"> &lt;- </span>equal col:number, <span class="Constant">8</span>
      <span class="muControl">break-if</span> done?:boolean
      f:address:shared:array:character<span class="Special"> &lt;- </span>index *board, col
      c:character<span class="Special"> &lt;- </span>index *f, row
      print screen, c
      print screen, space
      col<span class="Special"> &lt;- </span>add col, <span class="Constant">1</span>
      <span class="muControl">loop</span>
    <span class="Delimiter">}</span>
    row<span class="Special"> &lt;- </span>subtract row, <span class="Constant">1</span>
    cursor-to-next-line screen
    <span class="muControl">loop</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># print file letters as legend</span>
  s<span class="Special"> &lt;- </span>new <span class="Constant">[  +----------------]</span>
  print screen, s
  screen<span class="Special"> &lt;- </span>cursor-to-next-line screen
  s<span class="Special"> &lt;- </span>new <span class="Constant">[    a b c d e f g h]</span>
  screen<span class="Special"> &lt;- </span>print screen, s
  screen<span class="Special"> &lt;- </span>cursor-to-next-line screen
]

<span class="muRecipe">def</span> initial-position<span class="muRecipe"> -&gt; </span>board:address:shared:array:address:shared:array:character [
  <span class="Constant">local-scope</span>
  <span class="Comment"># layout in memory (in raster order):</span>
  <span class="Comment">#   R P _ _ _ _ p r</span>
  <span class="Comment">#   N P _ _ _ _ p n</span>
  <span class="Comment">#   B P _ _ _ _ p b</span>
  <span class="Comment">#   Q P _ _ _ _ p q</span>
  <span class="Comment">#   K P _ _ _ _ p k</span>
  <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:shared:array:character<span class="Special"> &lt;- </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>
<span class="CommentedCode">#?       81/Q, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 113/q,</span>
<span class="CommentedCode">#?       75/K, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 107/k,</span>
<span class="CommentedCode">#?       66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b,</span>
<span class="CommentedCode">#?       78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n,</span>
<span class="CommentedCode">#?       82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r</span>
  board<span class="Special"> &lt;- </span>new-board initial-position
]

<span class="muScenario">scenario</span> printing-the-board [
  assume-screen <span class="Constant">30/width</span>, <span class="Constant">12/height</span>
  run [
    <span class="Constant">1</span>:address:shared:array:address:shared:array:character/board<span class="Special"> &lt;- </span>initial-position
    screen:address:shared:screen<span class="Special"> &lt;- </span>print-board screen:address:shared:screen, <span class="Constant">1</span>:address:shared:array:address:shared:array:character/board
  ]
  screen-should-contain [
  <span class="Comment">#  012345678901234567890123456789</span>
   <span class="Constant"> .8 | r n b q k b n r           .</span>
   <span class="Constant"> .7 | p p p p p p p p           .</span>
   <span class="Constant"> .6 |                           .</span>
   <span class="Constant"> .5 |                           .</span>
   <span class="Constant"> .4 |                           .</span>
   <span class="Constant"> .3 |                           .</span>
   <span class="Constant"> .2 | P P P P P P P P           .</span>
   <span class="Constant"> .1 | R N B Q K B N R           .</span>
   <span class="Constant"> .  +----------------           .</span>
   <span class="Constant"> .    a b c d e f g h           .</span>
   <span class="Constant"> .                              .</span>
   <span class="Constant"> .                              .</span>
  ]
]

<span class="SalientComment">## data structure: move</span>

<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
]

<span class="Comment"># prints only error messages to screen</span>
<span class="muRecipe">def</span> read-move stdin:address:shared:channel, screen:address:shared:screen<span class="muRecipe"> -&gt; </span>result:address:shared:move, quit?:boolean, error?:boolean, stdin:address:shared:channel, screen:address:shared:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  from-file:number, quit?:boolean, error?:boolean<span class="Special"> &lt;- </span>read-file stdin, screen
  <span class="muControl">return-if</span> quit?, <span class="Constant">0/dummy</span>, quit?, error?
  <span class="muControl">return-if</span> error?, <span class="Constant">0/dummy</span>, quit?, error?
  <span class="Comment"># construct the move object</span>
  result:address:shared:move<span class="Special"> &lt;- </span>new <span class="Constant">move:type</span>
  x:address:number<span class="Special"> &lt;- </span>get-address *result, <span class="Constant">from-file:offset</span>
  *x<span class="Special"> &lt;- </span>copy from-file
  x<span class="Special"> &lt;- </span>get-address *result, <span class="Constant">from-rank:offset</span>
  *x, quit?, error?<span class="Special"> &lt;- </span>read-rank stdin, screen
  <span class="muControl">return-if</span> quit?, <span class="Constant">0/dummy</span>, quit?, error?
  <span class="muControl">return-if</span> error?, <span class="Constant">0/dummy</span>, quit?, error?
  error?<span class="Special"> &lt;- </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>, error?
  x<span class="Special"> &lt;- </span>get-address *result, <span class="Constant">to-file:offset</span>
  *x, quit?, error?<span class="Special"> &lt;- </span>read-file stdin, screen
  <span class="muControl">return-if</span> quit?:boolean, <span class="Constant">0/dummy</span>, quit?:boolean, error?:boolean
  <span class="muControl">return-if</span> error?:boolean, <span class="Constant">0/dummy</span>, quit?:boolean, error?:boolean
  x:address:number<span class="Special"> &lt;- </span>get-address *result, <span class="Constant">to-rank:offset</span>
  *x, quit?, error?<span class="Special"> &lt;- </span>read-rank stdin, screen
  <span class="muControl">return-if</span> quit?, <span class="Constant">0/dummy</span>, quit?, error?
  <span class="muControl">return-if</span> error?, <span class="Constant">0/dummy</span>, quit?, error?
  error?<span class="Special"> &lt;- </span>expect-from-channel stdin, <span class="Constant">10/newline</span>, screen
  <span class="muControl">return-if</span> error?, <span class="Constant">0/dummy</span>, <span class="Constant">0/quit</span>, error?
  <span class="muControl">return</span> result, quit?, error?
]

<span class="Comment"># valid values for file: 0-7</span>
<span class="muRecipe">def</span> read-file stdin:address:shared:channel, screen:address:shared:screen<span class="muRecipe"> -&gt; </span>file:number, quit:boolean, error:boolean, stdin:address:shared:channel, screen:address:shared:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  c:character, stdin<span class="Special"> &lt;- </span>read stdin
  <span class="Delimiter">{</span>
    q-pressed?:boolean<span class="Special"> &lt;- </span>equal c, <span class="Constant">81/Q</span>
    <span class="muControl">break-unless</span> q-pressed?
    <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">1/quit</span>, <span class="Constant">0/error</span>
  <span class="Delimiter">}</span>
  <span class="Delimiter">{</span>
    q-pressed?<span class="Special"> &lt;- </span>equal c, <span class="Constant">113/q</span>
    <span class="muControl">break-unless</span> q-pressed?
    <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">1/quit</span>, <span class="Constant">0/error</span>
  <span class="Delimiter">}</span>
  <span class="Delimiter">{</span>
    empty-fake-keyboard?:boolean<span class="Special"> &lt;- </span>equal c, <span class="Constant">0/eof</span>
    <span class="muControl">break-unless</span> empty-fake-keyboard?
    <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">1/quit</span>, <span class="Constant">0/error</span>
  <span class="Delimiter">}</span>
  <span class="Delimiter">{</span>
    newline?:boolean<span class="Special"> &lt;- </span>equal c, <span class="Constant">10/newline</span>
    <span class="muControl">break-unless</span> newline?
    error-message:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[that's not enough]</span>
    print screen, error-message
    <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"> &lt;- </span>subtract c, <span class="Constant">97/a</span>
  <span class="Comment"># 'a' &lt;= file &lt;= 'h'</span>
  <span class="Delimiter">{</span>
    above-min:boolean<span class="Special"> &lt;- </span>greater-or-equal file, <span class="Constant">0</span>
    <span class="muControl">break-if</span> above-min
    error-message:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[file too low: ]</span>
    print screen, error-message
    print screen, c
    cursor-to-next-line screen
    <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>
  <span class="Delimiter">{</span>
    below-max:boolean<span class="Special"> &lt;- </span>lesser-than file, <span class="Constant">8</span>
    <span class="muControl">break-if</span> below-max
    error-message<span class="Special"> &lt;- </span>new <span class="Constant">[file too high: ]</span>
    print screen, error-message
    print screen, c
    <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>
  <span class="muControl">return</span> file, <span class="Constant">0/quit</span>, <span class="Constant">0/error</span>
]

<span class="Comment"># valid values: 0-7, -1 (quit), -2 (error)</span>
<span class="muRecipe">def</span> read-rank stdin:address:shared:channel, screen:address:shared:screen<span class="muRecipe"> -&gt; </span>rank:number, quit?:boolean, error?:boolean, stdin:address:shared:channel, screen:address:shared:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  c:character, stdin<span class="Special"> &lt;- </span>read stdin
  <span class="Delimiter">{</span>
    q-pressed?:boolean<span class="Special"> &lt;- </span>equal c, <span class="Constant">8/Q</span>
    <span class="muControl">break-unless</span> q-pressed?
    <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">1/quit</span>, <span class="Constant">0/error</span>
  <span class="Delimiter">}</span>
  <span class="Delimiter">{</span>
    q-pressed?<span class="Special"> &lt;- </span>equal c, <span class="Constant">113/q</span>
    <span class="muControl">break-unless</span> q-pressed?
    <span class="muControl">return</span> <span class="Constant">0/dummy</span>, <span class="Constant">1/quit</span>, <span class="Constant">0/error</span>
  <span class="Delimiter">}</span>
  <span class="Delimiter">{</span>
    newline?:boolean<span class="Special"> &lt;- </span>equal c, <span class="Constant">10</span>  <span class="Comment"># newline</span>
    <span class="muControl">break-unless</span> newline?
    error-message:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[that's not enough]</span>
    print screen, error-message
    <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"> &lt;- </span>subtract c, <span class="Constant">49/'1'</span>
  <span class="Comment"># assert'1' &lt;= rank &lt;= '8'</span>
  <span class="Delimiter">{</span>
    above-min:boolean<span class="Special"> &lt;- </span>greater-or-equal rank, <span class="Constant">0</span>
    <span class="muControl">break-if</span> above-min
    error-message<span class="Special"> &lt;- </span>new <span class="Constant">[rank too low: ]</span>
    print screen, error-message
    print screen, c
    <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>
  <span class="Delimiter">{</span>
    below-max:boolean<span class="Special"> &lt;- </span>lesser-or-equal rank, <span class="Constant">7</span>
    <span class="muControl">break-if</span> below-max
    error-message<span class="Special"> &lt;- </span>new <span class="Constant">[rank too high: ]</span>
    print screen, error-message
    print screen, c
    <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>
  <span class="muControl">return</span> rank, <span class="Constant">0/quit</span>, <span class="Constant">0/error</span>
]

<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:shared:channel, expected:character, screen:address:shared:screen<span class="muRecipe"> -&gt; </span>result:boolean, stdin:address:shared:channel, screen:address:shared:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  c:character, stdin<span class="Special"> &lt;- </span>read stdin
  <span class="Delimiter">{</span>
    match?:boolean<span class="Special"> &lt;- </span>equal c, expected
    <span class="muControl">break-if</span> match?
    s:address:shared:array:character<span class="Special"> &lt;- </span>new <span class="Constant">[expected character not found]</span>
    print screen, s
  <span class="Delimiter">}</span>
  result<span class="Special"> &lt;- </span>not match?
]

<span class="muScenario">scenario</span> read-move-blocking [
  assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span>
  run [
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>new-channel <span class="Constant">2</span>
    <span class="Constant">2</span>:number/routine<span class="Special"> &lt;- </span>start-running read-move, <span class="Constant">1</span>:address:shared:channel, screen:address:shared:screen
    <span class="Comment"># 'read-move' is waiting for input</span>
    wait-for-routine <span class="Constant">2</span>:number
    <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>routine-state <span class="Constant">2</span>:number/id
    <span class="Constant">4</span>:boolean/waiting?<span class="Special"> &lt;- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span>
    assert <span class="Constant">4</span>:boolean/waiting?, [
F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> coming up (<span class="muRecipe">before</span> any keys were pressed)]
    <span class="Comment"># press 'a'</span>
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span>
    restart <span class="Constant">2</span>:number/routine
    <span class="Comment"># 'read-move' still waiting for input</span>
    wait-for-routine <span class="Constant">2</span>:number
    <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>routine-state <span class="Constant">2</span>:number/id
    <span class="Constant">4</span>:boolean/waiting?<span class="Special"> &lt;- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span>
    assert <span class="Constant">4</span>:boolean/waiting?, [
F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> rank 'a']
    <span class="Comment"># press '2'</span>
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">50/'2'</span>
    restart <span class="Constant">2</span>:number/routine
    <span class="Comment"># 'read-move' still waiting for input</span>
    wait-for-routine <span class="Constant">2</span>:number
    <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>routine-state <span class="Constant">2</span>:number/id
    <span class="Constant">4</span>:boolean/waiting?<span class="Special"> &lt;- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span>
    assert <span class="Constant">4</span>:boolean/waiting?, [
F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> file 'a2']
    <span class="Comment"># press '-'</span>
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">45/'-'</span>
    restart <span class="Constant">2</span>:number/routine
    <span class="Comment"># 'read-move' still waiting for input</span>
    wait-for-routine <span class="Constant">2</span>:number
    <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>routine-state <span class="Constant">2</span>:number
    <span class="Constant">4</span>:boolean/waiting?<span class="Special"> &lt;- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span>
    assert <span class="Constant">4</span>:boolean/waiting?/routine-state, [
F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> hyphen 'a2-']
    <span class="Comment"># press 'a'</span>
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span>
    restart <span class="Constant">2</span>:number/routine
    <span class="Comment"># 'read-move' still waiting for input</span>
    wait-for-routine <span class="Constant">2</span>:number
    <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>routine-state <span class="Constant">2</span>:number
    <span class="Constant">4</span>:boolean/waiting?<span class="Special"> &lt;- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span>
    assert <span class="Constant">4</span>:boolean/waiting?/routine-state, [
F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> rank 'a2-a']
    <span class="Comment"># press '4'</span>
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">52/'4'</span>
    restart <span class="Constant">2</span>:number/routine
    <span class="Comment"># 'read-move' still waiting for input</span>
    wait-for-routine <span class="Constant">2</span>:number
    <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>routine-state <span class="Constant">2</span>:number
    <span class="Constant">4</span>:boolean/waiting?<span class="Special"> &lt;- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span>
    assert <span class="Constant">4</span>:boolean/waiting?, [
F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> file 'a2-a4']
    <span class="Comment"># press 'newline'</span>
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">10</span>  <span class="Comment"># newline</span>
    restart <span class="Constant">2</span>:number/routine
    <span class="Comment"># 'read-move' now completes</span>
    wait-for-routine <span class="Constant">2</span>:number
    <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>routine-state <span class="Constant">2</span>:number
    <span class="Constant">4</span>:boolean/completed?<span class="Special"> &lt;- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">1/completed</span>
    assert <span class="Constant">4</span>:boolean/completed?, [
F read-move-blocking: routine failed to terminate on newline]
    trace <span class="Constant">1</span>, <span class="Constant">[test]</span>, <span class="Constant">[reached end]</span>
  ]
  trace-should-contain [
    test: reached end
  ]
]

<span class="muScenario">scenario</span> read-move-quit [
  assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span>
  run [
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>new-channel <span class="Constant">2</span>
    <span class="Constant">2</span>:number/routine<span class="Special"> &lt;- </span>start-running read-move, <span class="Constant">1</span>:address:shared:channel, screen:address:shared:screen
    <span class="Comment"># 'read-move' is waiting for input</span>
    wait-for-routine <span class="Constant">2</span>:number
    <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>routine-state <span class="Constant">2</span>:number/id
    <span class="Constant">4</span>:boolean/waiting?<span class="Special"> &lt;- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span>
    assert <span class="Constant">4</span>:boolean/waiting?, [
F read-move-quit: routine failed to pause <span class="muRecipe">after</span> coming up (<span class="muRecipe">before</span> any keys were pressed)]
    <span class="Comment"># press 'q'</span>
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">113/q</span>
    restart <span class="Constant">2</span>:number/routine
    <span class="Comment"># 'read-move' completes</span>
    wait-for-routine <span class="Constant">2</span>:number
    <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>routine-state <span class="Constant">2</span>:number/id
    <span class="Constant">4</span>:boolean/completed?<span class="Special"> &lt;- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">1/completed</span>
    assert <span class="Constant">4</span>:boolean/completed?, [
F read-move-quit: routine failed to terminate on 'q']
    trace <span class="Constant">1</span>, <span class="Constant">[test]</span>, <span class="Constant">[reached end]</span>
  ]
  trace-should-contain [
    test: reached end
  ]
]

<span class="muScenario">scenario</span> read-move-illegal-file [
  assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span>
  run [
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>new-channel <span class="Constant">2</span>
    <span class="Constant">2</span>:number/routine<span class="Special"> &lt;- </span>start-running read-move, <span class="Constant">1</span>:address:shared:channel, screen:address:shared:screen
    <span class="Comment"># 'read-move' is waiting for input</span>
    wait-for-routine <span class="Constant">2</span>:number
    <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>routine-state <span class="Constant">2</span>:number/id
    <span class="Constant">4</span>:boolean/waiting?<span class="Special"> &lt;- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span>
    assert <span class="Constant">4</span>:boolean/waiting?, [
F read-move-file: routine failed to pause <span class="muRecipe">after</span> coming up (<span class="muRecipe">before</span> any keys were pressed)]
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">50/'2'</span>
    restart <span class="Constant">2</span>:number/routine
    wait-for-routine <span class="Constant">2</span>:number
  ]
  screen-should-contain [
   <span class="Constant"> .file too low: 2     .</span>
   <span class="Constant"> .                    .</span>
  ]
]

<span class="muScenario">scenario</span> read-move-illegal-rank [
  assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span>
  run [
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>new-channel <span class="Constant">2</span>
    <span class="Constant">2</span>:number/routine<span class="Special"> &lt;- </span>start-running read-move, <span class="Constant">1</span>:address:shared:channel, screen:address:shared:screen
    <span class="Comment"># 'read-move' is waiting for input</span>
    wait-for-routine <span class="Constant">2</span>:number
    <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>routine-state <span class="Constant">2</span>:number/id
    <span class="Constant">4</span>:boolean/waiting?<span class="Special"> &lt;- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span>
    assert <span class="Constant">4</span>:boolean/waiting?, [
F read-move-file: routine failed to pause <span class="muRecipe">after</span> coming up (<span class="muRecipe">before</span> any keys were pressed)]
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span>
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span>
    restart <span class="Constant">2</span>:number/routine
    wait-for-routine <span class="Constant">2</span>:number
  ]
  screen-should-contain [
   <span class="Constant"> .rank too high: a    .</span>
   <span class="Constant"> .                    .</span>
  ]
]

<span class="muScenario">scenario</span> read-move-empty [
  assume-screen <span class="Constant">20/width</span>, <span class="Constant">2/height</span>
  run [
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>new-channel <span class="Constant">2</span>
    <span class="Constant">2</span>:number/routine<span class="Special"> &lt;- </span>start-running read-move, <span class="Constant">1</span>:address:shared:channel, screen:address:shared:screen
    <span class="Comment"># 'read-move' is waiting for input</span>
    wait-for-routine <span class="Constant">2</span>:number
    <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>routine-state <span class="Constant">2</span>:number/id
    <span class="Constant">4</span>:boolean/waiting?<span class="Special"> &lt;- </span>equal <span class="Constant">3</span>:number/routine-state, <span class="Constant">3/waiting</span>
    assert <span class="Constant">4</span>:boolean/waiting?, [
F read-move-file: routine failed to pause <span class="muRecipe">after</span> coming up (<span class="muRecipe">before</span> any keys were pressed)]
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">10/newline</span>
    <span class="Constant">1</span>:address:shared:channel<span class="Special"> &lt;- </span>write <span class="Constant">1</span>:address:shared:channel, <span class="Constant">97/a</span>
    restart <span class="Constant">2</span>:number/routine
    wait-for-routine <span class="Constant">2</span>:number
  ]
  screen-should-contain [
   <span class="Constant"> .that's not enough   .</span>
   <span class="Constant"> .                    .</span>
  ]
]

<span class="muRecipe">def</span> make-move board:address:shared:array:address:shared:array:character, m:address:shared:move<span class="muRecipe"> -&gt; </span>board:address:shared:array:address:shared:array:character [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  from-file:number<span class="Special"> &lt;- </span>get *m, <span class="Constant">from-file:offset</span>
  from-rank:number<span class="Special"> &lt;- </span>get *m, <span class="Constant">from-rank:offset</span>
  to-file:number<span class="Special"> &lt;- </span>get *m, <span class="Constant">to-file:offset</span>
  to-rank:number<span class="Special"> &lt;- </span>get *m, <span class="Constant">to-rank:offset</span>
  f:address:shared:array:character<span class="Special"> &lt;- </span>index *board, from-file
  src:address:character/square<span class="Special"> &lt;- </span>index-address *f, from-rank
  f<span class="Special"> &lt;- </span>index *board, to-file
  dest:address:character/square<span class="Special"> &lt;- </span>index-address *f, to-rank
  *dest<span class="Special"> &lt;- </span>copy *src
  *src<span class="Special"> &lt;- </span>copy <span class="Constant">32/space</span>
]

<span class="muScenario">scenario</span> making-a-move [
  assume-screen <span class="Constant">30/width</span>, <span class="Constant">12/height</span>
  run [
    <span class="Constant">2</span>:address:shared:array:address:shared:array:character/board<span class="Special"> &lt;- </span>initial-position
    <span class="Constant">3</span>:address:shared:move<span class="Special"> &lt;- </span>new <span class="Constant">move:type</span>
    <span class="Constant">4</span>:address:number<span class="Special"> &lt;- </span>get-address *<span class="Constant">3</span>:address:shared:move, <span class="Constant">from-file:offset</span>
    *<span class="Constant">4</span>:address:number<span class="Special"> &lt;- </span>copy <span class="Constant">6/g</span>
    <span class="Constant">5</span>:address:number<span class="Special"> &lt;- </span>get-address *<span class="Constant">3</span>:address:shared:move, <span class="Constant">from-rank:offset</span>
    *<span class="Constant">5</span>:address:number<span class="Special"> &lt;- </span>copy <span class="Constant">1/'2'</span>
    <span class="Constant">6</span>:address:number<span class="Special"> &lt;- </span>get-address *<span class="Constant">3</span>:address:shared:move, <span class="Constant">to-file:offset</span>
    *<span class="Constant">6</span>:address:number<span class="Special"> &lt;- </span>copy <span class="Constant">6/g</span>
    <span class="Constant">7</span>:address:number<span class="Special"> &lt;- </span>get-address *<span class="Constant">3</span>:address:shared:move, <span class="Constant">to-rank:offset</span>
    *<span class="Constant">7</span>:address:number<span class="Special"> &lt;- </span>copy <span class="Constant">3/'4'</span>
    <span class="Constant">2</span>:address:shared:array:address:shared:array:character/board<span class="Special"> &lt;- </span>make-move <span class="Constant">2</span>:address:shared:array:address:shared:array:character/board, <span class="Constant">3</span>:address:shared:move
    screen:address:shared:screen<span class="Special"> &lt;- </span>print-board screen:address:shared:screen, <span class="Constant">2</span>:address:shared:array:address:shared:array:character/board
  ]
  screen-should-contain [
  <span class="Comment">#  012345678901234567890123456789</span>
   <span class="Constant"> .8 | r n b q k b n r           .</span>
   <span class="Constant"> .7 | p p p p p p p p           .</span>
   <span class="Constant"> .6 |                           .</span>
   <span class="Constant"> .5 |                           .</span>
   <span class="Constant"> .4 |             P             .</span>
   <span class="Constant"> .3 |                           .</span>
   <span class="Constant"> .2 | P P P P P P   P           .</span>
   <span class="Constant"> .1 | R N B Q K B N R           .</span>
   <span class="Constant"> .  +----------------           .</span>
   <span class="Constant"> .    a b c d e f g h           .</span>
   <span class="Constant"> .                              .</span>
  ]
]
</pre>
</body>
</html>