improved indentation and whitespace for markdown code blocks
All code blocks in markdown have been intended by at least 4 spaces. We add `--tab-stop=8` to all `pandoc(1)` executions in order to set a better tab stop indentation, especially for tab intended code blocks. Changed `bin/pandoc-wrapper.sh` VERSION from "1.5.3 2024-03-26" to "1.6 2024-03-31". Fixed `1991/brnstnd/sorta.README.md` so that the sorta code is code blocks. Removed unneeded paragraph group in copyright in `inc/footer.default.html`. Fixed excess whitespace after list Author on entry `index.html` page. Changed `bin/output-index-author.sh` VERSION from "1.5.2 2024-03-26" to "1.6 2024-03-31". Performed `make www` to perform the above and test under macOS. TODO: Fix the problem of the initial line of code being extra intended. TODO: Fix excess whitespace around code that is inline.
This commit is contained in:
1 parent
b84c27ce02
commit
a996f8d2b8
734 files changed
+16723
-16963
No files matched your search
+74
-74
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
NOTE: there is an alternate version for vi(m) like movements. See [alternate
|
||||
@@ -9,7 +9,7 @@ version](#alternate-code) below. If your terminal has problems with the
|
||||
`stty(1)` commands try:
|
||||
|
||||
```sh
|
||||
make anon-no_stty
|
||||
make anon-no_stty
|
||||
```
|
||||
|
||||
This will compile [anon.c](anon.c) as `anon` to not use `stty(1)`.
|
||||
@@ -20,7 +20,7 @@ This will compile [anon.c](anon.c) as `anon` to not use `stty(1)`.
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2005 anon bugs](../../bugs.html#2005_anon).
|
||||
@@ -29,16 +29,16 @@ For more detailed information see [2005 anon bugs](../../bugs.html#2005_anon).
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./anon x y [z]
|
||||
./anon x y [z]
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./anon 4 4
|
||||
./anon 4 4
|
||||
|
||||
./anon 3 3 3
|
||||
./anon 3 3 3
|
||||
```
|
||||
|
||||
After a very large number of moves this program will deliberately force itself
|
||||
@@ -49,13 +49,13 @@ hook you) and spending too much time playing. :-)
|
||||
If you want to see this in action you can easily do this:
|
||||
|
||||
```sh
|
||||
yes 'please crash on me :-)' | ./anon 4 4
|
||||
yes 'please crash on me :-)' | ./anon 4 4
|
||||
```
|
||||
|
||||
What happens if you specify a larger board? For instance:
|
||||
|
||||
```sh
|
||||
yes 'please crash on me :-)' | ./anon 10 10 10
|
||||
yes 'please crash on me :-)' | ./anon 10 10 10
|
||||
```
|
||||
|
||||
If you specify more than three args the program might also crash or do
|
||||
@@ -71,13 +71,13 @@ The alternate version uses `vi(m)` like movement keys.
|
||||
### Alternate build:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
To compile the version without `stty(1)`:
|
||||
|
||||
```sh
|
||||
make alt-no_stty
|
||||
make alt-no_stty
|
||||
```
|
||||
|
||||
|
||||
@@ -86,12 +86,12 @@ make alt-no_stty
|
||||
Use `anon.alt` as you would `anon` with the change in movements:
|
||||
|
||||
```
|
||||
k | Move empty spot up
|
||||
h | Move empty spot left
|
||||
j | Move empty spot down
|
||||
l | Move empty spot right
|
||||
J | Move empty spot forwards
|
||||
K | Move empty spot backwards
|
||||
k | Move empty spot up
|
||||
h | Move empty spot left
|
||||
j | Move empty spot down
|
||||
l | Move empty spot right
|
||||
J | Move empty spot forwards
|
||||
K | Move empty spot backwards
|
||||
```
|
||||
|
||||
|
||||
@@ -122,13 +122,13 @@ The program takes 2 or 3 arguments, specifying the dimensions of the board.
|
||||
For example, to play the original version of the Fifteen Puzzle:
|
||||
|
||||
```sh
|
||||
./anon 4 4
|
||||
./anon 4 4
|
||||
```
|
||||
|
||||
To play with a 3D board, do something like this:
|
||||
|
||||
```sh
|
||||
./anon 3 3 3
|
||||
./anon 3 3 3
|
||||
```
|
||||
|
||||
**WARNING: do NOT run the program with more than 3 command-line arguments.
|
||||
@@ -145,18 +145,18 @@ characters instead of digits. To slide the tiles around, use the following
|
||||
keys:
|
||||
|
||||
```
|
||||
i | Slide the tile above the current empty space downwards.
|
||||
j | Slide the tile to the left of the current empty space to the right.
|
||||
k | Slide the tile below the current empty space upwards.
|
||||
l | Slide the tile to the right of the current empty space to the left.
|
||||
o | Slide the tile behind the current empty space forwards.
|
||||
n | Slide the tile in front of the current empty space backwards.
|
||||
i | Slide the tile above the current empty space downwards.
|
||||
j | Slide the tile to the left of the current empty space to the right.
|
||||
k | Slide the tile below the current empty space upwards.
|
||||
l | Slide the tile to the right of the current empty space to the left.
|
||||
o | Slide the tile behind the current empty space forwards.
|
||||
n | Slide the tile in front of the current empty space backwards.
|
||||
```
|
||||
|
||||
To quit the game:
|
||||
|
||||
```
|
||||
q | Quit the game.
|
||||
q | Quit the game.
|
||||
```
|
||||
|
||||
Note that, for example, sliding the tile above the current empty spot
|
||||
@@ -165,12 +165,12 @@ the current empty spot was. Hence, you could think of the movement keys in
|
||||
terms of how they effectively "move" the empty spot:
|
||||
|
||||
```
|
||||
i | Move empty spot up
|
||||
j | Move empty spot left
|
||||
k | Move empty spot down
|
||||
l | Move empty spot right
|
||||
n | Move empty spot forwards
|
||||
o | Move empty spot backwards
|
||||
i | Move empty spot up
|
||||
j | Move empty spot left
|
||||
k | Move empty spot down
|
||||
l | Move empty spot right
|
||||
n | Move empty spot forwards
|
||||
o | Move empty spot backwards
|
||||
```
|
||||
|
||||
**NOTE:** as a measure of alleviating counter-productivity due to addiction to
|
||||
@@ -378,7 +378,7 @@ stored in a well-known location in the `MASS`.
|
||||
`if(p,q,r,s)` is, in fact, an `if` statement. :-) It is equivalent to:
|
||||
|
||||
```c
|
||||
if (p) { q; r } else {s}
|
||||
if (p) { q; r } else {s}
|
||||
```
|
||||
|
||||
Why are `q` and `r` split up? Because it's cleaner (in whatever twisted sense of
|
||||
@@ -405,18 +405,18 @@ variable); `x` and `y-1` define the starting and ending values of `i`, and `z`
|
||||
is the loop body. `Z` is the post-loop code in the current state. For example:
|
||||
|
||||
```c
|
||||
for(s,i, 0, 10,
|
||||
some_code ,
|
||||
other_code)
|
||||
for(s,i, 0, 10,
|
||||
some_code ,
|
||||
other_code)
|
||||
```
|
||||
|
||||
is equivalent to:
|
||||
|
||||
```c
|
||||
for (i=0; i<10; i++) {
|
||||
some_code;
|
||||
}
|
||||
other_code;
|
||||
for (i=0; i<10; i++) {
|
||||
some_code;
|
||||
}
|
||||
other_code;
|
||||
```
|
||||
|
||||
Note the "wrong" indentation in the former: the author prefers to write it
|
||||
@@ -444,25 +444,25 @@ program, and what the various state numbers are meant to do:
|
||||
#### MASS usage map
|
||||
|
||||
```
|
||||
0 | Function return value
|
||||
1 | Function argument 1
|
||||
2 | Function argument 2
|
||||
3 | Function argument 3
|
||||
4 | Scratch register 1
|
||||
5 | Scratch register 2
|
||||
6 | Scratch register 3
|
||||
7 | Scratch register 4
|
||||
8 | Value of original argv :-)
|
||||
9 | Value of original argc :-)
|
||||
11 | Zero register (always set to 0)
|
||||
12 | Width of board
|
||||
13 | Length of board
|
||||
14 | Height of board
|
||||
15 | Current position of hole
|
||||
16 | Random seed for rand_r(3)
|
||||
18 | Scratch register used by state 18 :-)
|
||||
31 | field width for printing tiles
|
||||
32 | Start of board data
|
||||
0 | Function return value
|
||||
1 | Function argument 1
|
||||
2 | Function argument 2
|
||||
3 | Function argument 3
|
||||
4 | Scratch register 1
|
||||
5 | Scratch register 2
|
||||
6 | Scratch register 3
|
||||
7 | Scratch register 4
|
||||
8 | Value of original argv :-)
|
||||
9 | Value of original argc :-)
|
||||
11 | Zero register (always set to 0)
|
||||
12 | Width of board
|
||||
13 | Length of board
|
||||
14 | Height of board
|
||||
15 | Current position of hole
|
||||
16 | Random seed for rand_r(3)
|
||||
18 | Scratch register used by state 18 :-)
|
||||
31 | field width for printing tiles
|
||||
32 | Start of board data
|
||||
```
|
||||
|
||||
(**CAVEAT:** not all of these mappings ended up in the final version of the
|
||||
@@ -478,22 +478,22 @@ to be on all tested architectures.)
|
||||
#### State number assignments
|
||||
|
||||
```
|
||||
1 | showhelp
|
||||
2 | showhelp
|
||||
3 | is 2D: start init
|
||||
4 | is 3D: start init
|
||||
5 | find allocation type
|
||||
6 | MASS init, bottom-up
|
||||
7 | MASS init, top-down
|
||||
8 | main program
|
||||
9 | generate() outer loop
|
||||
13 | render()
|
||||
14 | render() loop
|
||||
15 | exit(0)
|
||||
16 | pick a tile that hasn't occurred yet
|
||||
17 | inner loop of 16.
|
||||
18 | main loop
|
||||
19 | checkwin() loop
|
||||
1 | showhelp
|
||||
2 | showhelp
|
||||
3 | is 2D: start init
|
||||
4 | is 3D: start init
|
||||
5 | find allocation type
|
||||
6 | MASS init, bottom-up
|
||||
7 | MASS init, top-down
|
||||
8 | main program
|
||||
9 | generate() outer loop
|
||||
13 | render()
|
||||
14 | render() loop
|
||||
15 | exit(0)
|
||||
16 | pick a tile that hasn't occurred yet
|
||||
17 | inner loop of 16.
|
||||
18 | main loop
|
||||
19 | checkwin() loop
|
||||
```
|
||||
|
||||
Note that some of the manually-implemented states (those not implemented by
|
||||
|
||||
+75
-76
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Anonymous_2005">Anonymous 2005</a><br>
|
||||
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,47 +141,47 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<p>NOTE: there is an alternate version for vi(m) like movements. See <a href="#alternate-code">alternate
|
||||
version</a> below. If your terminal has problems with the
|
||||
<code>stty(1)</code> commands try:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> anon-no_stty</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> anon-no_stty</span></code></pre></div>
|
||||
<p>This will compile <a href="anon.c">anon.c</a> as <code>anon</code> to not use <code>stty(1)</code>.</p>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#2005_anon">2005 anon bugs</a>.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./anon</span> x y <span class="pp">[</span><span class="ss">z</span><span class="pp">]</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./anon</span> x y <span class="pp">[</span><span class="ss">z</span><span class="pp">]</span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./anon</span> 4 4</span>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./anon</span> 4 4</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./anon</span> 3 3 3</span></code></pre></div>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./anon</span> 3 3 3</span></code></pre></div>
|
||||
<p>After a very large number of moves this program will deliberately force itself
|
||||
to destroy its runtime stack. This is the author’s way to prevent you from being
|
||||
frustrated (which might happen as it likes to create unsolvable puzzles just to
|
||||
hook you) and spending too much time playing. :-)</p>
|
||||
<p>If you want to see this in action you can easily do this:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">yes</span> <span class="st">'please crash on me :-)'</span> <span class="kw">|</span> <span class="ex">./anon</span> 4 4</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">yes</span> <span class="st">'please crash on me :-)'</span> <span class="kw">|</span> <span class="ex">./anon</span> 4 4</span></code></pre></div>
|
||||
<p>What happens if you specify a larger board? For instance:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="fu">yes</span> <span class="st">'please crash on me :-)'</span> <span class="kw">|</span> <span class="ex">./anon</span> 10 10 10</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">yes</span> <span class="st">'please crash on me :-)'</span> <span class="kw">|</span> <span class="ex">./anon</span> 10 10 10</span></code></pre></div>
|
||||
<p>If you specify more than three args the program might also crash or do
|
||||
something strange. This might also happen if you specify excessively large board
|
||||
dimensions. Try <code>100 100 100</code> for instance and see what happens!</p>
|
||||
<h2 id="alternate-version">Alternate version:</h2>
|
||||
<p>The alternate version uses <code>vi(m)</code> like movement keys.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> alt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
|
||||
<p>To compile the version without <code>stty(1)</code>:</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> alt-no_stty</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt-no_stty</span></code></pre></div>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>anon.alt</code> as you would <code>anon</code> with the change in movements:</p>
|
||||
<pre><code>k | Move empty spot up
|
||||
h | Move empty spot left
|
||||
j | Move empty spot down
|
||||
l | Move empty spot right
|
||||
J | Move empty spot forwards
|
||||
K | Move empty spot backwards</code></pre>
|
||||
<pre><code> k | Move empty spot up
|
||||
h | Move empty spot left
|
||||
j | Move empty spot down
|
||||
l | Move empty spot right
|
||||
J | Move empty spot forwards
|
||||
K | Move empty spot backwards</code></pre>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>Taking the 4x4 board with 15 tiles to a whole new level, this entry takes this
|
||||
puzzle to a whole new dimension! While you puzzle out this puzzle, we invite
|
||||
@@ -201,9 +200,9 @@ spaces on the board, and the goal is to rearrange them so that they appear
|
||||
sorted in the order they appear on the screen.</p>
|
||||
<p>The program takes 2 or 3 arguments, specifying the dimensions of the board.
|
||||
For example, to play the original version of the Fifteen Puzzle:</p>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./anon</span> 4 4</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./anon</span> 4 4</span></code></pre></div>
|
||||
<p>To play with a 3D board, do something like this:</p>
|
||||
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./anon</span> 3 3 3</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./anon</span> 3 3 3</span></code></pre></div>
|
||||
<p><strong>WARNING: do NOT run the program with more than 3 command-line arguments.
|
||||
This will trigger a bug that will cause it to crash or do something strange.
|
||||
:-)</strong></p>
|
||||
@@ -214,24 +213,24 @@ dimensions. :-) (10x10x10 is considered a safe upper limit.)</p>
|
||||
<p>The empty space on the board is represented by a space filled with <code>#</code>
|
||||
characters instead of digits. To slide the tiles around, use the following
|
||||
keys:</p>
|
||||
<pre><code>i | Slide the tile above the current empty space downwards.
|
||||
j | Slide the tile to the left of the current empty space to the right.
|
||||
k | Slide the tile below the current empty space upwards.
|
||||
l | Slide the tile to the right of the current empty space to the left.
|
||||
o | Slide the tile behind the current empty space forwards.
|
||||
n | Slide the tile in front of the current empty space backwards.</code></pre>
|
||||
<pre><code> i | Slide the tile above the current empty space downwards.
|
||||
j | Slide the tile to the left of the current empty space to the right.
|
||||
k | Slide the tile below the current empty space upwards.
|
||||
l | Slide the tile to the right of the current empty space to the left.
|
||||
o | Slide the tile behind the current empty space forwards.
|
||||
n | Slide the tile in front of the current empty space backwards.</code></pre>
|
||||
<p>To quit the game:</p>
|
||||
<pre><code>q | Quit the game.</code></pre>
|
||||
<pre><code> q | Quit the game.</code></pre>
|
||||
<p>Note that, for example, sliding the tile above the current empty spot
|
||||
downwards will fill up the empty spot, and create a new empty spot above where
|
||||
the current empty spot was. Hence, you could think of the movement keys in
|
||||
terms of how they effectively “move” the empty spot:</p>
|
||||
<pre><code>i | Move empty spot up
|
||||
j | Move empty spot left
|
||||
k | Move empty spot down
|
||||
l | Move empty spot right
|
||||
n | Move empty spot forwards
|
||||
o | Move empty spot backwards</code></pre>
|
||||
<pre><code> i | Move empty spot up
|
||||
j | Move empty spot left
|
||||
k | Move empty spot down
|
||||
l | Move empty spot right
|
||||
n | Move empty spot forwards
|
||||
o | Move empty spot backwards</code></pre>
|
||||
<p><strong>NOTE:</strong> as a measure of alleviating counter-productivity due to addiction to
|
||||
this game, particularly for those hardcore gamers who insist on solving a
|
||||
10x10x10 puzzle during work hours, and also to give an upper bound to user
|
||||
@@ -395,7 +394,7 @@ allocation. It’s the only state that needs to return a value from the boolean
|
||||
expression, since once the <code>MASS</code> is initialized any return value can simply be
|
||||
stored in a well-known location in the <code>MASS</code>.</p>
|
||||
<p><code>if(p,q,r,s)</code> is, in fact, an <code>if</code> statement. :-) It is equivalent to:</p>
|
||||
<div class="sourceCode" id="cb16"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> <span class="op">(</span>p<span class="op">)</span> <span class="op">{</span> q<span class="op">;</span> r <span class="op">}</span> <span class="cf">else</span> <span class="op">{</span>s<span class="op">}</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb16"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>p<span class="op">)</span> <span class="op">{</span> q<span class="op">;</span> r <span class="op">}</span> <span class="cf">else</span> <span class="op">{</span>s<span class="op">}</span></span></code></pre></div>
|
||||
<p>Why are <code>q</code> and <code>r</code> split up? Because it’s cleaner (in whatever twisted sense of
|
||||
the word that can be applied to an IOCCC entry) to implement using boolean
|
||||
expressions. Keep in mind that all statements are assumed to evaluate to
|
||||
@@ -416,14 +415,14 @@ closes the current state and opens a new one behind the programmer’s back.
|
||||
<code>i</code> is the index variable (well, the index into the <code>MASS</code> of the index
|
||||
variable); <code>x</code> and <code>y-1</code> define the starting and ending values of <code>i</code>, and <code>z</code>
|
||||
is the loop body. <code>Z</code> is the post-loop code in the current state. For example:</p>
|
||||
<div class="sourceCode" id="cb17"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span><span class="op">(</span>s<span class="op">,</span>i<span class="op">,</span> <span class="dv">0</span><span class="op">,</span> <span class="dv">10</span><span class="op">,</span></span>
|
||||
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a>some_code <span class="op">,</span></span>
|
||||
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a>other_code<span class="op">)</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb17"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span><span class="op">(</span>s<span class="op">,</span>i<span class="op">,</span> <span class="dv">0</span><span class="op">,</span> <span class="dv">10</span><span class="op">,</span></span>
|
||||
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a> some_code <span class="op">,</span></span>
|
||||
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a> other_code<span class="op">)</span></span></code></pre></div>
|
||||
<p>is equivalent to:</p>
|
||||
<div class="sourceCode" id="cb18"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> <span class="op">(</span>i<span class="op">=</span><span class="dv">0</span><span class="op">;</span> i<span class="op">&</span>lt<span class="op">;</span><span class="dv">10</span><span class="op">;</span> i<span class="op">++)</span> <span class="op">{</span></span>
|
||||
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a> some_code<span class="op">;</span></span>
|
||||
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
|
||||
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a>other_code<span class="op">;</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb18"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> <span class="op">(</span>i<span class="op">=</span><span class="dv">0</span><span class="op">;</span> i<span class="op">&</span>lt<span class="op">;</span><span class="dv">10</span><span class="op">;</span> i<span class="op">++)</span> <span class="op">{</span></span>
|
||||
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a> some_code<span class="op">;</span></span>
|
||||
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
|
||||
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a> other_code<span class="op">;</span></span></code></pre></div>
|
||||
<p>Note the “wrong” indentation in the former: the author prefers to write it
|
||||
that way, since the analogy to the usual <code>for</code> loop is clearer. This is why it’s
|
||||
easier to understand the pre-CPP code, since after CPP, the macro reshuffles
|
||||
@@ -444,25 +443,25 @@ key press. What could be more fun than to define such a case in terms of a
|
||||
are the mappings of various locations of the <code>MASS</code> to their usage in the
|
||||
program, and what the various state numbers are meant to do:</p>
|
||||
<h4 id="mass-usage-map">MASS usage map</h4>
|
||||
<pre><code>0 | Function return value
|
||||
1 | Function argument 1
|
||||
2 | Function argument 2
|
||||
3 | Function argument 3
|
||||
4 | Scratch register 1
|
||||
5 | Scratch register 2
|
||||
6 | Scratch register 3
|
||||
7 | Scratch register 4
|
||||
8 | Value of original argv :-)
|
||||
9 | Value of original argc :-)
|
||||
11 | Zero register (always set to 0)
|
||||
12 | Width of board
|
||||
13 | Length of board
|
||||
14 | Height of board
|
||||
15 | Current position of hole
|
||||
16 | Random seed for rand_r(3)
|
||||
18 | Scratch register used by state 18 :-)
|
||||
31 | field width for printing tiles
|
||||
32 | Start of board data</code></pre>
|
||||
<pre><code> 0 | Function return value
|
||||
1 | Function argument 1
|
||||
2 | Function argument 2
|
||||
3 | Function argument 3
|
||||
4 | Scratch register 1
|
||||
5 | Scratch register 2
|
||||
6 | Scratch register 3
|
||||
7 | Scratch register 4
|
||||
8 | Value of original argv :-)
|
||||
9 | Value of original argc :-)
|
||||
11 | Zero register (always set to 0)
|
||||
12 | Width of board
|
||||
13 | Length of board
|
||||
14 | Height of board
|
||||
15 | Current position of hole
|
||||
16 | Random seed for rand_r(3)
|
||||
18 | Scratch register used by state 18 :-)
|
||||
31 | field width for printing tiles
|
||||
32 | Start of board data</code></pre>
|
||||
<p>(<strong>CAVEAT:</strong> not all of these mappings ended up in the final version of the
|
||||
program, mainly due to size limitations which entailed the trimming off of a
|
||||
lot of neat features in the game. It is left as an exercise for the reader to
|
||||
@@ -472,22 +471,22 @@ the <code>MASS</code>, because otherwise they may overwrite their original value
|
||||
memory allocation code saves them. Index 8 is deemed “safe enough”. (It seems
|
||||
to be on all tested architectures.)</p>
|
||||
<h4 id="state-number-assignments">State number assignments</h4>
|
||||
<pre><code>1 | showhelp
|
||||
2 | showhelp
|
||||
3 | is 2D: start init
|
||||
4 | is 3D: start init
|
||||
5 | find allocation type
|
||||
6 | MASS init, bottom-up
|
||||
7 | MASS init, top-down
|
||||
8 | main program
|
||||
9 | generate() outer loop
|
||||
13 | render()
|
||||
14 | render() loop
|
||||
15 | exit(0)
|
||||
16 | pick a tile that hasn't occurred yet
|
||||
17 | inner loop of 16.
|
||||
18 | main loop
|
||||
19 | checkwin() loop</code></pre>
|
||||
<pre><code> 1 | showhelp
|
||||
2 | showhelp
|
||||
3 | is 2D: start init
|
||||
4 | is 3D: start init
|
||||
5 | find allocation type
|
||||
6 | MASS init, bottom-up
|
||||
7 | MASS init, top-down
|
||||
8 | main program
|
||||
9 | generate() outer loop
|
||||
13 | render()
|
||||
14 | render() loop
|
||||
15 | exit(0)
|
||||
16 | pick a tile that hasn't occurred yet
|
||||
17 | inner loop of 16.
|
||||
18 | main loop
|
||||
19 | checkwin() loop</code></pre>
|
||||
<p>Note that some of the manually-implemented states (those not implemented by
|
||||
<code>do()</code>) respond to multiple state numbers. Also note that states 1-4
|
||||
conveniently correspond to what the program should do when 1-4 arguments are
|
||||
|
||||
Reference in new issue
Block a user