set pandoc 8 character tab stops for HTML conversion
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 "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`. Performed `make www` to perform the above and test under macOS.
This commit is contained in:
1 parent
7141a1b808
commit
b84c27ce02
402 files changed
+2414
-2396
No files matched your search
@@ -191,11 +191,11 @@ the proper function (and/or cast to the right type).</p>
|
||||
|
||||
You are free to share and adapt this file under the terms of this license:
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
|
||||
For more information, see:
|
||||
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
-->
|
||||
|
||||
@@ -232,7 +232,7 @@ the proper function (and/or cast to the right type).</p>
|
||||
<div class="footer">
|
||||
<h2>Copyright and CC BY-SA 4.0 License</h2>
|
||||
<p>This file and web page is:</p>
|
||||
<blockquote><p><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></p></blockquote>
|
||||
<blockquote><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></blockquote>
|
||||
<p>You are free to share and adapt this file under the terms of this license:</p>
|
||||
<blockquote><b>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</b></blockquote>
|
||||
<p>For more information, see:</p>
|
||||
|
||||
+21
-17
@@ -146,8 +146,10 @@ snake’s syllabary) for all snake and herpetologist programmers alike.</p>
|
||||
<ul>
|
||||
<li><p>Modifications</p>
|
||||
<ul>
|
||||
<li>Modifying the colours</li>
|
||||
<li>Modifying the colours
|
||||
<ul>
|
||||
<li>Background colour</li>
|
||||
</ul></li>
|
||||
<li>Modifying the characters for the wall, bug and snake</li>
|
||||
<li>Modifying input keys</li>
|
||||
<li>Modifying the status/score line</li>
|
||||
@@ -157,8 +159,10 @@ snake’s syllabary) for all snake and herpetologist programmers alike.</p>
|
||||
<ul>
|
||||
<li>Health (and/or Lives)</li>
|
||||
<li>Saving the game</li>
|
||||
<li>Different types of walls</li>
|
||||
<li>Different types of walls
|
||||
<ul>
|
||||
<li>Blockades</li>
|
||||
</ul></li>
|
||||
<li>Diagonal movement</li>
|
||||
<li>Special abilities</li>
|
||||
<li>Obstacles</li>
|
||||
@@ -279,27 +283,27 @@ not wanting to mess with anything that’s unnecessary):</p>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#define J Z</span><span class="op">(</span><span class="pp">SIZE</span><span class="op">:</span><span class="pp"> </span><span class="op">%</span><span class="pp">zu BUGS</span><span class="op">:</span><span class="pp"> </span><span class="op">%</span><span class="pp">zu\n</span><span class="op">),</span><span class="pp"> A</span><span class="op">,</span><span class="pp"> c</span><span class="op">);</span></span></code></pre></div>
|
||||
<p>More generally the following expressions and data types (with format specifiers)
|
||||
come to mind as information that might be of interest.</p>
|
||||
<pre><code> DESCRIPTION EXPRESSION TYPE FORMAT SPECIFIER
|
||||
<pre><code> DESCRIPTION EXPRESSION TYPE FORMAT SPECIFIER
|
||||
|
||||
Snake size A size_t %zu
|
||||
Snake size A size_t %zu
|
||||
|
||||
Y coordinate Y int %d
|
||||
Y coordinate Y int %d
|
||||
of snake head
|
||||
|
||||
X coordinate X int %d
|
||||
X coordinate X int %d
|
||||
of snake head
|
||||
|
||||
Max snake size g size_t %zu
|
||||
Max snake size g size_t %zu
|
||||
|
||||
Bugs eaten c size_t %zu
|
||||
Bugs eaten c size_t %zu
|
||||
|
||||
Bug line (Y) *U int %d
|
||||
Bug line (Y) *U int %d
|
||||
|
||||
Bug column (X) *V int %d
|
||||
Bug column (X) *V int %d
|
||||
|
||||
Snake size A size_t %zu
|
||||
Snake size A size_t %zu
|
||||
|
||||
Growth size (per N size_t %zu
|
||||
Growth size (per N size_t %zu
|
||||
bug)</code></pre>
|
||||
<h2 id="make-it-so-the-snake-starts-at-a-random-location">Make it so the snake starts at a random location</h2>
|
||||
<p>Quite simply change:</p>
|
||||
@@ -406,9 +410,9 @@ coordinates. This of course is very different now but the idea remains the same:
|
||||
<div class="sourceCode" id="cb14"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb14-1"><a href="#cb14-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>O<span class="op">>=</span>O<span class="op">[</span><span class="dv">1</span><span class="op">]||</span>H<span class="op">>=</span>M<span class="op">(</span><span class="dv">1</span><span class="op">)))</span></span>
|
||||
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
|
||||
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>X<span class="op"><</span><span class="dv">1</span><span class="op">||</span>X<span class="op">>=</span>H<span class="op">)</span></span>
|
||||
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a> X <span class="op">=</span> X<span class="op"><</span><span class="dv">1</span><span class="op">?</span>H<span class="op">-</span><span class="dv">1</span><span class="op">:</span><span class="dv">1</span><span class="op">;</span></span>
|
||||
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a> X <span class="op">=</span> X<span class="op"><</span><span class="dv">1</span><span class="op">?</span>H<span class="op">-</span><span class="dv">1</span><span class="op">:</span><span class="dv">1</span><span class="op">;</span></span>
|
||||
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>Y<span class="op"><</span><span class="dv">2</span><span class="op">||</span>Y<span class="op">>=*</span>O<span class="op">)</span></span>
|
||||
<span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a> Y <span class="op">=</span> Y<span class="op"><</span><span class="dv">2</span><span class="op">?*</span>O<span class="op">-</span><span class="dv">1</span><span class="op">:</span><span class="dv">2</span><span class="op">;</span></span>
|
||||
<span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a> Y <span class="op">=</span> Y<span class="op"><</span><span class="dv">2</span><span class="op">?*</span>O<span class="op">-</span><span class="dv">1</span><span class="op">:</span><span class="dv">2</span><span class="op">;</span></span>
|
||||
<span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
|
||||
<p>You can ignore the first if if you like; I’m not going to explain that part. The
|
||||
inner if statements however are testing if the new snake coordinates are beyond
|
||||
@@ -501,11 +505,11 @@ no default limit on max moves.</p>
|
||||
|
||||
You are free to share and adapt this file under the terms of this license:
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
|
||||
For more information, see:
|
||||
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
-->
|
||||
|
||||
@@ -542,7 +546,7 @@ no default limit on max moves.</p>
|
||||
<div class="footer">
|
||||
<h2>Copyright and CC BY-SA 4.0 License</h2>
|
||||
<p>This file and web page is:</p>
|
||||
<blockquote><p><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></p></blockquote>
|
||||
<blockquote><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></blockquote>
|
||||
<p>You are free to share and adapt this file under the terms of this license:</p>
|
||||
<blockquote><b>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</b></blockquote>
|
||||
<p>For more information, see:</p>
|
||||
|
||||
@@ -232,8 +232,8 @@ me and I figured I better note it.</p>
|
||||
second pointing to where it happens and the third being what’s left after the
|
||||
rest of the snake has gone through). Doing <code>SHED=100 SHEDS=-1</code>:</p>
|
||||
<pre><code>ooooooooo>ooo>
|
||||
^
|
||||
></code></pre>
|
||||
^
|
||||
></code></pre>
|
||||
<p>The <code>^</code> points to the part that’s split from the snake and which will be
|
||||
there on its own after the snake passes through it. Here’s an example with
|
||||
it being <code>SHEDS=-3</code>:</p>
|
||||
@@ -342,11 +342,11 @@ but it is very much appreciated and it means a great deal to me. Cheers.)</p>
|
||||
|
||||
You are free to share and adapt this file under the terms of this license:
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
|
||||
For more information, see:
|
||||
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
-->
|
||||
|
||||
@@ -383,7 +383,7 @@ but it is very much appreciated and it means a great deal to me. Cheers.)</p>
|
||||
<div class="footer">
|
||||
<h2>Copyright and CC BY-SA 4.0 License</h2>
|
||||
<p>This file and web page is:</p>
|
||||
<blockquote><p><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></p></blockquote>
|
||||
<blockquote><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></blockquote>
|
||||
<p>You are free to share and adapt this file under the terms of this license:</p>
|
||||
<blockquote><b>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</b></blockquote>
|
||||
<p>For more information, see:</p>
|
||||
|
||||
@@ -309,11 +309,11 @@ hadn’t yet moved (that is it was still growing):</p>
|
||||
|
||||
You are free to share and adapt this file under the terms of this license:
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
|
||||
For more information, see:
|
||||
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
-->
|
||||
|
||||
@@ -350,7 +350,7 @@ hadn’t yet moved (that is it was still growing):</p>
|
||||
<div class="footer">
|
||||
<h2>Copyright and CC BY-SA 4.0 License</h2>
|
||||
<p>This file and web page is:</p>
|
||||
<blockquote><p><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></p></blockquote>
|
||||
<blockquote><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></blockquote>
|
||||
<p>You are free to share and adapt this file under the terms of this license:</p>
|
||||
<blockquote><b>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</b></blockquote>
|
||||
<p>For more information, see:</p>
|
||||
|
||||
@@ -279,11 +279,11 @@ thick BUT not too thick. <strong>Make <em>SURE</em> ICING DOES <em>NOT</em> GET
|
||||
|
||||
You are free to share and adapt this file under the terms of this license:
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
|
||||
For more information, see:
|
||||
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
-->
|
||||
|
||||
@@ -320,7 +320,7 @@ thick BUT not too thick. <strong>Make <em>SURE</em> ICING DOES <em>NOT</em> GET
|
||||
<div class="footer">
|
||||
<h2>Copyright and CC BY-SA 4.0 License</h2>
|
||||
<p>This file and web page is:</p>
|
||||
<blockquote><p><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></p></blockquote>
|
||||
<blockquote><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></blockquote>
|
||||
<p>You are free to share and adapt this file under the terms of this license:</p>
|
||||
<blockquote><b>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</b></blockquote>
|
||||
<p>For more information, see:</p>
|
||||
|
||||
@@ -226,11 +226,11 @@ could safely go through that part of the screen.</p>
|
||||
|
||||
You are free to share and adapt this file under the terms of this license:
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
|
||||
For more information, see:
|
||||
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
-->
|
||||
|
||||
@@ -267,7 +267,7 @@ could safely go through that part of the screen.</p>
|
||||
<div class="footer">
|
||||
<h2>Copyright and CC BY-SA 4.0 License</h2>
|
||||
<p>This file and web page is:</p>
|
||||
<blockquote><p><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></p></blockquote>
|
||||
<blockquote><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></blockquote>
|
||||
<p>You are free to share and adapt this file under the terms of this license:</p>
|
||||
<blockquote><b>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</b></blockquote>
|
||||
<p>For more information, see:</p>
|
||||
|
||||
@@ -522,11 +522,11 @@ could also set the max size to be the highest possible by saying</p>
|
||||
perfect: the snake after all does not leave gaps and the game does not support
|
||||
diagonal movement and I also made a mistake and had to modify what I was aiming
|
||||
for. But you can consider this mode drawing or practice mode.</p>
|
||||
<pre><code> oooooooooo ooooo o oo ooooo
|
||||
o o oo o oo o ooo o
|
||||
oooo o oo ooooooo oooo ooooo
|
||||
o o ooo oo o ooo o
|
||||
oooo o oo ooo oooooooo></code></pre>
|
||||
<pre><code> oooooooooo ooooo o oo ooooo
|
||||
o o oo o oo o ooo o
|
||||
oooo o oo ooooooo oooo ooooo
|
||||
o o ooo oo o ooo o
|
||||
oooo o oo ooo oooooooo></code></pre>
|
||||
<h2 id="gameplay-mode-computer-playing-automatic-mode-photosensitive-epilepsystimulation-overload-trigger"><a name="auto" href="#toc">Gameplay mode: Computer playing / Automatic mode (Photosensitive epilepsy/Stimulation overload trigger)</a></h2>
|
||||
<p><strong>Photosensitive epilepsy/stimulation overload trigger warning:</strong>
|
||||
For those who have epilepsy or are susceptible to stimulation overload from
|
||||
@@ -713,11 +713,11 @@ years ago but I know it’s true now. <strong>Believe in yourself. Always.</stro
|
||||
|
||||
You are free to share and adapt this file under the terms of this license:
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
|
||||
For more information, see:
|
||||
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
-->
|
||||
|
||||
@@ -754,7 +754,7 @@ years ago but I know it’s true now. <strong>Believe in yourself. Always.</stro
|
||||
<div class="footer">
|
||||
<h2>Copyright and CC BY-SA 4.0 License</h2>
|
||||
<p>This file and web page is:</p>
|
||||
<blockquote><p><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></p></blockquote>
|
||||
<blockquote><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></blockquote>
|
||||
<p>You are free to share and adapt this file under the terms of this license:</p>
|
||||
<blockquote><b>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</b></blockquote>
|
||||
<p>For more information, see:</p>
|
||||
|
||||
@@ -603,11 +603,11 @@ email but I’m more likely to respond to mastodon messages.</p>
|
||||
|
||||
You are free to share and adapt this file under the terms of this license:
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
|
||||
For more information, see:
|
||||
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
-->
|
||||
|
||||
@@ -700,7 +700,7 @@ email but I’m more likely to respond to mastodon messages.</p>
|
||||
<div class="footer">
|
||||
<h2>Copyright and CC BY-SA 4.0 License</h2>
|
||||
<p>This file and web page is:</p>
|
||||
<blockquote><p><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></p></blockquote>
|
||||
<blockquote><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></blockquote>
|
||||
<p>You are free to share and adapt this file under the terms of this license:</p>
|
||||
<blockquote><b>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</b></blockquote>
|
||||
<p>For more information, see:</p>
|
||||
|
||||
@@ -278,21 +278,21 @@ in real life increases in size like that so suddenly? :)</p>
|
||||
<li><p>I make use of the C token pasting operator. Although this is well known it’s
|
||||
probably less known and either way it’s not as simple as just having the code
|
||||
that it translates to. For example why have:</p>
|
||||
<pre><code> attroff(COLOR_PAIR(L));</code></pre>
|
||||
<pre><code> attroff(COLOR_PAIR(L));</code></pre>
|
||||
<p>When you can have instead:</p>
|
||||
<pre><code> attroff(m(PAIR(L)));</code></pre>
|
||||
<pre><code> attroff(m(PAIR(L)));</code></pre>
|
||||
<p>It’s an extra layer of indirection. This used to be more used but when
|
||||
making it easier for users to change the colour pairs I no longer used it to
|
||||
set up colour pairs. It might not defeat <code>cpp</code> but it does make for more
|
||||
reading otherwise (depending on how you look at it maybe less?).</p>
|
||||
<p>It also helps save iocccsize bytes (but not as many as it used to!).</p></li>
|
||||
<li><p>What is this block of code?</p>
|
||||
<pre><code> F(MAXSIZE)g d g = f((a)((*y-2)*(y[-2]-2)),g);
|
||||
F(GROW)N d
|
||||
F(SIZE)A d
|
||||
F(WAIT)y[-3] = (int) strtol(z,NULL,0));
|
||||
F(EVADE)W d
|
||||
/* and so on */</code></pre>
|
||||
<pre><code> F(MAXSIZE)g d g = f((a)((*y-2)*(y[-2]-2)),g);
|
||||
F(GROW)N d
|
||||
F(SIZE)A d
|
||||
F(WAIT)y[-3] = (int) strtol(z,NULL,0));
|
||||
F(EVADE)W d
|
||||
/* and so on */</code></pre>
|
||||
<p>There are several things going on here but I’ll focus on the main one here and
|
||||
leave the others to their own: the <code>F</code> macro and the associated <code>d</code> macro are
|
||||
here important.</p>
|
||||
@@ -303,7 +303,7 @@ the one that clearly shows strtol()).</p>
|
||||
<p>There are other things going on (below).</p>
|
||||
<p>Now it might not defeat the cpp but can you tell me what this is even with the
|
||||
cpp?</p>
|
||||
<pre><code> f((a)((*y-2)*(y[-2]-2)),g);</code></pre>
|
||||
<pre><code> f((a)((*y-2)*(y[-2]-2)),g);</code></pre>
|
||||
<p>The cpp might get it closer to what you might expect in a normal program but I
|
||||
refer to the array offsets (below also).</p></li>
|
||||
<li><p>Stringification: there isn’t a single <code>"</code> in the source code! The <code>F</code> macro
|
||||
@@ -313,7 +313,7 @@ made it use it instead. If I remember rightly that uses extra bytes but somehow
|
||||
it felt better this way in my head. Then to save many bytes I made the macro do
|
||||
much more than that (that is the <code>F</code> macro).</p>
|
||||
<p>As for the Z() macro it means that I could remove <code>"</code>s; for example:</p>
|
||||
<pre><code> #define J Z(X:%d/%d Y:%d/%d S:%zu/%zu B:%zu\n), Y, y[-2], X,*y,A,g, c);</code></pre>
|
||||
<pre><code> #define J Z(X:%d/%d Y:%d/%d S:%zu/%zu B:%zu\n), Y, y[-2], X,*y,A,g, c);</code></pre>
|
||||
<p>Which as I have discussed elsewhere is the entire set of parameters to both
|
||||
<code>mvprintw()</code> and <code>printf()</code> plus the end of the function call (i.e. <code>);</code>.</p>
|
||||
<p>BTW: There’s another really cool benefit of stringification: because more than
|
||||
@@ -321,7 +321,7 @@ one space is converted to a single space I can have it spread across columns on
|
||||
the format and even new lines if necessary. This fact along with the next
|
||||
technique causes some beautifiers problems too.</p></li>
|
||||
<li><p>Another use of the <code>Z</code> macro is this curious line:</p>
|
||||
<pre><code> static const char*s =Z( ; +<>^v);</code></pre>
|
||||
<pre><code> static const char*s =Z( ; +<>^v);</code></pre>
|
||||
<p>There are a number of curious parts. First is the Z() part makes it look
|
||||
like a function call. Of course that wouldn’t work as such because an array
|
||||
initialiser needs an initialiser list or a string literal. Whether that’s
|
||||
@@ -340,7 +340,7 @@ only one copy is needed. Why I have it in the function is to move it further
|
||||
away from the definition of <code>Z()</code>. I will also be returning to this one
|
||||
again.</p>
|
||||
<p>Another example is using the <code>E()</code> function e.g.:</p>
|
||||
<pre><code> E(Z(YOU WIN!));</code></pre>
|
||||
<pre><code> E(Z(YOU WIN!));</code></pre>
|
||||
<p>Which happens to be in the same function the above char array is defined. Also
|
||||
it’s more like a string than anything but yet it’s not visibly a string.</p>
|
||||
<p>Some beautifiers didn’t like this at all.</p></li>
|
||||
@@ -374,10 +374,10 @@ not the good kind!</p></li>
|
||||
<li><p>On the note of pausing there’s at least one instance of removing <code>if..else</code>
|
||||
(besides those in e.g. environmental variable processing) that’s curious: I
|
||||
converted this:</p>
|
||||
<pre><code> if (!P) P = 1;
|
||||
else P = 0;</code></pre>
|
||||
<pre><code> if (!P) P = 1;
|
||||
else P = 0;</code></pre>
|
||||
<p>To this:</p>
|
||||
<pre><code> (!P && (P = 1))||(P=0);</code></pre></li>
|
||||
<pre><code> (!P && (P = 1))||(P=0);</code></pre></li>
|
||||
<li><p>Makes use of the different namespaces to have variables and labels be the
|
||||
same identifier. For example in main() there’s a variable that also have the
|
||||
same name label for <code>goto</code> (there used to be two pairs in <code>main()</code>).</p></li>
|
||||
@@ -390,30 +390,30 @@ to then <code>goto x</code>? Do I need to check <code>Q</code> at all? In fact I
|
||||
it might be easy to miss.</p></li>
|
||||
<li><p>Uses an unnamed array (compound literal) for several different game variables.
|
||||
The pointer to the first element is defined like <code>int *j</code>:</p>
|
||||
<pre><code> static int Y,X,*j = (int[8]){231,0}, *U, *V, *e, *n, Q, P,x,*y,l=4,*D;</code></pre>
|
||||
<pre><code> static int Y,X,*j = (int[8]){231,0}, *U, *V, *e, *n, Q, P,x,*y,l=4,*D;</code></pre>
|
||||
<p>Does the 231 seem familiar? It should: it’s the default key delay for the
|
||||
<code>timeout()</code> call (which I will return to again). The rest are 0 default. But
|
||||
what about <code>j</code>? Is it even used? Actually in main:</p>
|
||||
<pre><code> y = j+3;</code></pre>
|
||||
<pre><code> y = j+3;</code></pre>
|
||||
<p>But aside from that <code>j</code> is not used. However…</p></li>
|
||||
<li><p>Major abuse of negative pointer offsets along with confusing names. I’ll say
|
||||
this in two parts: the negative offsets and then the confusing names.</p>
|
||||
<p>Can you honestly tell me that this is easy to follow?</p>
|
||||
<pre><code> if (Y < 1 || Y >= y[-2] || X < 2 || X >= *y || y[-2] >= y[-1] || *y >= 1[y])
|
||||
{
|
||||
if (*p && !(*y>=1[y]||y[-2]>=y[-1]))
|
||||
<pre><code> if (Y < 1 || Y >= y[-2] || X < 2 || X >= *y || y[-2] >= y[-1] || *y >= 1[y])
|
||||
{
|
||||
if (Y<1||Y>=y[-2])
|
||||
Y = Y<1?y[-2]-1:1;
|
||||
if (X<2||X>=*y)
|
||||
X = X<2?*y-1:2;
|
||||
}
|
||||
/* ... */
|
||||
}</code></pre>
|
||||
if (*p && !(*y>=1[y]||y[-2]>=y[-1]))
|
||||
{
|
||||
if (Y<1||Y>=y[-2])
|
||||
Y = Y<1?y[-2]-1:1;
|
||||
if (X<2||X>=*y)
|
||||
X = X<2?*y-1:2;
|
||||
}
|
||||
/* ... */
|
||||
}</code></pre>
|
||||
<p>That’s not the only place negative offsets occur! Observe the ternary operators
|
||||
there too.</p>
|
||||
<p>I’ll go back to the <code>F()</code> macro and in particular what follows one of them:</p>
|
||||
<pre><code> g d g = f((a)((*y-2)*(y[-2]-2)),g);</code></pre>
|
||||
<pre><code> g d g = f((a)((*y-2)*(y[-2]-2)),g);</code></pre>
|
||||
<p>To parse that at the very least you have to know that <code>y</code> points to <code>j + 3</code>.
|
||||
Then you have to know that <code>j</code> points to the first element of an unnamed
|
||||
array (compound literal). But then you also have to know that that array has
|
||||
@@ -422,17 +422,17 @@ then have to account for the offset that <code>y</code> is. Then once you have t
|
||||
figured out you need to consider the negative offsets to <code>y</code> (this also
|
||||
applies to the block above of course and maybe more so). Then you have to
|
||||
think of operator precedence etc. I mean what is:</p>
|
||||
<pre><code> (*y-2) * (y[-2]-2])</code></pre>
|
||||
<pre><code> (*y-2) * (y[-2]-2])</code></pre>
|
||||
<p>…about? An offset of <code>-2</code> and subtract <code>-2</code> from that. Multiply that by the <code>*y</code>
|
||||
(which is <code>j[3]</code>) <code>- 2</code>.</p>
|
||||
<p>But why is there a <code>g d g =</code> when the other lines only have the variable (or
|
||||
location) and a <code>d</code>? (Excepting the one that doesn’t refer to <code>d</code>.)</p></li>
|
||||
<li><p>On the confusing names etc.: the <code>getmaxyx()</code> function gets the maximum Y, X
|
||||
dimensions. Now in the first call in <code>main()</code> I have the code and tests following:</p>
|
||||
<pre><code> getmaxyx(v, *y, y[-2]);
|
||||
--*y; --y[-2];
|
||||
if (y[-2] < 9 || *y < 9)
|
||||
return E(Z(term too small));</code></pre>
|
||||
<pre><code> getmaxyx(v, *y, y[-2]);
|
||||
--*y; --y[-2];
|
||||
if (y[-2] < 9 || *y < 9)
|
||||
return E(Z(term too small));</code></pre>
|
||||
<p>Clearly the <code>max x</code> must be stored in <code>*y</code> and the <code>max y</code> must be stored in ..
|
||||
<code>y[-2]</code>. After all anyone knows that the coordinates are in the order <code>(X,Y)</code>!
|
||||
In fact the output of my entry and my documentation demonstrates this
|
||||
@@ -466,7 +466,7 @@ what it knows, and since <code>X</code> and <code>Y</code> are used for coordina
|
||||
of the brain is to assume <code>Y</code> is what is really <code>X</code> and <code>X</code> is what is really <code>Y</code>.</p></li>
|
||||
<li><p>More confusion with variable names: If you notice the <code>int *U, *V</code> they are
|
||||
also part of the compound literal: that is they point into it:</p>
|
||||
<pre><code> U=y+2; V=U+1;</code></pre>
|
||||
<pre><code> U=y+2; V=U+1;</code></pre>
|
||||
<p>Except that these two are done in two different places: away from the
|
||||
assignment of <code>y</code> to remove them further away from the contexts they are
|
||||
used in.</p>
|
||||
@@ -477,13 +477,13 @@ location at <code>*U, *V</code> but then assign the new location differently. Th
|
||||
<code>main()</code> I draw it at <code>*U, *V</code> and also check for the bug being eaten there
|
||||
too.</p></li>
|
||||
<li><p>There’s another array that holds a variety of data.</p>
|
||||
<pre><code> static k p[5]={1,0},W=300;</code></pre>
|
||||
<pre><code> static k p[5]={1,0},W=300;</code></pre>
|
||||
<p>It holds the following information (but not necessarily in this order):</p>
|
||||
<pre><code> WALLS
|
||||
CANNIBAL
|
||||
SHED
|
||||
SHEDS
|
||||
EVADE</code></pre>
|
||||
<pre><code> WALLS
|
||||
CANNIBAL
|
||||
SHED
|
||||
SHEDS
|
||||
EVADE</code></pre>
|
||||
<p>But how will you know that just looking at the declaration? Many variables
|
||||
and they’re part of collections but the many layers of indirection cause
|
||||
confusion to the already unhelpful variable names (for those that even have
|
||||
@@ -496,18 +496,18 @@ don’t know why.</p></li>
|
||||
<li><p>On arrays/pointers in general I also use e.g. <code>3[p]</code> and <code>p[3]</code> (there are
|
||||
many other examples that I have already shown).</p></li>
|
||||
<li><p>Expanding on referring to the same thing in more than one way take a look at:</p>
|
||||
<pre><code> case KEY_LEFT:
|
||||
V[1] = l-3;
|
||||
break;
|
||||
case KEY_RIGHT:
|
||||
V[l/l] = l/2;
|
||||
break;
|
||||
case KEY_UP:
|
||||
V[l-3] = l-1;
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
V[l/4] = l;
|
||||
break;</code></pre>
|
||||
<pre><code> case KEY_LEFT:
|
||||
V[1] = l-3;
|
||||
break;
|
||||
case KEY_RIGHT:
|
||||
V[l/l] = l/2;
|
||||
break;
|
||||
case KEY_UP:
|
||||
V[l-3] = l-1;
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
V[l/4] = l;
|
||||
break;</code></pre>
|
||||
<p>What’s going on there? First of all the letter ell looks very much like the
|
||||
digit one but above there are only two references to the digit <code>1</code>; the
|
||||
others are the letter <code>l</code>. If you’re tired though, don’t have the best
|
||||
@@ -529,7 +529,7 @@ possible that I could have negative offsets here (and there’s nothing that
|
||||
would prevent negating a variable either in this case): I have done it many
|
||||
other places! But even after all of that you still need to do the
|
||||
calculations when I could simply have had:</p>
|
||||
<pre><code> V[1] = 1; V[1] = 2; ...</code></pre>
|
||||
<pre><code> V[1] = 1; V[1] = 2; ...</code></pre>
|
||||
<p>Etc.</p></li>
|
||||
<li><p>Variable reuse. For example in the function E() there’s a variable that keeps
|
||||
track of whether or not it’s been called; that variable is <code>h</code> and it says
|
||||
@@ -556,20 +556,20 @@ is to make sure that they’re actually bigger? How does that work? Why not just
|
||||
check if it’s > than the current?</p></li>
|
||||
<li><p>More confusion with the max x/y dimensions: Going back to max x/y dimensions
|
||||
and coordinates of the snake; I showed this code before:</p>
|
||||
<pre><code> if (Y < 1 || Y >= y[-2] || X < 2 || X >= *y || y[-2] >= y[-1] || *y >= 1[y])
|
||||
{
|
||||
if (*p && !(*y>=1[y]||y[-2]>=y[-1]))
|
||||
<pre><code> if (Y < 1 || Y >= y[-2] || X < 2 || X >= *y || y[-2] >= y[-1] || *y >= 1[y])
|
||||
{
|
||||
if (Y<1||Y>=y[-2])
|
||||
Y = Y<1?y[-2]-1:1;
|
||||
if (X<2||X>=*y)
|
||||
X = X<2?*y-1:2;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
}</code></pre>
|
||||
if (*p && !(*y>=1[y]||y[-2]>=y[-1]))
|
||||
{
|
||||
if (Y<1||Y>=y[-2])
|
||||
Y = Y<1?y[-2]-1:1;
|
||||
if (X<2||X>=*y)
|
||||
X = X<2?*y-1:2;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
}</code></pre>
|
||||
<p>I asked if you could honestly figure that out easily. But here’s a bit more
|
||||
elaboration. I already talked about the negative offsets - and they should
|
||||
talk enough themselves - but look at the mess. Even if they weren’t negative
|
||||
@@ -593,10 +593,10 @@ and not even in this part of the code).</p></li>
|
||||
<li><p>The function <code>B()</code> ends with a <code>goto</code>. Why? It’s also another place where
|
||||
there’s at least one negative offset.</p></li>
|
||||
<li><p>A note on the many <code>#define</code>s in my entry. You say you dislike them:</p>
|
||||
<pre><code> Doing masses of #defines to obscure the source has become 'old'. We
|
||||
tend to 'see thru' masses of #defines due to our pre-processor tests
|
||||
that we apply. Simply abusing #defines or -Dfoo=bar won't go as far
|
||||
as a program that is more well rounded in confusion.</code></pre>
|
||||
<pre><code> Doing masses of #defines to obscure the source has become 'old'. We
|
||||
tend to 'see thru' masses of #defines due to our pre-processor tests
|
||||
that we apply. Simply abusing #defines or -Dfoo=bar won't go as far
|
||||
as a program that is more well rounded in confusion.</code></pre>
|
||||
<p>As I have noted though many of these save quite a lot of bytes too. It’s
|
||||
true that they might aid (but barely) in obfuscation but I think that my
|
||||
entry is more rounded in confusion; certainly the other techniques I have
|
||||
@@ -613,24 +613,24 @@ the way I have it now).</p></li>
|
||||
magical about the number 7 isn’t there? I do not refer to primes although
|
||||
certainly one could say that primes have a magic to them. No. I’m instead
|
||||
referring to another property: bitwise AND. For example consider the following:</p>
|
||||
<pre><code> 7 & 0
|
||||
7 & 1
|
||||
7 & 2
|
||||
7 & 3
|
||||
7 & 4
|
||||
7 & 5
|
||||
7 & 6
|
||||
7 & 7</code></pre>
|
||||
<pre><code> 7 & 0
|
||||
7 & 1
|
||||
7 & 2
|
||||
7 & 3
|
||||
7 & 4
|
||||
7 & 5
|
||||
7 & 6
|
||||
7 & 7</code></pre>
|
||||
<p>What is the result of each operation? Quite simply it’s the number itself!
|
||||
How does this relate to the <code>s</code> array though? Let me back up. Is there any
|
||||
place in the code that has the number 7 (by itself - 997 doesn’t count)? A
|
||||
quick check will answer that: no. But here’s a curious thing:</p>
|
||||
<pre><code> q X, Y, s[*D+2&(1<<3)-!Q]);</code></pre>
|
||||
<pre><code> q X, Y, s[*D+2&(1<<3)-!Q]);</code></pre>
|
||||
<p>We KNOW that at this place <code>Q</code> is 0 so the <code>!Q</code> has to be 1. Now <code>1 << 3</code> is 8. Therefore</p>
|
||||
<pre><code> (1 << 3) - !Q == 7</code></pre>
|
||||
<pre><code> (1 << 3) - !Q == 7</code></pre>
|
||||
<p>But what’s <code>*D</code>? If the snake hasn’t moved once yet it’s 0; otherwise it’s the number
|
||||
of the direction the snake is currently facing. Thus</p>
|
||||
<pre><code> *D&(1<<3)-!Q</code></pre>
|
||||
<pre><code> *D&(1<<3)-!Q</code></pre>
|
||||
<p>…refers to <code>*D</code>. However if I were to have that be the element it wouldn’t
|
||||
work right: I wanted the semicolon in there but the space was needed to
|
||||
reduce the iocccsize down by one (ironic that adding a byte reduces it by
|
||||
@@ -845,11 +845,11 @@ matter having a ‘o’ at 0,0 isn’t either).</p>
|
||||
|
||||
You are free to share and adapt this file under the terms of this license:
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
|
||||
For more information, see:
|
||||
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
-->
|
||||
|
||||
@@ -886,7 +886,7 @@ matter having a ‘o’ at 0,0 isn’t either).</p>
|
||||
<div class="footer">
|
||||
<h2>Copyright and CC BY-SA 4.0 License</h2>
|
||||
<p>This file and web page is:</p>
|
||||
<blockquote><p><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></p></blockquote>
|
||||
<blockquote><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></blockquote>
|
||||
<p>You are free to share and adapt this file under the terms of this license:</p>
|
||||
<blockquote><b>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</b></blockquote>
|
||||
<p>For more information, see:</p>
|
||||
|
||||
@@ -252,14 +252,13 @@ messed up. There are numerous things you might try but probably the easiest is
|
||||
to run the game again without modifying the dimensions (and then just quit) or
|
||||
even just the <code>reset</code> command.</p>
|
||||
<p>The Linux man page says:</p>
|
||||
<pre><code>You might have to run the `reset` tool like:
|
||||
|
||||
<LF>reset<LF>
|
||||
<p>You might have to run the <code>reset</code> tool like:</p>
|
||||
<pre><code> <LF>reset<LF>
|
||||
|
||||
(the line-feed character is normally control-J) to get the terminal
|
||||
to work, as carriage-return may no longer work in the abnormal state.</code></pre>
|
||||
<p>If you don’t have the reset utility you can try:</p>
|
||||
<pre><code> echo -e \\033c</code></pre>
|
||||
<pre><code> echo -e \\033c</code></pre>
|
||||
<p>Otherwise try <code>clear; stty sane</code> (that will turn on echo also) or if all else
|
||||
fails log out and back in.</p>
|
||||
<p>For more information on this subject generally see the <a href="https://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO.html">Linux keyboard and
|
||||
@@ -271,10 +270,10 @@ outside what’s actually possible with their screen. But then player 4 comes
|
||||
along and thinks he/she will be clever and mess with the dimensions a bit. Let’s
|
||||
say they have a 13” monitor and they think it’d be funny to see how 997 lines
|
||||
would work; they might try something like:</p>
|
||||
<pre><code> LINES=997 ./prog</code></pre>
|
||||
<pre><code> LINES=997 ./prog</code></pre>
|
||||
<p>What then? Well expect trouble; curses will not know any better and the max
|
||||
number of lines will be 997. If they were to do:</p>
|
||||
<pre><code> COLUMNS=997 ./prog</code></pre>
|
||||
<pre><code> COLUMNS=997 ./prog</code></pre>
|
||||
<p>Then they will see a different effect. Again the same reason: the player trying
|
||||
to be funny.</p>
|
||||
<p>The game will try and be funny in return and you can expect it to not function
|
||||
@@ -306,7 +305,7 @@ GitHub) file).</p>
|
||||
<p>According to my tests for monochrome terminals the screen has the white and
|
||||
black background; if terminal is configured to be black background white
|
||||
foreground that is the order it is too. You can try that like:</p>
|
||||
<pre><code> TERM=linux-m ./prog</code></pre>
|
||||
<pre><code> TERM=linux-m ./prog</code></pre>
|
||||
<p>But I do not specifically check if the terminal has colours. Is there a curses
|
||||
implementation that has a problem here? Below I explain what to comment out
|
||||
should you need colours to be disabled but I personally have not run into any
|
||||
@@ -324,7 +323,7 @@ including COLORS-1.</code></pre>
|
||||
|
||||
[...]
|
||||
|
||||
COLOR_PAIRS corresponds to the terminal database's max_pairs capability, (see terminfo(5)).</code></pre>
|
||||
COLOR_PAIRS corresponds to the terminal database's max_pairs capability, (see terminfo(5)).</code></pre>
|
||||
<p>Based on the two as well as the fact that monochrome terminals (I’ve tried under
|
||||
both Linux and macOS) seem to work fine I believe I am fine here too. And to
|
||||
confirm this I wrote the following code with the output below:</p>
|
||||
@@ -332,11 +331,11 @@ confirm this I wrote the following code with the output below:</p>
|
||||
|
||||
int main()
|
||||
{
|
||||
initscr();
|
||||
start_color();
|
||||
printw("COLORS: %d\nCOLOR_PAIRS: %d\n", COLORS, COLOR_PAIRS);
|
||||
getch();
|
||||
endwin();
|
||||
initscr();
|
||||
start_color();
|
||||
printw("COLORS: %d\nCOLOR_PAIRS: %d\n", COLORS, COLOR_PAIRS);
|
||||
getch();
|
||||
endwin();
|
||||
}
|
||||
|
||||
TERM=linux-m ./colour_pairs
|
||||
@@ -351,17 +350,17 @@ even it would only be a runtime error if the colours are supported and the
|
||||
number is out of the range? To try and figure this out I did another test:</p>
|
||||
<pre><code> int main()
|
||||
{
|
||||
initscr();
|
||||
start_color();
|
||||
initscr();
|
||||
start_color();
|
||||
|
||||
init_pair(COLOR_PAIRS+1, COLOR_WHITE, COLOR_GREEN);
|
||||
bkgd(COLOR_PAIR(COLOR_PAIRS+1));
|
||||
init_pair(1, COLOR_WHITE, COLOR_BLACK);
|
||||
attron(COLOR_PAIR(1));
|
||||
printw("COLORS: %d\nCOLOR_PAIRS: %d\n", COLORS, COLOR_PAIRS);
|
||||
init_pair(COLOR_PAIRS+1, COLOR_WHITE, COLOR_GREEN);
|
||||
bkgd(COLOR_PAIR(COLOR_PAIRS+1));
|
||||
init_pair(1, COLOR_WHITE, COLOR_BLACK);
|
||||
attron(COLOR_PAIR(1));
|
||||
printw("COLORS: %d\nCOLOR_PAIRS: %d\n", COLORS, COLOR_PAIRS);
|
||||
|
||||
getch();
|
||||
endwin();
|
||||
getch();
|
||||
endwin();
|
||||
}</code></pre>
|
||||
<p>Running it like</p>
|
||||
<pre><code> TERM=linux-m ./colour_pairs</code></pre>
|
||||
@@ -388,11 +387,11 @@ but I do not know for certain.</p>
|
||||
|
||||
You are free to share and adapt this file under the terms of this license:
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
|
||||
For more information, see:
|
||||
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
-->
|
||||
|
||||
@@ -429,7 +428,7 @@ but I do not know for certain.</p>
|
||||
<div class="footer">
|
||||
<h2>Copyright and CC BY-SA 4.0 License</h2>
|
||||
<p>This file and web page is:</p>
|
||||
<blockquote><p><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></p></blockquote>
|
||||
<blockquote><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></blockquote>
|
||||
<p>You are free to share and adapt this file under the terms of this license:</p>
|
||||
<blockquote><b>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</b></blockquote>
|
||||
<p>For more information, see:</p>
|
||||
|
||||
@@ -155,9 +155,9 @@ needed. This won’t work right if you change the score line!</p>
|
||||
small screen will make it harder to play esp without the cheat modes enabled
|
||||
(but they can still be fun with large screens).</p></li>
|
||||
<li><p>RESOLUTION #1: Open the <a href="prog.c">prog.c</a> and change the line</p>
|
||||
<pre><code> #define J Z(X:%d/%d Y:%d/%d S:%zu/%zu B:%zu\n),Y,y[-2],X, *y, A, g, c );</code></pre>
|
||||
<pre><code> #define J Z(X:%d/%d Y:%d/%d S:%zu/%zu B:%zu\n),Y,y[-2],X, *y, A, g, c );</code></pre>
|
||||
<p>To be something like:</p>
|
||||
<pre><code> #define J Z(B:%zu\n), c);</code></pre>
|
||||
<pre><code> #define J Z(B:%zu\n), c);</code></pre>
|
||||
<p>Recompile and try again. That will then show only the number of bugs eaten.
|
||||
See the <a href="HACKING.html">HACKING.html</a> (<a href="HACKING.md">HACKING.md</a> on GitHub) file for other data you
|
||||
can include (though there are some discrepancies here and there as you’ll
|
||||
@@ -248,16 +248,16 @@ theoretically happen. If this happens you will have to kill the game by e.g.
|
||||
ctrl-c. Try increasing the screen size and/or decreasing the max size of the
|
||||
snake. See below for some tests.</p>
|
||||
<p>I removed caps in a test and then:</p>
|
||||
<pre><code> GROW=1 COLUMNS=30 LINES=10 CANNIBAL=1 MAXSIZE=10000 ./prog</code></pre>
|
||||
<pre><code> GROW=1 COLUMNS=30 LINES=10 CANNIBAL=1 MAXSIZE=10000 ./prog</code></pre>
|
||||
<p>It froze at this point:</p>
|
||||
<pre><code> X:14/29 Y:5/9 S:323/10000 B:318</code></pre>
|
||||
<pre><code> X:14/29 Y:5/9 S:323/10000 B:318</code></pre>
|
||||
<p>This is because there was only one place for the bug - where the snake head
|
||||
was to be. With these parameters the limit is actually 189! This could
|
||||
perhaps be increased but the calculation I have used is easy and although I
|
||||
certainly could make it so it’s one less than the max that takes more bytes
|
||||
and I don’t see it actually mattering.</p>
|
||||
<p>Another time I tried:</p>
|
||||
<pre><code> LINES=6 COLUMNS=6</code></pre>
|
||||
<pre><code> LINES=6 COLUMNS=6</code></pre>
|
||||
<p>And it also froze (as noted I impose a minimum of >= 10 for both LINES and
|
||||
COLUMNS).</p>
|
||||
<p>Ultimately I had to kill the program due to the game being stuck in the bug
|
||||
@@ -266,29 +266,29 @@ good would that do? It would use more bytes and what would it do anyway,
|
||||
win? Well that’s what the max size is for.</p></li>
|
||||
<li><p>TERMINAL SIZE TO MAX SNAKE SIZE CALCULATION ETC.</p>
|
||||
<p>For this information and more use the termcaps utility:</p>
|
||||
<pre><code> make test</code></pre>
|
||||
<pre><code> make test</code></pre>
|
||||
<p>An example:</p>
|
||||
<pre><code> terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
terminal supports bold
|
||||
terminal supports colours
|
||||
<pre><code> terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
terminal supports bold
|
||||
terminal supports colours
|
||||
|
||||
terminal rows 41 (38 playable)
|
||||
terminal cols 154 (152 playable)
|
||||
terminal rows 41 (38 playable)
|
||||
terminal cols 154 (152 playable)
|
||||
|
||||
snake size: 997 (max size: 5738)
|
||||
bugs: 199 (max size: 1147)
|
||||
snake size: 997 (max size: 5738)
|
||||
bugs: 199 (max size: 1147)
|
||||
|
||||
at least 34 columns (currently 154) recommended for snake size 997
|
||||
at least 37 columns (currently 154) recommended for capped snake size 5738
|
||||
at least 34 columns (currently 154) recommended for snake size 997
|
||||
at least 37 columns (currently 154) recommended for capped snake size 5738
|
||||
|
||||
No problems detected.</code></pre>
|
||||
No problems detected.</code></pre>
|
||||
<p>Why are there only 38 playable lines for 41 rows? The first row is the score
|
||||
line, the second is the top wall, the last is the bottom wall. For columns
|
||||
you have the left and rightmost columns for the walls.</p>
|
||||
<p>The calculation for max size takes place after decrementing the max y/x;
|
||||
then it’s <code>(maxy - 2) * (maxx - 2)</code>; above that would be:</p>
|
||||
<pre><code> (41 - 2) * (156 - 2) == 6006</code></pre>
|
||||
<pre><code> (41 - 2) * (156 - 2) == 6006</code></pre>
|
||||
<p>If for some reason the game were to stall for this purpose you would have to
|
||||
kill the game by e.g. ctrl-c since the bug placement is stuck in a loop.
|
||||
This shouldn’t happen though.</p></li>
|
||||
@@ -313,7 +313,7 @@ Or is the system rather busy?</p></li>
|
||||
is 0? The head is the obvious choice so once you do get to size 1 you will still
|
||||
only have the head. When you get to size 2 you’ll have part of the body too.
|
||||
Try:</p>
|
||||
<pre><code> SIZE=1 GROW=1</code></pre>
|
||||
<pre><code> SIZE=1 GROW=1</code></pre>
|
||||
<p>And you will see that at one bug you’ll have size two and just as if you had
|
||||
two bugs with the previous invocation.</p>
|
||||
<p>BTW: When you are size 1 you can go back on yourself even if cannibalism is
|
||||
@@ -336,7 +336,7 @@ terminal is under <code>/usr/share/terminfo/l/linux-m</code> and under macOS (Ca
|
||||
at least) it’s at <code>/usr/share/terminfo/6c/linux-m</code> (for macOS Ventura it’s
|
||||
<code>/usr/share/terminfo/6c/linux-m</code>).</p></li>
|
||||
<li><p>BOTTOM LINE: Try using a monochrome terminal for the game by e.g.:</p>
|
||||
<pre><code> TERM=linux-m ./prog</code></pre>
|
||||
<pre><code> TERM=linux-m ./prog</code></pre>
|
||||
<p>And then on your white background terminal the game should keep the
|
||||
background white and the foreground black. This will of course mean you have
|
||||
no colour but unfortunately changing the background colour of curses would
|
||||
@@ -440,11 +440,11 @@ is 0 and I limit the size to be no bigger than the max size.</p>
|
||||
|
||||
You are free to share and adapt this file under the terms of this license:
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||||
|
||||
For more information, see:
|
||||
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
-->
|
||||
|
||||
@@ -481,7 +481,7 @@ is 0 and I limit the size to be no bigger than the max size.</p>
|
||||
<div class="footer">
|
||||
<h2>Copyright and CC BY-SA 4.0 License</h2>
|
||||
<p>This file and web page is:</p>
|
||||
<blockquote><p><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></p></blockquote>
|
||||
<blockquote><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></blockquote>
|
||||
<p>You are free to share and adapt this file under the terms of this license:</p>
|
||||
<blockquote><b>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</b></blockquote>
|
||||
<p>For more information, see:</p>
|
||||
|
||||
Reference in new issue
Block a user