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
@@ -146,7 +146,7 @@ matters; I only have Intel CPUs and arm64 (MacBook Pro M1).</p>
|
||||
<p>I imagine that it works for 32-bit systems but I do not know for sure.</p>
|
||||
<h1 id="portability-macos">Portability: macOS</h1>
|
||||
<p>You should be able to get the compiler with:</p>
|
||||
<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">sudo</span> xcode-select <span class="at">--install</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">sudo</span> xcode-select <span class="at">--install</span></span></code></pre></div>
|
||||
<p>You don’t need Xcode itself and it appears that the command line tools (as above
|
||||
should install) already has ncurses so there shouldn’t be anything else that
|
||||
needs to be done. But I’m not actually sure of this - I’m seeing conflicting
|
||||
@@ -159,20 +159,20 @@ so that you don’t need sudo because … Well never mind.</p>
|
||||
you want to use the Makefile) to compile and link this entry. With Fedora more
|
||||
recent versions there’s the <code>dnf</code> package manager but I cannot help with any of
|
||||
the GUI installers since I don’t use them. Something like:</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">sudo</span> dnf install ncurses-devel ncurses make gcc</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">sudo</span> dnf install ncurses-devel ncurses make gcc</span></code></pre></div>
|
||||
<p>or</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># dnf install ncurses-devel ncurses make gcc</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="co"># dnf install ncurses-devel ncurses make gcc</span></span></code></pre></div>
|
||||
<h1 id="portability-centos">Portability: CentOS</h1>
|
||||
<p>Just like Fedora you will need <code>gcc</code>, <code>ncurses</code>, <code>ncurses-devel</code> (and if you
|
||||
want to use the Makefile <code>make</code>). CentOS uses <code>yum</code> and CentOS 8 uses <code>dnf</code>.
|
||||
So:</p>
|
||||
<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="fu">sudo</span> yum install ncurses-devel ncurses make gcc</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="fu">sudo</span> yum install ncurses-devel ncurses make gcc</span></code></pre></div>
|
||||
<p>or</p>
|
||||
<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="co"># yum install ncurses-devel ncurses make gcc</span></span></code></pre></div>
|
||||
<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="co"># yum install ncurses-devel ncurses make gcc</span></span></code></pre></div>
|
||||
<p>or</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">sudo</span> dnf install ncurses-devel ncurses make gcc</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">sudo</span> dnf install ncurses-devel ncurses make gcc</span></code></pre></div>
|
||||
<p>or</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="co"># dnf install ncurses-devel ncurses make gcc</span></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="co"># dnf install ncurses-devel ncurses make gcc</span></span></code></pre></div>
|
||||
<p>You can also use clang to compile (which is what gcc actually is under macOS).</p>
|
||||
<h1 id="compilation-notes">Compilation notes</h1>
|
||||
<p>As long as you have the dependencies above the only thing that comes to mind is
|
||||
|
||||
@@ -34,7 +34,7 @@ I imagine that it works for 32-bit systems but I do not know for sure.
|
||||
You should be able to get the compiler with:
|
||||
|
||||
```sh
|
||||
sudo xcode-select --install
|
||||
sudo xcode-select --install
|
||||
```
|
||||
|
||||
You don't need Xcode itself and it appears that the command line tools (as above
|
||||
@@ -54,13 +54,13 @@ recent versions there's the `dnf` package manager but I cannot help with any of
|
||||
the GUI installers since I don't use them. Something like:
|
||||
|
||||
```sh
|
||||
sudo dnf install ncurses-devel ncurses make gcc
|
||||
sudo dnf install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```sh
|
||||
# dnf install ncurses-devel ncurses make gcc
|
||||
# dnf install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
# Portability: CentOS
|
||||
@@ -70,25 +70,25 @@ want to use the Makefile `make`). CentOS uses `yum` and CentOS 8 uses `dnf`.
|
||||
So:
|
||||
|
||||
```sh
|
||||
sudo yum install ncurses-devel ncurses make gcc
|
||||
sudo yum install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```sh
|
||||
# yum install ncurses-devel ncurses make gcc
|
||||
# yum install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```sh
|
||||
sudo dnf install ncurses-devel ncurses make gcc
|
||||
sudo dnf install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```sh
|
||||
# dnf install ncurses-devel ncurses make gcc
|
||||
# dnf install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
You can also use clang to compile (which is what gcc actually is under macOS).
|
||||
|
||||
+44
-44
@@ -192,44 +192,44 @@ defaults if you don’t want to change the colour.</p>
|
||||
initialise a pair (make it 5 so as to not interfere with the script
|
||||
customisability) and then you use the bkgd() function with the colour pair.
|
||||
Something like this:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>init_pair<span class="op">(</span><span class="dv">5</span><span class="op">,</span> COLOR_BLACK<span class="op">,</span> COLOR_WHITE<span class="op">);</span></span>
|
||||
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>bkgd<span class="op">(</span>COLOR_PAIR<span class="op">(</span><span class="dv">5</span><span class="op">));</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> init_pair<span class="op">(</span><span class="dv">5</span><span class="op">,</span> COLOR_BLACK<span class="op">,</span> COLOR_WHITE<span class="op">);</span></span>
|
||||
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> bkgd<span class="op">(</span>COLOR_PAIR<span class="op">(</span><span class="dv">5</span><span class="op">));</span></span></code></pre></div>
|
||||
<p>I played with this after winning and I came across some problems with colours
|
||||
but that changes the background of the program anyway.</p>
|
||||
<p>The standard colour identifiers are:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>COLOR_BLACK</span>
|
||||
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>COLOR_RED</span>
|
||||
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>COLOR_GREEN</span>
|
||||
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>COLOR_YELLOW</span>
|
||||
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a>COLOR_BLUE</span>
|
||||
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a>COLOR_MAGENTA</span>
|
||||
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a>COLOR_CYAN</span>
|
||||
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a>COLOR_WHITE</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> COLOR_BLACK</span>
|
||||
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> COLOR_RED</span>
|
||||
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> COLOR_GREEN</span>
|
||||
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> COLOR_YELLOW</span>
|
||||
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a> COLOR_BLUE</span>
|
||||
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a> COLOR_MAGENTA</span>
|
||||
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a> COLOR_CYAN</span>
|
||||
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a> COLOR_WHITE</span></code></pre></div>
|
||||
<p>See Linux Journal for more information article
|
||||
<a href="https://www.linuxjournal.com/content/programming-color-ncurses" class="uri">https://www.linuxjournal.com/content/programming-color-ncurses</a> for more
|
||||
details.</p>
|
||||
<h2 id="modifying-the-characters-for-the-wall-bug-and-snake">Modifying the characters for the wall, bug and snake</h2>
|
||||
<p>For the wall, bug and snake body characters you can replace the following in the
|
||||
source code (<strong>include the single quotes!</strong>) respectively:</p>
|
||||
<pre><code>'#'
|
||||
<pre><code> '#'
|
||||
|
||||
'*'
|
||||
'*'
|
||||
|
||||
'o'</code></pre>
|
||||
'o'</code></pre>
|
||||
<h2 id="modifying-input-keys">Modifying input keys</h2>
|
||||
<p>Let’s say you don’t want to use arrow keys or you don’t have arrow keys. Instead
|
||||
you might want the keys <code>l</code>, <code>r</code>, <code>u</code> and <code>d</code> for the directions. Find the case
|
||||
statements:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="cf">case</span> KEY_LEFT<span class="op">:</span></span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="cf">case</span> KEY_RIGHT<span class="op">:</span></span>
|
||||
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="cf">case</span> KEY_UP<span class="op">:</span></span>
|
||||
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="cf">case</span> KEY_DOWN<span class="op">:</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> KEY_LEFT<span class="op">:</span></span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> KEY_RIGHT<span class="op">:</span></span>
|
||||
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> KEY_UP<span class="op">:</span></span>
|
||||
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> KEY_DOWN<span class="op">:</span></span></code></pre></div>
|
||||
<p>Replace <code>KEY_LEFT</code> with:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ch">'l'</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ch">'l'</span></span></code></pre></div>
|
||||
<p>and do the same thing for the other directions too. If you want more than one
|
||||
key e.g. the arrow keys and the letters just add another case statement e.g. for
|
||||
left it might be:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="cf">case</span> KEY_LEFT<span class="op">:</span> <span class="cf">case</span> <span class="ch">'l'</span><span class="op">:</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> KEY_LEFT<span class="op">:</span> <span class="cf">case</span> <span class="ch">'l'</span><span class="op">:</span></span></code></pre></div>
|
||||
<p>Yes the single quotes matter. You can do similar for the other input keys.
|
||||
Please note that modifier keys like ctrl aren’t detectable or at least I’m
|
||||
unaware of how to do so.</p>
|
||||
@@ -245,9 +245,9 @@ end of the game; I leave that as an exercise to the reader to implement two
|
||||
different sets. Please also be aware that if you don’t want any information you
|
||||
must set it to the below at the very least; defining it without a value is not
|
||||
enough (it amounts to the parameters to a printf call):</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#define J </span><span class="st">" "</span><span class="pp"> </span><span class="op">);</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">#define J </span><span class="st">" "</span><span class="pp"> </span><span class="op">);</span></span></code></pre></div>
|
||||
<p>If you don’t care about brief displays of ‘o’ at 0,0 you can just have:</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#define J </span><span class="st">""</span><span class="op">);</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">#define J </span><span class="st">""</span><span class="op">);</span></span></code></pre></div>
|
||||
<p>That’s the bare minimum. Notice also that it’s been a long while since I’ve
|
||||
tested this part but I think this is right.</p>
|
||||
<p>Anyway as I said the score line has basic statistics that’s relatively easy to
|
||||
@@ -262,7 +262,7 @@ bug. This however was something I didn’t quite like: I like having the
|
||||
coordinates of where the snake is plus the other things that are there (a number
|
||||
of which were added over time). Obviously this would take many bug sized bytes
|
||||
(bites) even once let alone twice! Thus I made it into a define:</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#define J Z</span><span class="op">(</span><span class="pp">X</span><span class="op">:%</span><span class="pp">d</span><span class="op">/%</span><span class="pp">d Y</span><span class="op">:%</span><span class="pp">d</span><span class="op">/%</span><span class="pp">d S</span><span class="op">:%</span><span class="pp">zu</span><span class="op">/%</span><span class="pp">zu B</span><span class="op">:%</span><span class="pp">zu\n</span><span class="op">),</span><span class="pp"> Y</span><span class="op">,</span><span class="pp"> y</span><span class="op">[-</span><span class="dv">2</span><span class="op">],</span><span class="pp"> X</span><span class="op">,*</span><span class="pp">y</span><span class="op">,</span><span class="pp">A</span><span class="op">,</span><span class="pp">g</span><span class="op">,</span><span class="pp"> c</span><span class="op">);</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">#define J Z</span><span class="op">(</span><span class="pp">X</span><span class="op">:%</span><span class="pp">d</span><span class="op">/%</span><span class="pp">d Y</span><span class="op">:%</span><span class="pp">d</span><span class="op">/%</span><span class="pp">d S</span><span class="op">:%</span><span class="pp">zu</span><span class="op">/%</span><span class="pp">zu B</span><span class="op">:%</span><span class="pp">zu\n</span><span class="op">),</span><span class="pp"> Y</span><span class="op">,</span><span class="pp"> y</span><span class="op">[-</span><span class="dv">2</span><span class="op">],</span><span class="pp"> X</span><span class="op">,*</span><span class="pp">y</span><span class="op">,</span><span class="pp">A</span><span class="op">,</span><span class="pp">g</span><span class="op">,</span><span class="pp"> c</span><span class="op">);</span></span></code></pre></div>
|
||||
<p>With the table below you can show a variety of other variables/statistics.</p>
|
||||
<p>There’s another reason for changing this line though: depending on the terminal
|
||||
width the line could cover the top wall; this can even happen only part of the
|
||||
@@ -280,37 +280,37 @@ so if this line wasn’t there it would require changes to make it work right.</
|
||||
<p>For an example this would only include the size of the snake and the number of
|
||||
bugs eaten (I think I have this correct; I’ve made many changes to the point of
|
||||
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>
|
||||
<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
|
||||
|
||||
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>
|
||||
<div class="sourceCode" id="cb12"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a>X <span class="op">=</span> H <span class="op">/</span> <span class="dv">2</span><span class="op">;</span> Y <span class="op">=</span> <span class="op">*</span>x <span class="op">/</span> <span class="dv">2</span><span class="op">;</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb12"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> X <span class="op">=</span> H <span class="op">/</span> <span class="dv">2</span><span class="op">;</span> Y <span class="op">=</span> <span class="op">*</span>x <span class="op">/</span> <span class="dv">2</span><span class="op">;</span></span></code></pre></div>
|
||||
<p>To be something like:</p>
|
||||
<div class="sourceCode" id="cb13"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a>X <span class="op">=</span> R<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>
|
||||
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a>Y <span class="op">=</span> R<span class="op">(</span><span class="dv">2</span><span class="op">,*</span>x<span class="op">-</span><span class="dv">1</span><span class="op">);</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb13"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a> X <span class="op">=</span> R<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>
|
||||
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a> Y <span class="op">=</span> R<span class="op">(</span><span class="dv">2</span><span class="op">,*</span>x<span class="op">-</span><span class="dv">1</span><span class="op">);</span></span></code></pre></div>
|
||||
<p>Or whatever you might want it to be… (question to answer: will this work at
|
||||
all? You decide!)</p>
|
||||
<h1 id="additions">Additions (+)</h1>
|
||||
@@ -407,22 +407,22 @@ their ruddy phone instead of where they’re walking (even when crossing a busy
|
||||
street!).</p>
|
||||
<p>If you look at the walls code you will see a ternary operator for both <code>X</code> and <code>Y</code>
|
||||
coordinates. This of course is very different now but the idea remains the same:</p>
|
||||
<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-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-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
|
||||
<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-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-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
|
||||
the walls (off screen). Depending on where the snake is it will set the
|
||||
coordinates to the correct new location.</p>
|
||||
<p>If however you wanted the walls to act as a barrier you could do something like
|
||||
this instead (omitting the inner if statements here):</p>
|
||||
<div class="sourceCode" id="cb15"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb15-1"><a href="#cb15-1" 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><span class="dv">1</span><span class="op">:*</span>H<span class="op">-</span><span class="dv">1</span><span class="op">;</span></span>
|
||||
<div class="sourceCode" id="cb15"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb15-1"><a href="#cb15-1" 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><span class="dv">1</span><span class="op">:*</span>H<span class="op">-</span><span class="dv">1</span><span class="op">;</span></span>
|
||||
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb15-3"><a href="#cb15-3" 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><span class="dv">2</span><span class="op">:*</span>O<span class="op">-</span><span class="dv">1</span><span class="op">;</span></span></code></pre></div>
|
||||
<span id="cb15-3"><a href="#cb15-3" 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><span class="dv">2</span><span class="op">:*</span>O<span class="op">-</span><span class="dv">1</span><span class="op">;</span></span></code></pre></div>
|
||||
<p>Again though that’s just the idea; the code is dramatically different. The above
|
||||
incidentally is not even complete.</p>
|
||||
<p>You could also have it so depending on the WALLS value have it go through
|
||||
|
||||
+50
-48
@@ -79,8 +79,8 @@ customisability) and then you use the bkgd() function with the colour pair.
|
||||
Something like this:
|
||||
|
||||
```c
|
||||
init_pair(5, COLOR_BLACK, COLOR_WHITE);
|
||||
bkgd(COLOR_PAIR(5));
|
||||
init_pair(5, COLOR_BLACK, COLOR_WHITE);
|
||||
bkgd(COLOR_PAIR(5));
|
||||
```
|
||||
|
||||
I played with this after winning and I came across some problems with colours
|
||||
@@ -89,14 +89,14 @@ but that changes the background of the program anyway.
|
||||
The standard colour identifiers are:
|
||||
|
||||
```c
|
||||
COLOR_BLACK
|
||||
COLOR_RED
|
||||
COLOR_GREEN
|
||||
COLOR_YELLOW
|
||||
COLOR_BLUE
|
||||
COLOR_MAGENTA
|
||||
COLOR_CYAN
|
||||
COLOR_WHITE
|
||||
COLOR_BLACK
|
||||
COLOR_RED
|
||||
COLOR_GREEN
|
||||
COLOR_YELLOW
|
||||
COLOR_BLUE
|
||||
COLOR_MAGENTA
|
||||
COLOR_CYAN
|
||||
COLOR_WHITE
|
||||
```
|
||||
|
||||
|
||||
@@ -111,11 +111,11 @@ For the wall, bug and snake body characters you can replace the following in the
|
||||
source code (**include the single quotes!**) respectively:
|
||||
|
||||
```
|
||||
'#'
|
||||
'#'
|
||||
|
||||
'*'
|
||||
'*'
|
||||
|
||||
'o'
|
||||
'o'
|
||||
```
|
||||
|
||||
## Modifying input keys
|
||||
@@ -125,16 +125,16 @@ you might want the keys `l`, `r`, `u` and `d` for the directions. Find the case
|
||||
statements:
|
||||
|
||||
```c
|
||||
case KEY_LEFT:
|
||||
case KEY_RIGHT:
|
||||
case KEY_UP:
|
||||
case KEY_DOWN:
|
||||
case KEY_LEFT:
|
||||
case KEY_RIGHT:
|
||||
case KEY_UP:
|
||||
case KEY_DOWN:
|
||||
```
|
||||
|
||||
Replace `KEY_LEFT` with:
|
||||
|
||||
```c
|
||||
'l'
|
||||
'l'
|
||||
```
|
||||
|
||||
and do the same thing for the other directions too. If you want more than one
|
||||
@@ -142,7 +142,7 @@ key e.g. the arrow keys and the letters just add another case statement e.g. for
|
||||
left it might be:
|
||||
|
||||
```c
|
||||
case KEY_LEFT: case 'l':
|
||||
case KEY_LEFT: case 'l':
|
||||
```
|
||||
|
||||
Yes the single quotes matter. You can do similar for the other input keys.
|
||||
@@ -167,13 +167,13 @@ must set it to the below at the very least; defining it without a value is not
|
||||
enough (it amounts to the parameters to a printf call):
|
||||
|
||||
```c
|
||||
#define J " " );
|
||||
#define J " " );
|
||||
```
|
||||
|
||||
If you don't care about brief displays of 'o' at 0,0 you can just have:
|
||||
|
||||
```c
|
||||
#define J "");
|
||||
#define J "");
|
||||
```
|
||||
|
||||
That's the bare minimum. Notice also that it's been a long while since I've
|
||||
@@ -195,7 +195,7 @@ of which were added over time). Obviously this would take many bug sized bytes
|
||||
(bites) even once let alone twice! Thus I made it into a define:
|
||||
|
||||
```c
|
||||
#define J Z(X:%d/%d Y:%d/%d S:%zu/%zu B:%zu\n), Y, y[-2], X,*y,A,g, c);
|
||||
#define J Z(X:%d/%d Y:%d/%d S:%zu/%zu B:%zu\n), Y, y[-2], X,*y,A,g, c);
|
||||
```
|
||||
|
||||
With the table below you can show a variety of other variables/statistics.
|
||||
@@ -221,34 +221,36 @@ bugs eaten (I think I have this correct; I've made many changes to the point of
|
||||
not wanting to mess with anything that's unnecessary):
|
||||
|
||||
```c
|
||||
#define J Z(SIZE: %zu BUGS: %zu\n), A, c);
|
||||
#define J Z(SIZE: %zu BUGS: %zu\n), A, c);
|
||||
```
|
||||
|
||||
More generally the following expressions and data types (with format specifiers)
|
||||
come to mind as information that might be of interest.
|
||||
|
||||
DESCRIPTION EXPRESSION TYPE FORMAT SPECIFIER
|
||||
```
|
||||
DESCRIPTION EXPRESSION TYPE FORMAT SPECIFIER
|
||||
|
||||
Snake size A size_t %zu
|
||||
Snake size A size_t %zu
|
||||
|
||||
Y coordinate Y int %d
|
||||
of snake head
|
||||
Y coordinate Y int %d
|
||||
of snake head
|
||||
|
||||
X coordinate X int %d
|
||||
of snake head
|
||||
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
|
||||
bug)
|
||||
Growth size (per N size_t %zu
|
||||
bug)
|
||||
```
|
||||
|
||||
|
||||
## Make it so the snake starts at a random location
|
||||
@@ -256,14 +258,14 @@ come to mind as information that might be of interest.
|
||||
Quite simply change:
|
||||
|
||||
```c
|
||||
X = H / 2; Y = *x / 2;
|
||||
X = H / 2; Y = *x / 2;
|
||||
```
|
||||
|
||||
To be something like:
|
||||
|
||||
```c
|
||||
X = R(1,H-1);
|
||||
Y = R(2,*x-1);
|
||||
X = R(1,H-1);
|
||||
Y = R(2,*x-1);
|
||||
```
|
||||
|
||||
Or whatever you might want it to be... (question to answer: will this work at
|
||||
@@ -394,13 +396,13 @@ If you look at the walls code you will see a ternary operator for both `X` and `
|
||||
coordinates. This of course is very different now but the idea remains the same:
|
||||
|
||||
```c
|
||||
if (p && !(*O>=O[1]||H>=M(1)))
|
||||
{
|
||||
if (X<1||X>=H)
|
||||
X = X<1?H-1:1;
|
||||
if (Y<2||Y>=*O)
|
||||
Y = Y<2?*O-1:2;
|
||||
}
|
||||
if (p && !(*O>=O[1]||H>=M(1)))
|
||||
{
|
||||
if (X<1||X>=H)
|
||||
X = X<1?H-1:1;
|
||||
if (Y<2||Y>=*O)
|
||||
Y = Y<2?*O-1:2;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -413,9 +415,9 @@ If however you wanted the walls to act as a barrier you could do something like
|
||||
this instead (omitting the inner if statements here):
|
||||
|
||||
```c
|
||||
X=X<1?1:*H-1;
|
||||
X=X<1?1:*H-1;
|
||||
|
||||
Y=Y<2?2:*O-1;
|
||||
Y=Y<2?2:*O-1;
|
||||
```
|
||||
|
||||
Again though that's just the idea; the code is dramatically different. The above
|
||||
|
||||
+16
-16
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ make
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2020 ferguson1 bugs](../../bugs.html#2020_ferguson1).
|
||||
@@ -19,8 +19,8 @@ For more detailed information see [2020 ferguson1 bugs](../../bugs.html#2020_fer
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
WAIT=N WALLS=[01] EVADE=N SIZE=N MAXSIZE=N GROW=N SHEDS=N SHED=N CANNIBAL=[01] ./prog
|
||||
# start pressing some arrow keys
|
||||
WAIT=N WALLS=[01] EVADE=N SIZE=N MAXSIZE=N GROW=N SHEDS=N SHED=N CANNIBAL=[01] ./prog
|
||||
# start pressing some arrow keys
|
||||
```
|
||||
|
||||
where `N` is a number and `[01]` is either `1` or `0` (or more correctly zero
|
||||
@@ -88,25 +88,25 @@ and non-zero).
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
make test
|
||||
make test
|
||||
|
||||
WAIT=75 WALLS=1 CANNIBAL=1 ./prog
|
||||
WAIT=75 WALLS=1 CANNIBAL=1 ./prog
|
||||
|
||||
./prog
|
||||
./prog
|
||||
|
||||
SIZE=-1 ./prog
|
||||
SIZE=-1 ./prog
|
||||
|
||||
CANNIBAL=1 WALLS=1 WAIT=50 EVADE=200 ./prog
|
||||
CANNIBAL=1 WALLS=1 WAIT=50 EVADE=200 ./prog
|
||||
|
||||
WAIT=75 GROW=-1 SIZE=5 CANNIBAL=1 ./prog
|
||||
WAIT=75 GROW=-1 SIZE=5 CANNIBAL=1 ./prog
|
||||
|
||||
CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 MAXSIZE=10 ./prog
|
||||
CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 MAXSIZE=10 ./prog
|
||||
|
||||
./play
|
||||
# allows you to configure colours and has various pre-configured gameplay modes
|
||||
./play
|
||||
# allows you to configure colours and has various pre-configured gameplay modes
|
||||
|
||||
./snake-colours
|
||||
# allows for configuring colours
|
||||
./snake-colours
|
||||
# allows for configuring colours
|
||||
```
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ Because all IOCCC entries should have a man page I have included one (even
|
||||
though much of it is what's also above). To render try:
|
||||
|
||||
```sh
|
||||
man ./snake.1
|
||||
man ./snake.1
|
||||
```
|
||||
|
||||
The [COMPILING.html](COMPILING.html) file has a few portability
|
||||
|
||||
+30
-30
@@ -141,7 +141,7 @@ like some of the other features this was not intentionally designed but is
|
||||
simply a fun consequence of the features I did implement.</p>
|
||||
<p>Let’s say you want to verify that the evade mode is at the right count. How
|
||||
can you verify it without modifying the code? Try:</p>
|
||||
<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="va">SIZE</span><span class="op">=</span>0 <span class="va">SHED</span><span class="op">=</span>1 <span class="va">SHEDS</span><span class="op">=</span>1 <span class="va">EVADE</span><span class="op">=</span>10 <span class="ex">./prog</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="va">SIZE</span><span class="op">=</span>0 <span class="va">SHED</span><span class="op">=</span>1 <span class="va">SHEDS</span><span class="op">=</span>1 <span class="va">EVADE</span><span class="op">=</span>10 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>Since you start out at size 0 and you shed every movement then when you’re
|
||||
size 10 (as long as you don’t eat a bug of course!) the bug should evade.</p>
|
||||
<p>If you set it to <code>SIZE=10</code> there would be a difference of 10. Now every
|
||||
@@ -154,7 +154,7 @@ don’t at this time remember any I might have done.</p>
|
||||
<h1 id="the-snake-doesnt-seem-to-be-moving"><a name="stillsnake" href="#toc">The snake doesn’t seem to be moving</a></h1>
|
||||
<p>One way to show this is in full is to set the initial size and growth size to a
|
||||
high value; then try each one individually. For example:</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="va">SIZE</span><span class="op">=</span>100 <span class="ex">./prog</span></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="va">SIZE</span><span class="op">=</span>100 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>In this case after you make the first move the snake will keep growing and
|
||||
so the snake tail stays in the same spot until after it’s the ‘full size’.
|
||||
When it has reached the full size then the entire body of the snake will
|
||||
@@ -199,26 +199,26 @@ show as a gameplay mode); and < 0 it will ‘shrink’ as I explained above.
|
||||
say that it’s defying physics by growing and shrinking simultaneously but either
|
||||
way negative size will force a win.</p>
|
||||
<p>Here’s a fun output:</p>
|
||||
<pre><code>< <<<+</code></pre>
|
||||
<pre><code> < <<<+</code></pre>
|
||||
<p>That’s from:</p>
|
||||
<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="va">SHED</span><span class="op">=</span>1 <span class="va">SHEDS</span><span class="op">=</span>-1 <span class="ex">./prog</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="va">SHED</span><span class="op">=</span>1 <span class="va">SHEDS</span><span class="op">=</span>-1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>And right after that you would see:</p>
|
||||
<pre><code>YOU WIN!
|
||||
X:72/156 Y:20/41 S:997/997 B:0</code></pre>
|
||||
<pre><code> YOU WIN!
|
||||
X:72/156 Y:20/41 S:997/997 B:0</code></pre>
|
||||
<p>Try this though:</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="va">SHEDS</span><span class="op">=</span>-1 <span class="va">SHED</span><span class="op">=</span>25 <span class="ex">./prog</span></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="va">SHEDS</span><span class="op">=</span>-1 <span class="va">SHED</span><span class="op">=</span>25 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>And you’ll see that you start to be the normal size but then you leave your
|
||||
head several places until you end up getting to the max size (by way of it
|
||||
being unsigned). This isn’t a bug even if it might seem like one. In fact
|
||||
this is the basis of the grow/shrink mode of play that I talk about in the
|
||||
<a href="gameplay.html">gameplay.html</a> (<a href="gameplay.md">gameplay.md</a> on GitHub) file.</p>
|
||||
<p>Here’s another thing to be aware of. Let’s say you do:</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="va">SIZE</span><span class="op">=</span>1 <span class="va">GROW</span><span class="op">=</span>-1 <span class="ex">./prog</span></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="va">SIZE</span><span class="op">=</span>1 <span class="va">GROW</span><span class="op">=</span>-1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>How many bugs will it take before you win? In fact it’s two: you would see the
|
||||
head twice: the second time once you ‘shrink’ down to size 0; it would then be
|
||||
that if you get another bug you will be at the ‘max size’:</p>
|
||||
<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="ex">YOU</span> WIN!</span>
|
||||
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="ex">X:81/156</span> Y:35/41 S:997/997 B:2</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="ex">YOU</span> WIN!</span>
|
||||
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">X:81/156</span> Y:35/41 S:997/997 B:2</span></code></pre></div>
|
||||
<h1 id="i-was-a-few-places-behind-my-tail-and-i-ran-into-it"><a name="bitetail" href="#toc">‘I was a few places behind my tail and I ran into it!’</a></h1>
|
||||
<p>I.e. what happens if you’re growing - for example after just eating a bug - and
|
||||
you’re racing towards your tail? If you’re behind it should be fine since you’re
|
||||
@@ -231,15 +231,15 @@ me and I figured I better note it.</p>
|
||||
<p>For instance it might look like this (the first line is as it happens, the
|
||||
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>
|
||||
<pre><code> ooooooooo>ooo>
|
||||
^
|
||||
></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>
|
||||
<pre><code><ooo<ooooo
|
||||
^^^
|
||||
<oo</code></pre>
|
||||
<pre><code> <ooo<ooooo
|
||||
^^^
|
||||
<oo</code></pre>
|
||||
<p>If you go through the part that has split (which for some might be difficult
|
||||
to see whilst the snake has not fully left its skin) you won’t run into
|
||||
yourself; if you run into another part though you do. This might be a bit
|
||||
@@ -257,7 +257,7 @@ of the screen the snake is occupying is the place which is actually moving: if
|
||||
the snake decreases in size by 3 then the three respective characters you can go
|
||||
through safely. But this also means that a bug can go there! So you might see
|
||||
something like:</p>
|
||||
<pre><code><*oooooooo</code></pre>
|
||||
<pre><code> <*oooooooo</code></pre>
|
||||
<p>This is because the snake is no longer there: in fact in this run the snake was
|
||||
quite a bit lower on the screen and 25 in length.</p>
|
||||
<h1 id="on-the-safety-of-the-bug-placement-loop"><a name="bugplacement" href="#toc">On the safety of the bug placement loop</a></h1>
|
||||
@@ -271,23 +271,23 @@ how it’s done in Snake and works well). The minimum terminal size I require in
|
||||
the game is 10 x 10. This includes the walls and score line.</p>
|
||||
<p>Now the default max snake size is 997 but when the terminal is too small it
|
||||
adjusts the max snake size. For 10 lines and 10 columns you would see:</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">$</span> make test</span>
|
||||
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> supports cursor movement</span>
|
||||
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> supports making cursor invisible</span>
|
||||
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> supports bold</span>
|
||||
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> supports colours</span>
|
||||
<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">$</span> make test</span>
|
||||
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">terminal</span> supports cursor movement</span>
|
||||
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">terminal</span> supports making cursor invisible</span>
|
||||
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">terminal</span> supports bold</span>
|
||||
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">terminal</span> supports colours</span>
|
||||
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> rows 10 <span class="er">(</span><span class="ex">7</span> playable<span class="kw">)</span></span>
|
||||
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> cols 10 <span class="er">(</span><span class="ex">8</span> playable<span class="kw">)</span></span>
|
||||
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">terminal</span> rows 10 <span class="er">(</span><span class="ex">7</span> playable<span class="kw">)</span></span>
|
||||
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">terminal</span> cols 10 <span class="er">(</span><span class="ex">8</span> playable<span class="kw">)</span></span>
|
||||
<span id="cb12-9"><a href="#cb12-9" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb12-10"><a href="#cb12-10" aria-hidden="true" tabindex="-1"></a><span class="ex">snake</span> size: 49 <span class="er">(</span><span class="ex">max</span> size: 49<span class="kw">)</span></span>
|
||||
<span id="cb12-11"><a href="#cb12-11" aria-hidden="true" tabindex="-1"></a> <span class="ex">bugs:</span> 9 <span class="er">(</span><span class="ex">max</span> size: 9<span class="kw">)</span></span>
|
||||
<span id="cb12-10"><a href="#cb12-10" aria-hidden="true" tabindex="-1"></a> <span class="ex">snake</span> size: 49 <span class="er">(</span><span class="ex">max</span> size: 49<span class="kw">)</span></span>
|
||||
<span id="cb12-11"><a href="#cb12-11" aria-hidden="true" tabindex="-1"></a> <span class="ex">bugs:</span> 9 <span class="er">(</span><span class="ex">max</span> size: 9<span class="kw">)</span></span>
|
||||
<span id="cb12-12"><a href="#cb12-12" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb12-13"><a href="#cb12-13" aria-hidden="true" tabindex="-1"></a><span class="ex">at</span> least 28 columns recommended for snake size 49 <span class="er">(</span><span class="ex">is</span> 10<span class="kw">)</span></span>
|
||||
<span id="cb12-14"><a href="#cb12-14" aria-hidden="true" tabindex="-1"></a><span class="ex">at</span> least 28 columns recommended for snake size 49 <span class="er">(</span><span class="ex">is</span> 10<span class="kw">)</span></span>
|
||||
<span id="cb12-13"><a href="#cb12-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">at</span> least 28 columns recommended for snake size 49 <span class="er">(</span><span class="ex">is</span> 10<span class="kw">)</span></span>
|
||||
<span id="cb12-14"><a href="#cb12-14" aria-hidden="true" tabindex="-1"></a> <span class="ex">at</span> least 28 columns recommended for snake size 49 <span class="er">(</span><span class="ex">is</span> 10<span class="kw">)</span></span>
|
||||
<span id="cb12-15"><a href="#cb12-15" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb12-16"><a href="#cb12-16" aria-hidden="true" tabindex="-1"></a><span class="ex">1</span> problem detected <span class="er">(</span><span class="ex">0</span> fatal<span class="kw">)</span><span class="bu">.</span></span>
|
||||
<span id="cb12-17"><a href="#cb12-17" aria-hidden="true" tabindex="-1"></a><span class="ex">make:</span> <span class="pp">***</span> <span class="pp">[</span><span class="ss">test</span><span class="pp">]</span> Error 1</span></code></pre></div>
|
||||
<span id="cb12-16"><a href="#cb12-16" aria-hidden="true" tabindex="-1"></a> <span class="ex">1</span> problem detected <span class="er">(</span><span class="ex">0</span> fatal<span class="kw">)</span><span class="bu">.</span></span>
|
||||
<span id="cb12-17"><a href="#cb12-17" aria-hidden="true" tabindex="-1"></a> <span class="ex">make:</span> <span class="pp">***</span> <span class="pp">[</span><span class="ss">test</span><span class="pp">]</span> Error 1</span></code></pre></div>
|
||||
<p>First: what’s the problem? It’s just a warning that for the snake size of 49 the
|
||||
recommended size of columns is 28. However this is just for the score text; with
|
||||
only 10 columns it will overflow and wrap to the next line(s). But if you observe
|
||||
|
||||
+30
-31
@@ -23,7 +23,7 @@ Let's say you want to verify that the evade mode is at the right count. How
|
||||
can you verify it without modifying the code? Try:
|
||||
|
||||
```sh
|
||||
SIZE=0 SHED=1 SHEDS=1 EVADE=10 ./prog
|
||||
SIZE=0 SHED=1 SHEDS=1 EVADE=10 ./prog
|
||||
```
|
||||
|
||||
Since you start out at size 0 and you shed every movement then when you're
|
||||
@@ -45,7 +45,7 @@ One way to show this is in full is to set the initial size and growth size to a
|
||||
high value; then try each one individually. For example:
|
||||
|
||||
```sh
|
||||
SIZE=100 ./prog
|
||||
SIZE=100 ./prog
|
||||
```
|
||||
|
||||
In this case after you make the first move the snake will keep growing and
|
||||
@@ -108,26 +108,26 @@ way negative size will force a win.
|
||||
Here's a fun output:
|
||||
|
||||
```
|
||||
< <<<+
|
||||
< <<<+
|
||||
```
|
||||
|
||||
That's from:
|
||||
|
||||
```sh
|
||||
SHED=1 SHEDS=-1 ./prog
|
||||
SHED=1 SHEDS=-1 ./prog
|
||||
```
|
||||
|
||||
And right after that you would see:
|
||||
|
||||
```
|
||||
YOU WIN!
|
||||
X:72/156 Y:20/41 S:997/997 B:0
|
||||
YOU WIN!
|
||||
X:72/156 Y:20/41 S:997/997 B:0
|
||||
```
|
||||
|
||||
Try this though:
|
||||
|
||||
```sh
|
||||
SHEDS=-1 SHED=25 ./prog
|
||||
SHEDS=-1 SHED=25 ./prog
|
||||
```
|
||||
|
||||
And you'll see that you start to be the normal size but then you leave your
|
||||
@@ -139,7 +139,7 @@ this is the basis of the grow/shrink mode of play that I talk about in the
|
||||
Here's another thing to be aware of. Let's say you do:
|
||||
|
||||
```sh
|
||||
SIZE=1 GROW=-1 ./prog
|
||||
SIZE=1 GROW=-1 ./prog
|
||||
```
|
||||
|
||||
How many bugs will it take before you win? In fact it's two: you would see the
|
||||
@@ -147,8 +147,8 @@ head twice: the second time once you 'shrink' down to size 0; it would then be
|
||||
that if you get another bug you will be at the 'max size':
|
||||
|
||||
```sh
|
||||
YOU WIN!
|
||||
X:81/156 Y:35/41 S:997/997 B:2
|
||||
YOU WIN!
|
||||
X:81/156 Y:35/41 S:997/997 B:2
|
||||
```
|
||||
|
||||
# <a name="bitetail" href="#toc">'I was a few places behind my tail and I ran into it!'</a>
|
||||
@@ -170,9 +170,9 @@ second pointing to where it happens and the third being what's left after the
|
||||
rest of the snake has gone through). Doing `SHED=100 SHEDS=-1`:
|
||||
|
||||
```
|
||||
ooooooooo>ooo>
|
||||
^
|
||||
>
|
||||
ooooooooo>ooo>
|
||||
^
|
||||
>
|
||||
```
|
||||
|
||||
The `^` points to the part that's split from the snake and which will be
|
||||
@@ -180,9 +180,9 @@ there on its own after the snake passes through it. Here's an example with
|
||||
it being `SHEDS=-3`:
|
||||
|
||||
```
|
||||
<ooo<ooooo
|
||||
^^^
|
||||
<oo
|
||||
<ooo<ooooo
|
||||
^^^
|
||||
<oo
|
||||
```
|
||||
|
||||
If you go through the part that has split (which for some might be difficult
|
||||
@@ -207,7 +207,7 @@ through safely. But this also means that a bug can go there! So you might see
|
||||
something like:
|
||||
|
||||
```
|
||||
<*oooooooo
|
||||
<*oooooooo
|
||||
```
|
||||
|
||||
This is because the snake is no longer there: in fact in this run the snake was
|
||||
@@ -229,23 +229,23 @@ Now the default max snake size is 997 but when the terminal is too small it
|
||||
adjusts the max snake size. For 10 lines and 10 columns you would see:
|
||||
|
||||
```sh
|
||||
$ make test
|
||||
terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
terminal supports bold
|
||||
terminal supports colours
|
||||
$ make test
|
||||
terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
terminal supports bold
|
||||
terminal supports colours
|
||||
|
||||
terminal rows 10 (7 playable)
|
||||
terminal cols 10 (8 playable)
|
||||
terminal rows 10 (7 playable)
|
||||
terminal cols 10 (8 playable)
|
||||
|
||||
snake size: 49 (max size: 49)
|
||||
bugs: 9 (max size: 9)
|
||||
snake size: 49 (max size: 49)
|
||||
bugs: 9 (max size: 9)
|
||||
|
||||
at least 28 columns recommended for snake size 49 (is 10)
|
||||
at least 28 columns recommended for snake size 49 (is 10)
|
||||
at least 28 columns recommended for snake size 49 (is 10)
|
||||
at least 28 columns recommended for snake size 49 (is 10)
|
||||
|
||||
1 problem detected (0 fatal).
|
||||
make: *** [test] Error 1
|
||||
1 problem detected (0 fatal).
|
||||
make: *** [test] Error 1
|
||||
```
|
||||
|
||||
First: what's the problem? It's just a warning that for the snake size of 49 the
|
||||
@@ -309,7 +309,6 @@ with it and providing the resources! Much appreciated! (And although you
|
||||
suggested it is bugging me I once again here say it's not at all bugging me
|
||||
but it is very much appreciated and it means a great deal to me. Cheers.)
|
||||
|
||||
|
||||
[crazy.log.md]: crazy.log.md
|
||||
[gameplay.md]: gameplay.md
|
||||
[troubleshooting.md]: troubleshooting.md
|
||||
|
||||
+157
-157
@@ -137,171 +137,171 @@ right to make it easier to find.</p>
|
||||
<p>The first run I include several dumps but there isn’t much information about
|
||||
most of them.</p>
|
||||
<h2 id="example-0-snake-moving-right">Example 0: snake moving right</h2>
|
||||
<pre><code>X:45/89 Y:22/25 S:1675/2001 B:35
|
||||
##########################################################################################
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
# o o o o o oooo o #
|
||||
# oooooooooo o o o o ooo ooooooooo oooo #
|
||||
# o ooooooooooooooooooooooooo o o o o o #
|
||||
# o ooooooooooo ooooooooooooooooooooooo oooooooooooooooo o o o #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o o oo#
|
||||
# o o ooooooooooooooooooooooooooooooooooooooo o o oBo o oooo o # <- *BUG*
|
||||
# o o o ooooooooooooooooooooooooooooooooooooooo o o o o o o #
|
||||
# o o o o o ooo o o oo oooooooooooooooooooooooo o #
|
||||
# o ooooooooooooooooo oooooooo o o oooooooooooo ooooooooooooooooooooooooo o #
|
||||
# o o o o oooooo o o o o o oooooooooooooooooooooooo o o o o o #
|
||||
#oooooooooooooooooo o o o o oo o o o o o oo oo o oo o o oooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooo oo o o oo o o o #
|
||||
# o o ooooooooooooooooooooooooooooooooooooooooooooooooo o oo o o o #
|
||||
#oooooooooo oooo o o o o o o o o oo o oooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo o o o ooooooooo o oo o o o o o o ooooooooooooo #
|
||||
# ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o #
|
||||
#oooooo o oooooo o o o o o o o ooooooooooooooooooooooooo o ooooooo#
|
||||
# o o o o o o oooo ooooooooooooooooo o o o o o #
|
||||
# o o oo o o o oooooH o oooooooo ooooo o # <- *HEAD, RIGHT*
|
||||
#ooooooooo ooooooooooooooooooooo ooooooooooo ooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
##########################################################################################</code></pre>
|
||||
<pre><code> X:45/89 Y:22/25 S:1675/2001 B:35
|
||||
##########################################################################################
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
# o o o o o oooo o #
|
||||
# oooooooooo o o o o ooo ooooooooo oooo #
|
||||
# o ooooooooooooooooooooooooo o o o o o #
|
||||
# o ooooooooooo ooooooooooooooooooooooo oooooooooooooooo o o o #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o o oo#
|
||||
# o o ooooooooooooooooooooooooooooooooooooooo o o oBo o oooo o # <- *BUG*
|
||||
# o o o ooooooooooooooooooooooooooooooooooooooo o o o o o o #
|
||||
# o o o o o ooo o o oo oooooooooooooooooooooooo o #
|
||||
# o ooooooooooooooooo oooooooo o o oooooooooooo ooooooooooooooooooooooooo o #
|
||||
# o o o o oooooo o o o o o oooooooooooooooooooooooo o o o o o #
|
||||
#oooooooooooooooooo o o o o oo o o o o o oo oo o oo o o oooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooo oo o o oo o o o #
|
||||
# o o ooooooooooooooooooooooooooooooooooooooooooooooooo o oo o o o #
|
||||
#oooooooooo oooo o o o o o o o o oo o oooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo o o o ooooooooo o oo o o o o o o ooooooooooooo #
|
||||
# ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o #
|
||||
#oooooo o oooooo o o o o o o o ooooooooooooooooooooooooo o ooooooo#
|
||||
# o o o o o o oooo ooooooooooooooooo o o o o o #
|
||||
# o o oo o o o oooooH o oooooooo ooooo o # <- *HEAD, RIGHT*
|
||||
#ooooooooo ooooooooooooooooooooo ooooooooooo ooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
##########################################################################################</code></pre>
|
||||
<h2 id="example-1-snake-moving-right">Example 1: snake moving right</h2>
|
||||
<pre><code>X:79/89 Y:9/25 S:1680/2001 B:36
|
||||
##########################################################################################
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
# o o o o o oooo o #
|
||||
# oooooooooo o o o o ooo ooooooooo oooo #
|
||||
# o ooooooooooooooooooooooooo o o o o o #
|
||||
# o ooooooooooo ooooooooooooooooooooooo oooooooooooooooo o o o #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o o oo#
|
||||
# o o oooooooooooooooooooooooo oo o o oooooooooooooooooooH o # <- *HEAD, RIGHT*
|
||||
# o o o oooooooooooooooooooooooooooooooooooooooooo o o o o o #
|
||||
# o o o o o o o o o oo o oooooooooooooooooooooooo o #
|
||||
# o ooooooooooooooooo o o o o oooooooooooo ooooooooooooooooooooooooo o #
|
||||
# o o o o oooooo o o o o oooooooooooooooooooooooo o o o o o #
|
||||
#oooooooooooooooooo o o o oo o o o o o ooo oo o oo o o oooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooo oo Bo o oo o o o # <- *BUG*
|
||||
# o o ooooooooooooooooooooooooooooooooooooooooooooooooo o oo o o o #
|
||||
#oooooooooo oooo o o o o o o o ooo o oooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo o o ooooooooo o ooo o o o o o o ooooooooooooo #
|
||||
# ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o #
|
||||
#oooooo o oooooo o o o o o o o ooooooooooooooooooooooooo o ooooooo#
|
||||
# o o o o o oooo ooooooooooooooooo o o o o o #
|
||||
# o o o o o oooooo o oooooooo ooooo o #
|
||||
#ooooooooo ooooooooooooooooooooo ooooooooooo ooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
##########################################################################################</code></pre>
|
||||
<pre><code> X:79/89 Y:9/25 S:1680/2001 B:36
|
||||
##########################################################################################
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
# o o o o o oooo o #
|
||||
# oooooooooo o o o o ooo ooooooooo oooo #
|
||||
# o ooooooooooooooooooooooooo o o o o o #
|
||||
# o ooooooooooo ooooooooooooooooooooooo oooooooooooooooo o o o #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o o oo#
|
||||
# o o oooooooooooooooooooooooo oo o o oooooooooooooooooooH o # <- *HEAD, RIGHT*
|
||||
# o o o oooooooooooooooooooooooooooooooooooooooooo o o o o o #
|
||||
# o o o o o o o o o oo o oooooooooooooooooooooooo o #
|
||||
# o ooooooooooooooooo o o o o oooooooooooo ooooooooooooooooooooooooo o #
|
||||
# o o o o oooooo o o o o oooooooooooooooooooooooo o o o o o #
|
||||
#oooooooooooooooooo o o o oo o o o o o ooo oo o oo o o oooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooo oo Bo o oo o o o # <- *BUG*
|
||||
# o o ooooooooooooooooooooooooooooooooooooooooooooooooo o oo o o o #
|
||||
#oooooooooo oooo o o o o o o o ooo o oooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo o o ooooooooo o ooo o o o o o o ooooooooooooo #
|
||||
# ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o #
|
||||
#oooooo o oooooo o o o o o o o ooooooooooooooooooooooooo o ooooooo#
|
||||
# o o o o o oooo ooooooooooooooooo o o o o o #
|
||||
# o o o o o oooooo o oooooooo ooooo o #
|
||||
#ooooooooo ooooooooooooooooooooo ooooooooooo ooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
##########################################################################################</code></pre>
|
||||
<h2 id="example-2-snake-moving-left">Example 2: snake moving left</h2>
|
||||
<pre><code>X:53/89 Y:18/25 S:1690/2001 B:38
|
||||
##########################################################################################
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
# o o o o o oooo o #
|
||||
# oooooooooo o o o o ooo ooooooooo oooo #
|
||||
# o ooooooooooooooooooooooooo o o o o o #
|
||||
# o ooooooooooo ooooooooooooooooo o oooooooooooooooo o o o #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o o oo#
|
||||
# o B o oooooooooooooooooooooooo o o o oooooooooooooooooooo o # <- *BUG*
|
||||
# o o o oooooooooooooooooooooooooooooooooooooooooo o o o o o o #
|
||||
# o o o o o o o o o o o oooooooooooooooooooooooo o o #
|
||||
# o ooooooooooooooooo o o o o oooooooooo o ooooooooooooooooooooooooo o #
|
||||
# o o o o oooooo o o o o oooooooooooooooooooooooo o o o o o o #
|
||||
#oooooooooooooooooo o o o oo o o o o o o o o o oo oooooooooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooo oo oo o oo o o o #
|
||||
# o o ooooooooooooooooooooooooooooooooooooooooooooooooo o oo o o o #
|
||||
#oooooooooo oooo o o o o o o o o o o ooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo o o ooooooooo o o o o Hooooooooooo o ooooooooooooo # <- *HEAD, LEFT*
|
||||
# ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o #
|
||||
#oooooo o oooooo o o o o o o o ooooooooooooooooooooooooo o ooooooo#
|
||||
# o o o o o oooo ooooooooooooooooo o o o o o #
|
||||
# o o o o o oooooo o oooooooo ooooo o #
|
||||
#ooooooooo ooooooooooooooooooooo ooooooooooo ooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
##########################################################################################</code></pre>
|
||||
<pre><code> X:53/89 Y:18/25 S:1690/2001 B:38
|
||||
##########################################################################################
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
# o o o o o oooo o #
|
||||
# oooooooooo o o o o ooo ooooooooo oooo #
|
||||
# o ooooooooooooooooooooooooo o o o o o #
|
||||
# o ooooooooooo ooooooooooooooooo o oooooooooooooooo o o o #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o o oo#
|
||||
# o B o oooooooooooooooooooooooo o o o oooooooooooooooooooo o # <- *BUG*
|
||||
# o o o oooooooooooooooooooooooooooooooooooooooooo o o o o o o #
|
||||
# o o o o o o o o o o o oooooooooooooooooooooooo o o #
|
||||
# o ooooooooooooooooo o o o o oooooooooo o ooooooooooooooooooooooooo o #
|
||||
# o o o o oooooo o o o o oooooooooooooooooooooooo o o o o o o #
|
||||
#oooooooooooooooooo o o o oo o o o o o o o o o oo oooooooooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooo oo oo o oo o o o #
|
||||
# o o ooooooooooooooooooooooooooooooooooooooooooooooooo o oo o o o #
|
||||
#oooooooooo oooo o o o o o o o o o o ooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo o o ooooooooo o o o o Hooooooooooo o ooooooooooooo # <- *HEAD, LEFT*
|
||||
# ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o #
|
||||
#oooooo o oooooo o o o o o o o ooooooooooooooooooooooooo o ooooooo#
|
||||
# o o o o o oooo ooooooooooooooooo o o o o o #
|
||||
# o o o o o oooooo o oooooooo ooooo o #
|
||||
#ooooooooo ooooooooooooooooooooo ooooooooooo ooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
##########################################################################################</code></pre>
|
||||
<h2 id="example-3-snake-moving-left">Example 3: snake moving left</h2>
|
||||
<pre><code>X:61/89 Y:6/25 S:1815/2001 B:63
|
||||
##########################################################################################
|
||||
# oooooooooooooooooooooooooooooooooT # <- *TAIL*
|
||||
# o #
|
||||
# ooooo o ooooooooooo #
|
||||
# oooooooooo o o B ooooooooooooooooooooo # <- *BUG*
|
||||
#oooooo o oooooooooooooooooooooooooooooooo Hooooooooooooooooooooooooooo# <- *HEAD, LEFT
|
||||
# o ooooooooooooooooooooooo o oooo o o o o ooo #
|
||||
# o o oooo oooooooooooooooooooooooooooooooo o ooooooooooooooooooo ooo #
|
||||
# o ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ooo #
|
||||
# o o o o oooooooooooooooooooooooooooooooooooooooooooooo o o o o ooo #
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooooooooooooooooooooo #
|
||||
#ooooooooooooooooooooooo o oooooooooo o ooooooooooooooooooooooooooooooo#
|
||||
# o o o o oooooo o ooooooooooooooooooooooooooooooooooooooooooo #
|
||||
#oooooooooooooooooo o o o oo o o o ooooo o o oooooooooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oo oo #
|
||||
# o o oooooooooooooooooooooooooooooooooooooooooooooooooo oo o ooooooooooo #
|
||||
#oooooooooo oooo oooooooooooooo o o ooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo oo ooooooooo o oooooooooooooo o ooooooooooooooooo #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooo#
|
||||
#oooooo ooooooooooooooooooooooooooooooooooooooooo o ooo ooooooo#
|
||||
# oo o oooo oooo o o oooooo o #
|
||||
# ooooooooooooooooo ooooooooooooooooooo oooooooooooooooooooo o #
|
||||
#ooooooooo ooooooooooooooooooooooooooooooooooooooooooooo ooooooo#
|
||||
# #
|
||||
##########################################################################################</code></pre>
|
||||
<pre><code> X:61/89 Y:6/25 S:1815/2001 B:63
|
||||
##########################################################################################
|
||||
# oooooooooooooooooooooooooooooooooT # <- *TAIL*
|
||||
# o #
|
||||
# ooooo o ooooooooooo #
|
||||
# oooooooooo o o B ooooooooooooooooooooo # <- *BUG*
|
||||
#oooooo o oooooooooooooooooooooooooooooooo Hooooooooooooooooooooooooooo# <- *HEAD, LEFT
|
||||
# o ooooooooooooooooooooooo o oooo o o o o ooo #
|
||||
# o o oooo oooooooooooooooooooooooooooooooo o ooooooooooooooooooo ooo #
|
||||
# o ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ooo #
|
||||
# o o o o oooooooooooooooooooooooooooooooooooooooooooooo o o o o ooo #
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooooooooooooooooooooo #
|
||||
#ooooooooooooooooooooooo o oooooooooo o ooooooooooooooooooooooooooooooo#
|
||||
# o o o o oooooo o ooooooooooooooooooooooooooooooooooooooooooo #
|
||||
#oooooooooooooooooo o o o oo o o o ooooo o o oooooooooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oo oo #
|
||||
# o o oooooooooooooooooooooooooooooooooooooooooooooooooo oo o ooooooooooo #
|
||||
#oooooooooo oooo oooooooooooooo o o ooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo oo ooooooooo o oooooooooooooo o ooooooooooooooooo #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooo#
|
||||
#oooooo ooooooooooooooooooooooooooooooooooooooooo o ooo ooooooo#
|
||||
# oo o oooo oooo o o oooooo o #
|
||||
# ooooooooooooooooo ooooooooooooooooooo oooooooooooooooooooo o #
|
||||
#ooooooooo ooooooooooooooooooooooooooooooooooooooooooooo ooooooo#
|
||||
# #
|
||||
##########################################################################################</code></pre>
|
||||
<h2 id="example-4-snake-moving-left">Example 4: snake moving left</h2>
|
||||
<pre><code>X:47/89 Y:5/25 S:1815/2001 B:63
|
||||
##########################################################################################
|
||||
# ooooooooooooooooT # <- *TAIL*
|
||||
# o #
|
||||
# ooooo o ooooooooooo oooo # <- *HEAD, LEFT*
|
||||
# oooooooooo o o BHooo o ooooooooooooooooooooo # <- *BUG*
|
||||
#oooooo o oooooooooooooooooooooooooooooooo oooooooooooooooooooooooooooooooooooo#
|
||||
# o ooooooooooooooooooooooo o oooo o o o o ooo #
|
||||
# o o oooo oooooooooooooooooooooooooooooooo o ooooooooooooooooooo ooo #
|
||||
# o ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ooo #
|
||||
# o o o o oooooooooooooooooooooooooooooooooooooooooooooo o o o o ooo #
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooooooooooooooooooooo #
|
||||
#ooooooooooooooooooooooo o oooooooooo o ooooooooooooooooooooooooooooooo#
|
||||
# o o o o oooooo o ooooooooooooooooooooooooooooooooooooooooooo #
|
||||
#oooooooooooooooooo o o o oo o o o ooooo o o oooooooooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oo oo #
|
||||
# o o oooooooooooooooooooooooooooooooooooooooooooooooooo oo o ooooooooooo #
|
||||
#oooooooooo oooo oooooooooooooo o o ooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo oo ooooooooo o oooooooooooooo o ooooooooooooooooo #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooo#
|
||||
#oooooo ooooooooooooooooooooooooooooooooooooooooo o ooo ooooooo#
|
||||
# oo o oooo oooo o o oooooo o #
|
||||
# ooooooooooooooooo ooooooooooooooooooo oooooooooooooooooooo o #
|
||||
#ooooooooo ooooooooooooooooooooooooooooooooooooooooooooo ooooooo#
|
||||
# #
|
||||
##########################################################################################</code></pre>
|
||||
<pre><code> X:47/89 Y:5/25 S:1815/2001 B:63
|
||||
##########################################################################################
|
||||
# ooooooooooooooooT # <- *TAIL*
|
||||
# o #
|
||||
# ooooo o ooooooooooo oooo # <- *HEAD, LEFT*
|
||||
# oooooooooo o o BHooo o ooooooooooooooooooooo # <- *BUG*
|
||||
#oooooo o oooooooooooooooooooooooooooooooo oooooooooooooooooooooooooooooooooooo#
|
||||
# o ooooooooooooooooooooooo o oooo o o o o ooo #
|
||||
# o o oooo oooooooooooooooooooooooooooooooo o ooooooooooooooooooo ooo #
|
||||
# o ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ooo #
|
||||
# o o o o oooooooooooooooooooooooooooooooooooooooooooooo o o o o ooo #
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooooooooooooooooooooo #
|
||||
#ooooooooooooooooooooooo o oooooooooo o ooooooooooooooooooooooooooooooo#
|
||||
# o o o o oooooo o ooooooooooooooooooooooooooooooooooooooooooo #
|
||||
#oooooooooooooooooo o o o oo o o o ooooo o o oooooooooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oo oo #
|
||||
# o o oooooooooooooooooooooooooooooooooooooooooooooooooo oo o ooooooooooo #
|
||||
#oooooooooo oooo oooooooooooooo o o ooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo oo ooooooooo o oooooooooooooo o ooooooooooooooooo #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooo#
|
||||
#oooooo ooooooooooooooooooooooooooooooooooooooooo o ooo ooooooo#
|
||||
# oo o oooo oooo o o oooooo o #
|
||||
# ooooooooooooooooo ooooooooooooooooooo oooooooooooooooooooo o #
|
||||
#ooooooooo ooooooooooooooooooooooooooooooooooooooooooooo ooooooo#
|
||||
# #
|
||||
##########################################################################################</code></pre>
|
||||
<h2 id="example-5-snake-moving-left-with-snake-inside-itsself">Example 5: snake moving left with snake inside itsself</h2>
|
||||
<p>Another example invocation where the snake head is in the snake and where the snake
|
||||
hadn’t yet moved (that is it was still growing):</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="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">SIZE</span><span class="op">=</span>1500 <span class="va">GROW</span><span class="op">=</span>2 <span class="va">MAXSIZE</span><span class="op">=</span>1600 <span class="ex">./prog</span></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="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">SIZE</span><span class="op">=</span>1500 <span class="va">GROW</span><span class="op">=</span>2 <span class="va">MAXSIZE</span><span class="op">=</span>1600 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>It looked like:</p>
|
||||
<pre><code>X:55/89 Y:11/25 S:1564/1600 B:32
|
||||
##########################################################################################
|
||||
# oooo ooooooooooooooooooooooooo o #
|
||||
# o ooooooooooooooooooooooooooooooooooooooooooooo ooooooooooooooooo #
|
||||
#ooo o o o o o oooooo#
|
||||
# o o o oooooooooooooooooooooooooo o #
|
||||
#oooooooooooooooooooooooooo o ooo o oo oooooooooooooooooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
# o o ooooooooooooo oooooooooooooooooooooo ooo oo o o o oo#
|
||||
#ooo o o oooooo o oooo ooo oo o o oooo#
|
||||
# o o o oooo o o oo ooo oooooooooooooooooo oo#
|
||||
# o o o ooooooooooooo oooooooooooooooo oooooHoooooooooooooooooooooooooooooo # <- *HEAD, LEFT*
|
||||
# o o o o ooooooooo oooooooooooooooooooooooooooo o o o o #
|
||||
# o ooooooo o o o oooooooooooooo o o o o o o ooooo #
|
||||
# o o o o o o o o o o o o o #
|
||||
# o o o o o o oB ooooooooooooooooooo o o ooo # <- *BUG*
|
||||
# o o o o o oooooooooooooooooooooooooooooooooooooooooooo o o #
|
||||
# oooooooooooooo o o oo o o oooooooooooooooooooooooooooooooooooooo #
|
||||
# o oo o o oo oooooooooooooo o o o oooooooooooo #
|
||||
#oooooo oo oooooooooooooo o o o o o o ooo oooooo#
|
||||
# ooooo o o o o oooooooooooooooooooooooooooooooo o #
|
||||
# o oooooooooooooo o o o o ooooooooo o o #
|
||||
# o o oooooo o oooooooooooo o o #
|
||||
# oooooooooooooooooooooooooooooooooooooooooooooooooooo ooo o #
|
||||
# ooooooooooo ooooooooooooo o oooooooooo #
|
||||
##########################################################################################</code></pre>
|
||||
<pre><code> X:55/89 Y:11/25 S:1564/1600 B:32
|
||||
##########################################################################################
|
||||
# oooo ooooooooooooooooooooooooo o #
|
||||
# o ooooooooooooooooooooooooooooooooooooooooooooo ooooooooooooooooo #
|
||||
#ooo o o o o o oooooo#
|
||||
# o o o oooooooooooooooooooooooooo o #
|
||||
#oooooooooooooooooooooooooo o ooo o oo oooooooooooooooooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
# o o ooooooooooooo oooooooooooooooooooooo ooo oo o o o oo#
|
||||
#ooo o o oooooo o oooo ooo oo o o oooo#
|
||||
# o o o oooo o o oo ooo oooooooooooooooooo oo#
|
||||
# o o o ooooooooooooo oooooooooooooooo oooooHoooooooooooooooooooooooooooooo # <- *HEAD, LEFT*
|
||||
# o o o o ooooooooo oooooooooooooooooooooooooooo o o o o #
|
||||
# o ooooooo o o o oooooooooooooo o o o o o o ooooo #
|
||||
# o o o o o o o o o o o o o #
|
||||
# o o o o o o oB ooooooooooooooooooo o o ooo # <- *BUG*
|
||||
# o o o o o oooooooooooooooooooooooooooooooooooooooooooo o o #
|
||||
# oooooooooooooo o o oo o o oooooooooooooooooooooooooooooooooooooo #
|
||||
# o oo o o oo oooooooooooooo o o o oooooooooooo #
|
||||
#oooooo oo oooooooooooooo o o o o o o ooo oooooo#
|
||||
# ooooo o o o o oooooooooooooooooooooooooooooooo o #
|
||||
# o oooooooooooooo o o o o ooooooooo o o #
|
||||
# o o oooooo o oooooooooooo o o #
|
||||
# oooooooooooooooooooooooooooooooooooooooooooooooooooo ooo o #
|
||||
# ooooooooooo ooooooooooooo o oooooooooo #
|
||||
##########################################################################################</code></pre>
|
||||
<p>…and no <strong><em>Preciouss</em></strong>: the <em>itsself</em> was not a typo but intentional sibilance!</p>
|
||||
<!--
|
||||
|
||||
|
||||
+165
-159
@@ -5,6 +5,7 @@ to any other version of Snake), this file shows just how extreme cannibalism can
|
||||
get with a long snake. I made a few changes, described below, to make it easier
|
||||
to distinguish what is what.
|
||||
|
||||
|
||||
# Examples
|
||||
|
||||
In the below game dumps I have replaced the bug with **B**, the head with
|
||||
@@ -17,200 +18,205 @@ right to make it easier to find.
|
||||
The first run I include several dumps but there isn't much information about
|
||||
most of them.
|
||||
|
||||
|
||||
## Example 0: snake moving right
|
||||
|
||||
```
|
||||
X:45/89 Y:22/25 S:1675/2001 B:35
|
||||
##########################################################################################
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
# o o o o o oooo o #
|
||||
# oooooooooo o o o o ooo ooooooooo oooo #
|
||||
# o ooooooooooooooooooooooooo o o o o o #
|
||||
# o ooooooooooo ooooooooooooooooooooooo oooooooooooooooo o o o #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o o oo#
|
||||
# o o ooooooooooooooooooooooooooooooooooooooo o o oBo o oooo o # <- *BUG*
|
||||
# o o o ooooooooooooooooooooooooooooooooooooooo o o o o o o #
|
||||
# o o o o o ooo o o oo oooooooooooooooooooooooo o #
|
||||
# o ooooooooooooooooo oooooooo o o oooooooooooo ooooooooooooooooooooooooo o #
|
||||
# o o o o oooooo o o o o o oooooooooooooooooooooooo o o o o o #
|
||||
#oooooooooooooooooo o o o o oo o o o o o oo oo o oo o o oooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooo oo o o oo o o o #
|
||||
# o o ooooooooooooooooooooooooooooooooooooooooooooooooo o oo o o o #
|
||||
#oooooooooo oooo o o o o o o o o oo o oooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo o o o ooooooooo o oo o o o o o o ooooooooooooo #
|
||||
# ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o #
|
||||
#oooooo o oooooo o o o o o o o ooooooooooooooooooooooooo o ooooooo#
|
||||
# o o o o o o oooo ooooooooooooooooo o o o o o #
|
||||
# o o oo o o o oooooH o oooooooo ooooo o # <- *HEAD, RIGHT*
|
||||
#ooooooooo ooooooooooooooooooooo ooooooooooo ooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
##########################################################################################
|
||||
```
|
||||
|
||||
```
|
||||
X:45/89 Y:22/25 S:1675/2001 B:35
|
||||
##########################################################################################
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
# o o o o o oooo o #
|
||||
# oooooooooo o o o o ooo ooooooooo oooo #
|
||||
# o ooooooooooooooooooooooooo o o o o o #
|
||||
# o ooooooooooo ooooooooooooooooooooooo oooooooooooooooo o o o #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o o oo#
|
||||
# o o ooooooooooooooooooooooooooooooooooooooo o o oBo o oooo o # <- *BUG*
|
||||
# o o o ooooooooooooooooooooooooooooooooooooooo o o o o o o #
|
||||
# o o o o o ooo o o oo oooooooooooooooooooooooo o #
|
||||
# o ooooooooooooooooo oooooooo o o oooooooooooo ooooooooooooooooooooooooo o #
|
||||
# o o o o oooooo o o o o o oooooooooooooooooooooooo o o o o o #
|
||||
#oooooooooooooooooo o o o o oo o o o o o oo oo o oo o o oooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooo oo o o oo o o o #
|
||||
# o o ooooooooooooooooooooooooooooooooooooooooooooooooo o oo o o o #
|
||||
#oooooooooo oooo o o o o o o o o oo o oooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo o o o ooooooooo o oo o o o o o o ooooooooooooo #
|
||||
# ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o #
|
||||
#oooooo o oooooo o o o o o o o ooooooooooooooooooooooooo o ooooooo#
|
||||
# o o o o o o oooo ooooooooooooooooo o o o o o #
|
||||
# o o oo o o o oooooH o oooooooo ooooo o # <- *HEAD, RIGHT*
|
||||
#ooooooooo ooooooooooooooooooooo ooooooooooo ooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
##########################################################################################
|
||||
```
|
||||
|
||||
## Example 1: snake moving right
|
||||
|
||||
```
|
||||
X:79/89 Y:9/25 S:1680/2001 B:36
|
||||
##########################################################################################
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
# o o o o o oooo o #
|
||||
# oooooooooo o o o o ooo ooooooooo oooo #
|
||||
# o ooooooooooooooooooooooooo o o o o o #
|
||||
# o ooooooooooo ooooooooooooooooooooooo oooooooooooooooo o o o #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o o oo#
|
||||
# o o oooooooooooooooooooooooo oo o o oooooooooooooooooooH o # <- *HEAD, RIGHT*
|
||||
# o o o oooooooooooooooooooooooooooooooooooooooooo o o o o o #
|
||||
# o o o o o o o o o oo o oooooooooooooooooooooooo o #
|
||||
# o ooooooooooooooooo o o o o oooooooooooo ooooooooooooooooooooooooo o #
|
||||
# o o o o oooooo o o o o oooooooooooooooooooooooo o o o o o #
|
||||
#oooooooooooooooooo o o o oo o o o o o ooo oo o oo o o oooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooo oo Bo o oo o o o # <- *BUG*
|
||||
# o o ooooooooooooooooooooooooooooooooooooooooooooooooo o oo o o o #
|
||||
#oooooooooo oooo o o o o o o o ooo o oooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo o o ooooooooo o ooo o o o o o o ooooooooooooo #
|
||||
# ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o #
|
||||
#oooooo o oooooo o o o o o o o ooooooooooooooooooooooooo o ooooooo#
|
||||
# o o o o o oooo ooooooooooooooooo o o o o o #
|
||||
# o o o o o oooooo o oooooooo ooooo o #
|
||||
#ooooooooo ooooooooooooooooooooo ooooooooooo ooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
##########################################################################################
|
||||
X:79/89 Y:9/25 S:1680/2001 B:36
|
||||
##########################################################################################
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
# o o o o o oooo o #
|
||||
# oooooooooo o o o o ooo ooooooooo oooo #
|
||||
# o ooooooooooooooooooooooooo o o o o o #
|
||||
# o ooooooooooo ooooooooooooooooooooooo oooooooooooooooo o o o #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o o oo#
|
||||
# o o oooooooooooooooooooooooo oo o o oooooooooooooooooooH o # <- *HEAD, RIGHT*
|
||||
# o o o oooooooooooooooooooooooooooooooooooooooooo o o o o o #
|
||||
# o o o o o o o o o oo o oooooooooooooooooooooooo o #
|
||||
# o ooooooooooooooooo o o o o oooooooooooo ooooooooooooooooooooooooo o #
|
||||
# o o o o oooooo o o o o oooooooooooooooooooooooo o o o o o #
|
||||
#oooooooooooooooooo o o o oo o o o o o ooo oo o oo o o oooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooo oo Bo o oo o o o # <- *BUG*
|
||||
# o o ooooooooooooooooooooooooooooooooooooooooooooooooo o oo o o o #
|
||||
#oooooooooo oooo o o o o o o o ooo o oooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo o o ooooooooo o ooo o o o o o o ooooooooooooo #
|
||||
# ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o #
|
||||
#oooooo o oooooo o o o o o o o ooooooooooooooooooooooooo o ooooooo#
|
||||
# o o o o o oooo ooooooooooooooooo o o o o o #
|
||||
# o o o o o oooooo o oooooooo ooooo o #
|
||||
#ooooooooo ooooooooooooooooooooo ooooooooooo ooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
##########################################################################################
|
||||
```
|
||||
|
||||
|
||||
## Example 2: snake moving left
|
||||
|
||||
```
|
||||
X:53/89 Y:18/25 S:1690/2001 B:38
|
||||
##########################################################################################
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
# o o o o o oooo o #
|
||||
# oooooooooo o o o o ooo ooooooooo oooo #
|
||||
# o ooooooooooooooooooooooooo o o o o o #
|
||||
# o ooooooooooo ooooooooooooooooo o oooooooooooooooo o o o #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o o oo#
|
||||
# o B o oooooooooooooooooooooooo o o o oooooooooooooooooooo o # <- *BUG*
|
||||
# o o o oooooooooooooooooooooooooooooooooooooooooo o o o o o o #
|
||||
# o o o o o o o o o o o oooooooooooooooooooooooo o o #
|
||||
# o ooooooooooooooooo o o o o oooooooooo o ooooooooooooooooooooooooo o #
|
||||
# o o o o oooooo o o o o oooooooooooooooooooooooo o o o o o o #
|
||||
#oooooooooooooooooo o o o oo o o o o o o o o o oo oooooooooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooo oo oo o oo o o o #
|
||||
# o o ooooooooooooooooooooooooooooooooooooooooooooooooo o oo o o o #
|
||||
#oooooooooo oooo o o o o o o o o o o ooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo o o ooooooooo o o o o Hooooooooooo o ooooooooooooo # <- *HEAD, LEFT*
|
||||
# ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o #
|
||||
#oooooo o oooooo o o o o o o o ooooooooooooooooooooooooo o ooooooo#
|
||||
# o o o o o oooo ooooooooooooooooo o o o o o #
|
||||
# o o o o o oooooo o oooooooo ooooo o #
|
||||
#ooooooooo ooooooooooooooooooooo ooooooooooo ooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
##########################################################################################
|
||||
X:53/89 Y:18/25 S:1690/2001 B:38
|
||||
##########################################################################################
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
# o o o o o oooo o #
|
||||
# oooooooooo o o o o ooo ooooooooo oooo #
|
||||
# o ooooooooooooooooooooooooo o o o o o #
|
||||
# o ooooooooooo ooooooooooooooooo o oooooooooooooooo o o o #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o o oo#
|
||||
# o B o oooooooooooooooooooooooo o o o oooooooooooooooooooo o # <- *BUG*
|
||||
# o o o oooooooooooooooooooooooooooooooooooooooooo o o o o o o #
|
||||
# o o o o o o o o o o o oooooooooooooooooooooooo o o #
|
||||
# o ooooooooooooooooo o o o o oooooooooo o ooooooooooooooooooooooooo o #
|
||||
# o o o o oooooo o o o o oooooooooooooooooooooooo o o o o o o #
|
||||
#oooooooooooooooooo o o o oo o o o o o o o o o oo oooooooooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooo oo oo o oo o o o #
|
||||
# o o ooooooooooooooooooooooooooooooooooooooooooooooooo o oo o o o #
|
||||
#oooooooooo oooo o o o o o o o o o o ooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo o o ooooooooo o o o o Hooooooooooo o ooooooooooooo # <- *HEAD, LEFT*
|
||||
# ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o #
|
||||
#oooooo o oooooo o o o o o o o ooooooooooooooooooooooooo o ooooooo#
|
||||
# o o o o o oooo ooooooooooooooooo o o o o o #
|
||||
# o o o o o oooooo o oooooooo ooooo o #
|
||||
#ooooooooo ooooooooooooooooooooo ooooooooooo ooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
##########################################################################################
|
||||
```
|
||||
|
||||
|
||||
## Example 3: snake moving left
|
||||
|
||||
```
|
||||
X:61/89 Y:6/25 S:1815/2001 B:63
|
||||
##########################################################################################
|
||||
# oooooooooooooooooooooooooooooooooT # <- *TAIL*
|
||||
# o #
|
||||
# ooooo o ooooooooooo #
|
||||
# oooooooooo o o B ooooooooooooooooooooo # <- *BUG*
|
||||
#oooooo o oooooooooooooooooooooooooooooooo Hooooooooooooooooooooooooooo# <- *HEAD, LEFT
|
||||
# o ooooooooooooooooooooooo o oooo o o o o ooo #
|
||||
# o o oooo oooooooooooooooooooooooooooooooo o ooooooooooooooooooo ooo #
|
||||
# o ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ooo #
|
||||
# o o o o oooooooooooooooooooooooooooooooooooooooooooooo o o o o ooo #
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooooooooooooooooooooo #
|
||||
#ooooooooooooooooooooooo o oooooooooo o ooooooooooooooooooooooooooooooo#
|
||||
# o o o o oooooo o ooooooooooooooooooooooooooooooooooooooooooo #
|
||||
#oooooooooooooooooo o o o oo o o o ooooo o o oooooooooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oo oo #
|
||||
# o o oooooooooooooooooooooooooooooooooooooooooooooooooo oo o ooooooooooo #
|
||||
#oooooooooo oooo oooooooooooooo o o ooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo oo ooooooooo o oooooooooooooo o ooooooooooooooooo #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooo#
|
||||
#oooooo ooooooooooooooooooooooooooooooooooooooooo o ooo ooooooo#
|
||||
# oo o oooo oooo o o oooooo o #
|
||||
# ooooooooooooooooo ooooooooooooooooooo oooooooooooooooooooo o #
|
||||
#ooooooooo ooooooooooooooooooooooooooooooooooooooooooooo ooooooo#
|
||||
# #
|
||||
##########################################################################################
|
||||
X:61/89 Y:6/25 S:1815/2001 B:63
|
||||
##########################################################################################
|
||||
# oooooooooooooooooooooooooooooooooT # <- *TAIL*
|
||||
# o #
|
||||
# ooooo o ooooooooooo #
|
||||
# oooooooooo o o B ooooooooooooooooooooo # <- *BUG*
|
||||
#oooooo o oooooooooooooooooooooooooooooooo Hooooooooooooooooooooooooooo# <- *HEAD, LEFT
|
||||
# o ooooooooooooooooooooooo o oooo o o o o ooo #
|
||||
# o o oooo oooooooooooooooooooooooooooooooo o ooooooooooooooooooo ooo #
|
||||
# o ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ooo #
|
||||
# o o o o oooooooooooooooooooooooooooooooooooooooooooooo o o o o ooo #
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooooooooooooooooooooo #
|
||||
#ooooooooooooooooooooooo o oooooooooo o ooooooooooooooooooooooooooooooo#
|
||||
# o o o o oooooo o ooooooooooooooooooooooooooooooooooooooooooo #
|
||||
#oooooooooooooooooo o o o oo o o o ooooo o o oooooooooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oo oo #
|
||||
# o o oooooooooooooooooooooooooooooooooooooooooooooooooo oo o ooooooooooo #
|
||||
#oooooooooo oooo oooooooooooooo o o ooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo oo ooooooooo o oooooooooooooo o ooooooooooooooooo #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooo#
|
||||
#oooooo ooooooooooooooooooooooooooooooooooooooooo o ooo ooooooo#
|
||||
# oo o oooo oooo o o oooooo o #
|
||||
# ooooooooooooooooo ooooooooooooooooooo oooooooooooooooooooo o #
|
||||
#ooooooooo ooooooooooooooooooooooooooooooooooooooooooooo ooooooo#
|
||||
# #
|
||||
##########################################################################################
|
||||
```
|
||||
|
||||
|
||||
## Example 4: snake moving left
|
||||
|
||||
```
|
||||
X:47/89 Y:5/25 S:1815/2001 B:63
|
||||
##########################################################################################
|
||||
# ooooooooooooooooT # <- *TAIL*
|
||||
# o #
|
||||
# ooooo o ooooooooooo oooo # <- *HEAD, LEFT*
|
||||
# oooooooooo o o BHooo o ooooooooooooooooooooo # <- *BUG*
|
||||
#oooooo o oooooooooooooooooooooooooooooooo oooooooooooooooooooooooooooooooooooo#
|
||||
# o ooooooooooooooooooooooo o oooo o o o o ooo #
|
||||
# o o oooo oooooooooooooooooooooooooooooooo o ooooooooooooooooooo ooo #
|
||||
# o ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ooo #
|
||||
# o o o o oooooooooooooooooooooooooooooooooooooooooooooo o o o o ooo #
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooooooooooooooooooooo #
|
||||
#ooooooooooooooooooooooo o oooooooooo o ooooooooooooooooooooooooooooooo#
|
||||
# o o o o oooooo o ooooooooooooooooooooooooooooooooooooooooooo #
|
||||
#oooooooooooooooooo o o o oo o o o ooooo o o oooooooooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oo oo #
|
||||
# o o oooooooooooooooooooooooooooooooooooooooooooooooooo oo o ooooooooooo #
|
||||
#oooooooooo oooo oooooooooooooo o o ooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo oo ooooooooo o oooooooooooooo o ooooooooooooooooo #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooo#
|
||||
#oooooo ooooooooooooooooooooooooooooooooooooooooo o ooo ooooooo#
|
||||
# oo o oooo oooo o o oooooo o #
|
||||
# ooooooooooooooooo ooooooooooooooooooo oooooooooooooooooooo o #
|
||||
#ooooooooo ooooooooooooooooooooooooooooooooooooooooooooo ooooooo#
|
||||
# #
|
||||
##########################################################################################
|
||||
X:47/89 Y:5/25 S:1815/2001 B:63
|
||||
##########################################################################################
|
||||
# ooooooooooooooooT # <- *TAIL*
|
||||
# o #
|
||||
# ooooo o ooooooooooo oooo # <- *HEAD, LEFT*
|
||||
# oooooooooo o o BHooo o ooooooooooooooooooooo # <- *BUG*
|
||||
#oooooo o oooooooooooooooooooooooooooooooo oooooooooooooooooooooooooooooooooooo#
|
||||
# o ooooooooooooooooooooooo o oooo o o o o ooo #
|
||||
# o o oooo oooooooooooooooooooooooooooooooo o ooooooooooooooooooo ooo #
|
||||
# o ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ooo #
|
||||
# o o o o oooooooooooooooooooooooooooooooooooooooooooooo o o o o ooo #
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooooooooooooooooooooo #
|
||||
#ooooooooooooooooooooooo o oooooooooo o ooooooooooooooooooooooooooooooo#
|
||||
# o o o o oooooo o ooooooooooooooooooooooooooooooooooooooooooo #
|
||||
#oooooooooooooooooo o o o oo o o o ooooo o o oooooooooooooooooooooooooo#
|
||||
# o oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oo oo #
|
||||
# o o oooooooooooooooooooooooooooooooooooooooooooooooooo oo o ooooooooooo #
|
||||
#oooooooooo oooo oooooooooooooo o o ooooooooooooooooo ooooooooooooooooo#
|
||||
# oooooooooooooooo oo ooooooooo o oooooooooooooo o ooooooooooooooooo #
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooo#
|
||||
#oooooo ooooooooooooooooooooooooooooooooooooooooo o ooo ooooooo#
|
||||
# oo o oooo oooo o o oooooo o #
|
||||
# ooooooooooooooooo ooooooooooooooooooo oooooooooooooooooooo o #
|
||||
#ooooooooo ooooooooooooooooooooooooooooooooooooooooooooo ooooooo#
|
||||
# #
|
||||
##########################################################################################
|
||||
```
|
||||
|
||||
|
||||
## Example 5: snake moving left with snake inside itsself
|
||||
|
||||
Another example invocation where the snake head is in the snake and where the snake
|
||||
hadn't yet moved (that is it was still growing):
|
||||
|
||||
```sh
|
||||
CANNIBAL=1 SIZE=1500 GROW=2 MAXSIZE=1600 ./prog
|
||||
CANNIBAL=1 SIZE=1500 GROW=2 MAXSIZE=1600 ./prog
|
||||
```
|
||||
|
||||
It looked like:
|
||||
|
||||
```
|
||||
X:55/89 Y:11/25 S:1564/1600 B:32
|
||||
##########################################################################################
|
||||
# oooo ooooooooooooooooooooooooo o #
|
||||
# o ooooooooooooooooooooooooooooooooooooooooooooo ooooooooooooooooo #
|
||||
#ooo o o o o o oooooo#
|
||||
# o o o oooooooooooooooooooooooooo o #
|
||||
#oooooooooooooooooooooooooo o ooo o oo oooooooooooooooooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
# o o ooooooooooooo oooooooooooooooooooooo ooo oo o o o oo#
|
||||
#ooo o o oooooo o oooo ooo oo o o oooo#
|
||||
# o o o oooo o o oo ooo oooooooooooooooooo oo#
|
||||
# o o o ooooooooooooo oooooooooooooooo oooooHoooooooooooooooooooooooooooooo # <- *HEAD, LEFT*
|
||||
# o o o o ooooooooo oooooooooooooooooooooooooooo o o o o #
|
||||
# o ooooooo o o o oooooooooooooo o o o o o o ooooo #
|
||||
# o o o o o o o o o o o o o #
|
||||
# o o o o o o oB ooooooooooooooooooo o o ooo # <- *BUG*
|
||||
# o o o o o oooooooooooooooooooooooooooooooooooooooooooo o o #
|
||||
# oooooooooooooo o o oo o o oooooooooooooooooooooooooooooooooooooo #
|
||||
# o oo o o oo oooooooooooooo o o o oooooooooooo #
|
||||
#oooooo oo oooooooooooooo o o o o o o ooo oooooo#
|
||||
# ooooo o o o o oooooooooooooooooooooooooooooooo o #
|
||||
# o oooooooooooooo o o o o ooooooooo o o #
|
||||
# o o oooooo o oooooooooooo o o #
|
||||
# oooooooooooooooooooooooooooooooooooooooooooooooooooo ooo o #
|
||||
# ooooooooooo ooooooooooooo o oooooooooo #
|
||||
##########################################################################################
|
||||
X:55/89 Y:11/25 S:1564/1600 B:32
|
||||
##########################################################################################
|
||||
# oooo ooooooooooooooooooooooooo o #
|
||||
# o ooooooooooooooooooooooooooooooooooooooooooooo ooooooooooooooooo #
|
||||
#ooo o o o o o oooooo#
|
||||
# o o o oooooooooooooooooooooooooo o #
|
||||
#oooooooooooooooooooooooooo o ooo o oo oooooooooooooooooooooo#
|
||||
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
|
||||
# o o ooooooooooooo oooooooooooooooooooooo ooo oo o o o oo#
|
||||
#ooo o o oooooo o oooo ooo oo o o oooo#
|
||||
# o o o oooo o o oo ooo oooooooooooooooooo oo#
|
||||
# o o o ooooooooooooo oooooooooooooooo oooooHoooooooooooooooooooooooooooooo # <- *HEAD, LEFT*
|
||||
# o o o o ooooooooo oooooooooooooooooooooooooooo o o o o #
|
||||
# o ooooooo o o o oooooooooooooo o o o o o o ooooo #
|
||||
# o o o o o o o o o o o o o #
|
||||
# o o o o o o oB ooooooooooooooooooo o o ooo # <- *BUG*
|
||||
# o o o o o oooooooooooooooooooooooooooooooooooooooooooo o o #
|
||||
# oooooooooooooo o o oo o o oooooooooooooooooooooooooooooooooooooo #
|
||||
# o oo o o oo oooooooooooooo o o o oooooooooooo #
|
||||
#oooooo oo oooooooooooooo o o o o o o ooo oooooo#
|
||||
# ooooo o o o o oooooooooooooooooooooooooooooooo o #
|
||||
# o oooooooooooooo o o o o ooooooooo o o #
|
||||
# o o oooooo o oooooooooooo o o #
|
||||
# oooooooooooooooooooooooooooooooooooooooooooooooooooo ooo o #
|
||||
# ooooooooooo ooooooooooooo o oooooooooo #
|
||||
##########################################################################################
|
||||
```
|
||||
|
||||
...and no **_Preciouss_**: the _itsself_ was not a typo but intentional sibilance!
|
||||
|
||||
@@ -123,99 +123,99 @@
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<p>The following are a few screen dumps of:</p>
|
||||
<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="va">SIZE</span><span class="op">=</span>100 <span class="va">SHEDS</span><span class="op">=</span>5 <span class="va">GROW</span><span class="op">=</span>-10 <span class="va">SHED</span><span class="op">=</span>50 <span class="va">MAXSIZE</span><span class="op">=</span>250 <span class="ex">./prog</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="va">SIZE</span><span class="op">=</span>100 <span class="va">SHEDS</span><span class="op">=</span>5 <span class="va">GROW</span><span class="op">=</span>-10 <span class="va">SHED</span><span class="op">=</span>50 <span class="va">MAXSIZE</span><span class="op">=</span>250 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>As you will see it took 17 bugs to get down to below 0. Notice how I had to get
|
||||
down to 0 more than once: because I moved enough times before I got the last
|
||||
bug that I grew by 5 in size. I then however moved a bit more and ate a bug
|
||||
which brought me down to -5 therefore winning at the max size of 250. This then
|
||||
showed:</p>
|
||||
<pre><code>YOU WIN!
|
||||
X:62/89 Y:5/25 S:250/250 B:17</code></pre>
|
||||
<pre><code> YOU WIN!
|
||||
X:62/89 Y:5/25 S:250/250 B:17</code></pre>
|
||||
<p>Observe all the arrows on the screen; that’s where a bug was that I ate and
|
||||
then I split off losing 10 in size. The first dump I’m already at 15/250:</p>
|
||||
<pre><code>X:17/89 Y:15/25 S:15/250 B:13
|
||||
##########################################################################################
|
||||
# <ooooooooo o <ooooooooo* #
|
||||
# o o> #
|
||||
# o ooo oooo #
|
||||
# o o ooooooooo> o v #
|
||||
# o o oo o #
|
||||
# o o o o #
|
||||
# o o o o #
|
||||
# <oo o o o #
|
||||
# o #
|
||||
# o o #
|
||||
# o o #
|
||||
# o o o #
|
||||
# <ooo o oooooooo> #
|
||||
# <oooooooooooooo o o #
|
||||
# o o #
|
||||
# o o #
|
||||
# < ooo o o #
|
||||
# o o #
|
||||
# o v #
|
||||
# oooooo> #
|
||||
# o #
|
||||
# o o> #
|
||||
# oooooo #
|
||||
##########################################################################################</code></pre>
|
||||
<pre><code> X:17/89 Y:15/25 S:15/250 B:13
|
||||
##########################################################################################
|
||||
# <ooooooooo o <ooooooooo* #
|
||||
# o o> #
|
||||
# o ooo oooo #
|
||||
# o o ooooooooo> o v #
|
||||
# o o oo o #
|
||||
# o o o o #
|
||||
# o o o o #
|
||||
# <oo o o o #
|
||||
# o #
|
||||
# o o #
|
||||
# o o #
|
||||
# o o o #
|
||||
# <ooo o oooooooo> #
|
||||
# <oooooooooooooo o o #
|
||||
# o o #
|
||||
# o o #
|
||||
# < ooo o o #
|
||||
# o o #
|
||||
# o v #
|
||||
# oooooo> #
|
||||
# o #
|
||||
# o o> #
|
||||
# oooooo #
|
||||
##########################################################################################</code></pre>
|
||||
<p>But here now I’m at 0; the head is marked <code>H</code> and it’s moving left.</p>
|
||||
<pre><code>X:19/89 Y:12/25 S:0/250 B:16
|
||||
##########################################################################################
|
||||
# <ooooooooo o <oooooooo <ooooooo #
|
||||
# o o> oo #
|
||||
# o ooo oooo #
|
||||
# o o oooooo*oo> v #
|
||||
# o o oo o oo> #
|
||||
# o o o o oo #
|
||||
# o o o oooo #
|
||||
# <oo o o o #
|
||||
# o #
|
||||
# o o #
|
||||
# H o o # <- *HEAD, LEFT*
|
||||
# o o o #
|
||||
# <ooo o oo ooooo> #
|
||||
# o o #
|
||||
# o o #
|
||||
# o o #
|
||||
# < ooo o #
|
||||
# o o #
|
||||
# <oooooooo o v #
|
||||
# oooooo> #
|
||||
# o #
|
||||
# o o> #
|
||||
# oooooo #
|
||||
##########################################################################################</code></pre>
|
||||
<pre><code> X:19/89 Y:12/25 S:0/250 B:16
|
||||
##########################################################################################
|
||||
# <ooooooooo o <oooooooo <ooooooo #
|
||||
# o o> oo #
|
||||
# o ooo oooo #
|
||||
# o o oooooo*oo> v #
|
||||
# o o oo o oo> #
|
||||
# o o o o oo #
|
||||
# o o o oooo #
|
||||
# <oo o o o #
|
||||
# o #
|
||||
# o o #
|
||||
# H o o # <- *HEAD, LEFT*
|
||||
# o o o #
|
||||
# <ooo o oo ooooo> #
|
||||
# o o #
|
||||
# o o #
|
||||
# o o #
|
||||
# < ooo o #
|
||||
# o o #
|
||||
# <oooooooo o v #
|
||||
# oooooo> #
|
||||
# o #
|
||||
# o o> #
|
||||
# oooooo #
|
||||
##########################################################################################</code></pre>
|
||||
<p>I ended up moving enough times where my size went back up to 5.</p>
|
||||
<p>Below the snake is moving right and its head is indicated by a <code>H</code> with the line
|
||||
marked at the right; the bug is marked as <code>B</code> and is also marked at the right.
|
||||
Notice how it’s in the body of the snake (but see below)!</p>
|
||||
<pre><code>X:55/89 Y:4/25 S:5/250 B:16
|
||||
##########################################################################################
|
||||
# <ooooooooo o <oooooooo <ooooooo #
|
||||
# o o> oo #
|
||||
# ooooH oooo # <- *HEAD, RIGHT*
|
||||
# o o ooooooBoo> v # <- *BUG*
|
||||
# o o oo o oo> #
|
||||
# o o o o oo #
|
||||
# o o o oooo #
|
||||
# <oo o o o #
|
||||
# o #
|
||||
# o o #
|
||||
# o o #
|
||||
# o o o #
|
||||
# <ooo o oo ooooo> #
|
||||
# o o #
|
||||
# o o #
|
||||
# o o #
|
||||
# < ooo o #
|
||||
# o o #
|
||||
# <oooooooo o v #
|
||||
# oooooo> #
|
||||
# o #
|
||||
# o o> #
|
||||
# oooooo #
|
||||
##########################################################################################</code></pre>
|
||||
<pre><code> X:55/89 Y:4/25 S:5/250 B:16
|
||||
##########################################################################################
|
||||
# <ooooooooo o <oooooooo <ooooooo #
|
||||
# o o> oo #
|
||||
# ooooH oooo # <- *HEAD, RIGHT*
|
||||
# o o ooooooBoo> v # <- *BUG*
|
||||
# o o oo o oo> #
|
||||
# o o o o oo #
|
||||
# o o o oooo #
|
||||
# <oo o o o #
|
||||
# o #
|
||||
# o o #
|
||||
# o o #
|
||||
# o o o #
|
||||
# <ooo o oo ooooo> #
|
||||
# o o #
|
||||
# o o #
|
||||
# o o #
|
||||
# < ooo o #
|
||||
# o o #
|
||||
# <oooooooo o v #
|
||||
# oooooo> #
|
||||
# o #
|
||||
# o o> #
|
||||
# oooooo #
|
||||
##########################################################################################</code></pre>
|
||||
<p>But did you see anything strange? The bug is on the fourth line below the upper wall.
|
||||
However it appears to be inside the body of the snake! But actually that’s just where
|
||||
the snake split off at some point: the snake no longer occupies that place and indeed I
|
||||
|
||||
+81
-81
@@ -1,7 +1,7 @@
|
||||
The following are a few screen dumps of:
|
||||
|
||||
```sh
|
||||
SIZE=100 SHEDS=5 GROW=-10 SHED=50 MAXSIZE=250 ./prog
|
||||
SIZE=100 SHEDS=5 GROW=-10 SHED=50 MAXSIZE=250 ./prog
|
||||
```
|
||||
|
||||
As you will see it took 17 bugs to get down to below 0. Notice how I had to get
|
||||
@@ -11,71 +11,71 @@ which brought me down to -5 therefore winning at the max size of 250. This then
|
||||
showed:
|
||||
|
||||
```
|
||||
YOU WIN!
|
||||
X:62/89 Y:5/25 S:250/250 B:17
|
||||
YOU WIN!
|
||||
X:62/89 Y:5/25 S:250/250 B:17
|
||||
```
|
||||
|
||||
Observe all the arrows on the screen; that's where a bug was that I ate and
|
||||
then I split off losing 10 in size. The first dump I'm already at 15/250:
|
||||
|
||||
```
|
||||
X:17/89 Y:15/25 S:15/250 B:13
|
||||
##########################################################################################
|
||||
# <ooooooooo o <ooooooooo* #
|
||||
# o o> #
|
||||
# o ooo oooo #
|
||||
# o o ooooooooo> o v #
|
||||
# o o oo o #
|
||||
# o o o o #
|
||||
# o o o o #
|
||||
# <oo o o o #
|
||||
# o #
|
||||
# o o #
|
||||
# o o #
|
||||
# o o o #
|
||||
# <ooo o oooooooo> #
|
||||
# <oooooooooooooo o o #
|
||||
# o o #
|
||||
# o o #
|
||||
# < ooo o o #
|
||||
# o o #
|
||||
# o v #
|
||||
# oooooo> #
|
||||
# o #
|
||||
# o o> #
|
||||
# oooooo #
|
||||
##########################################################################################
|
||||
X:17/89 Y:15/25 S:15/250 B:13
|
||||
##########################################################################################
|
||||
# <ooooooooo o <ooooooooo* #
|
||||
# o o> #
|
||||
# o ooo oooo #
|
||||
# o o ooooooooo> o v #
|
||||
# o o oo o #
|
||||
# o o o o #
|
||||
# o o o o #
|
||||
# <oo o o o #
|
||||
# o #
|
||||
# o o #
|
||||
# o o #
|
||||
# o o o #
|
||||
# <ooo o oooooooo> #
|
||||
# <oooooooooooooo o o #
|
||||
# o o #
|
||||
# o o #
|
||||
# < ooo o o #
|
||||
# o o #
|
||||
# o v #
|
||||
# oooooo> #
|
||||
# o #
|
||||
# o o> #
|
||||
# oooooo #
|
||||
##########################################################################################
|
||||
```
|
||||
|
||||
But here now I'm at 0; the head is marked `H` and it's moving left.
|
||||
|
||||
```
|
||||
X:19/89 Y:12/25 S:0/250 B:16
|
||||
##########################################################################################
|
||||
# <ooooooooo o <oooooooo <ooooooo #
|
||||
# o o> oo #
|
||||
# o ooo oooo #
|
||||
# o o oooooo*oo> v #
|
||||
# o o oo o oo> #
|
||||
# o o o o oo #
|
||||
# o o o oooo #
|
||||
# <oo o o o #
|
||||
# o #
|
||||
# o o #
|
||||
# H o o # <- *HEAD, LEFT*
|
||||
# o o o #
|
||||
# <ooo o oo ooooo> #
|
||||
# o o #
|
||||
# o o #
|
||||
# o o #
|
||||
# < ooo o #
|
||||
# o o #
|
||||
# <oooooooo o v #
|
||||
# oooooo> #
|
||||
# o #
|
||||
# o o> #
|
||||
# oooooo #
|
||||
##########################################################################################
|
||||
X:19/89 Y:12/25 S:0/250 B:16
|
||||
##########################################################################################
|
||||
# <ooooooooo o <oooooooo <ooooooo #
|
||||
# o o> oo #
|
||||
# o ooo oooo #
|
||||
# o o oooooo*oo> v #
|
||||
# o o oo o oo> #
|
||||
# o o o o oo #
|
||||
# o o o oooo #
|
||||
# <oo o o o #
|
||||
# o #
|
||||
# o o #
|
||||
# H o o # <- *HEAD, LEFT*
|
||||
# o o o #
|
||||
# <ooo o oo ooooo> #
|
||||
# o o #
|
||||
# o o #
|
||||
# o o #
|
||||
# < ooo o #
|
||||
# o o #
|
||||
# <oooooooo o v #
|
||||
# oooooo> #
|
||||
# o #
|
||||
# o o> #
|
||||
# oooooo #
|
||||
##########################################################################################
|
||||
```
|
||||
|
||||
I ended up moving enough times where my size went back up to 5.
|
||||
@@ -85,32 +85,32 @@ marked at the right; the bug is marked as `B` and is also marked at the right.
|
||||
Notice how it's in the body of the snake (but see below)!
|
||||
|
||||
```
|
||||
X:55/89 Y:4/25 S:5/250 B:16
|
||||
##########################################################################################
|
||||
# <ooooooooo o <oooooooo <ooooooo #
|
||||
# o o> oo #
|
||||
# ooooH oooo # <- *HEAD, RIGHT*
|
||||
# o o ooooooBoo> v # <- *BUG*
|
||||
# o o oo o oo> #
|
||||
# o o o o oo #
|
||||
# o o o oooo #
|
||||
# <oo o o o #
|
||||
# o #
|
||||
# o o #
|
||||
# o o #
|
||||
# o o o #
|
||||
# <ooo o oo ooooo> #
|
||||
# o o #
|
||||
# o o #
|
||||
# o o #
|
||||
# < ooo o #
|
||||
# o o #
|
||||
# <oooooooo o v #
|
||||
# oooooo> #
|
||||
# o #
|
||||
# o o> #
|
||||
# oooooo #
|
||||
##########################################################################################
|
||||
X:55/89 Y:4/25 S:5/250 B:16
|
||||
##########################################################################################
|
||||
# <ooooooooo o <oooooooo <ooooooo #
|
||||
# o o> oo #
|
||||
# ooooH oooo # <- *HEAD, RIGHT*
|
||||
# o o ooooooBoo> v # <- *BUG*
|
||||
# o o oo o oo> #
|
||||
# o o o o oo #
|
||||
# o o o oooo #
|
||||
# <oo o o o #
|
||||
# o #
|
||||
# o o #
|
||||
# o o #
|
||||
# o o o #
|
||||
# <ooo o oo ooooo> #
|
||||
# o o #
|
||||
# o o #
|
||||
# o o #
|
||||
# < ooo o #
|
||||
# o o #
|
||||
# <oooooooo o v #
|
||||
# oooooo> #
|
||||
# o #
|
||||
# o o> #
|
||||
# oooooo #
|
||||
##########################################################################################
|
||||
```
|
||||
|
||||
But did you see anything strange? The bug is on the fourth line below the upper wall.
|
||||
|
||||
+219
-220
@@ -196,24 +196,23 @@ below. Note that the top line is the score/status line: the top wall is at line
|
||||
1 and the left wall is column 0. Below I use the coordinates in the X/Y order
|
||||
(ncurses is the opposite: Y/X). I will parenthesise the numbers below to refer
|
||||
to the number in the diagram:</p>
|
||||
<pre><code>X:24/49 Y:8/16 S:5/658 B:0
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# + #
|
||||
# #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################
|
||||
</code></pre>
|
||||
<pre><code> X:24/49 Y:8/16 S:5/658 B:0
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# + #
|
||||
# #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################</code></pre>
|
||||
<ul>
|
||||
<li><p>The snake (<code>+</code>) is at (24),(8). The bug char is <code>*</code> and the wall char is
|
||||
<code>#</code>. When the snake moves the head will be an arrow facing the direction it
|
||||
@@ -232,207 +231,207 @@ it will always have an upper limit depending on the terminal size.</p></li>
|
||||
<li><p>The number of bugs eaten so far is 0.</p></li>
|
||||
</ul>
|
||||
<h2 id="gameplay-playing-the-game"><a name="playing" href="#toc">Gameplay: Playing the game</a></h2>
|
||||
<pre><code>X:39/49 Y:8/16 S:5/658 B:0
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# oooo> #
|
||||
# #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################</code></pre>
|
||||
<pre><code> X:39/49 Y:8/16 S:5/658 B:0
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# oooo> #
|
||||
# #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################</code></pre>
|
||||
<p>I let the snake grow to its full size (with the head at (39),(8)) and I’m two
|
||||
places above the bug so let’s go down:</p>
|
||||
<pre><code>X:39/49 Y:9/16 S:5/658 B:0
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# oooo #
|
||||
# v #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################</code></pre>
|
||||
<pre><code> X:39/49 Y:9/16 S:5/658 B:0
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# oooo #
|
||||
# v #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################</code></pre>
|
||||
<p>Now you see that the snake is going down and in one move the bug will be eaten.
|
||||
Let’s do that:</p>
|
||||
<pre><code>X:36/49 Y:10/16 S:10/658 B:1
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# ^ o #
|
||||
# oooo #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################</code></pre>
|
||||
<pre><code> X:36/49 Y:10/16 S:10/658 B:1
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# ^ o #
|
||||
# oooo #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################</code></pre>
|
||||
<p>Observe that the bug was eaten and a new bug spawned elsewhere. I went left
|
||||
three and then up one and could slither on to the bug.</p>
|
||||
<h1 id="gameplay-walls"><a name="walls" href="#toc">Gameplay: Walls</a></h1>
|
||||
<p>By default walls are passable (<strong>WALLS=1</strong>). Let’s get to full size and go
|
||||
through the top wall:</p>
|
||||
<pre><code>X:36/49 Y:15/16 S:10/658 B:1
|
||||
##################################################
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# * o #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# ^ #
|
||||
##################################################</code></pre>
|
||||
<pre><code> X:36/49 Y:15/16 S:10/658 B:1
|
||||
##################################################
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# * o #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# ^ #
|
||||
##################################################</code></pre>
|
||||
<p>There you can see I have grown to the full size and went through the top wall;
|
||||
the head is now at the opposite wall. Continuing:</p>
|
||||
<pre><code>X:36/49 Y:11/16 S:10/658 B:1
|
||||
##################################################
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# * o #
|
||||
# o #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# ^ #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
##################################################</code></pre>
|
||||
<pre><code> X:36/49 Y:11/16 S:10/658 B:1
|
||||
##################################################
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# * o #
|
||||
# o #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# ^ #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
##################################################</code></pre>
|
||||
<p>I might then have turned to the left and then shortly go up to get the bug. This
|
||||
goes on until you lose, quit or win the game.</p>
|
||||
<p>When you specify <strong>WALLS=0</strong> the walls become an obstacle that end the game. It
|
||||
might look like (I set the starting size to 150 and had only just started):</p>
|
||||
<pre><code>X:20/49 Y:2/16 S:150/658 B:0
|
||||
##################################################
|
||||
# ^ #
|
||||
# o #
|
||||
# o * #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# ooooo #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################</code></pre>
|
||||
<pre><code> X:20/49 Y:2/16 S:150/658 B:0
|
||||
##################################################
|
||||
# ^ #
|
||||
# o #
|
||||
# o * #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# ooooo #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################</code></pre>
|
||||
<p>If I continue going up I will see:</p>
|
||||
<pre><code>OUCH!
|
||||
X:20/49 Y:1/16 S:150/658 B:0</code></pre>
|
||||
<h1 id="gameplay-cannibalism"><a name="cannibalism" href="#toc">Gameplay: Cannibalism</a></h1>
|
||||
<p>By default cannibalism is disabled (<strong>CANNIBAL=0</strong>) so if you run into yourself it might look
|
||||
something like:</p>
|
||||
<pre><code>X:45/49 Y:10/16 S:10/658 B:1
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# ooooo #
|
||||
# ^ o #
|
||||
# ooo #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################</code></pre>
|
||||
<pre><code> X:45/49 Y:10/16 S:10/658 B:1
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# ooooo #
|
||||
# ^ o #
|
||||
# ooo #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################</code></pre>
|
||||
<p>If I were to do any movement but turn to the left I would run into myself. I’ll
|
||||
go to the right two spaces:</p>
|
||||
<pre><code>OW!
|
||||
X:47/49 Y:10/16 S:10/658 B:1</code></pre>
|
||||
<pre><code> OW!
|
||||
X:47/49 Y:10/16 S:10/658 B:1</code></pre>
|
||||
<p>But <strong>CANNIBAL=1</strong> can look very funny both in movement and still especially
|
||||
when you go through yourself several times when the snake is rather long. For
|
||||
example going through walls and the snake a few times:</p>
|
||||
<pre><code>X:4/49 Y:12/16 S:165/658 B:3
|
||||
##################################################
|
||||
#oo o ooooo o o o#
|
||||
# oooo o ooo o#
|
||||
# ooooooooooooooooooo#
|
||||
# o #
|
||||
# oooooooooo o #
|
||||
# o o o #
|
||||
# o oooo o o #
|
||||
# o o o o #
|
||||
# ooooooooooooooo #
|
||||
# o o* #
|
||||
# oo> o o #
|
||||
# o oooooooo o #
|
||||
#oooooooooooooo o oooo oooooooo#
|
||||
# o o o o o #
|
||||
##################################################</code></pre>
|
||||
<pre><code> X:4/49 Y:12/16 S:165/658 B:3
|
||||
##################################################
|
||||
#oo o ooooo o o o#
|
||||
# oooo o ooo o#
|
||||
# ooooooooooooooooooo#
|
||||
# o #
|
||||
# oooooooooo o #
|
||||
# o o o #
|
||||
# o oooo o o #
|
||||
# o o o o #
|
||||
# ooooooooooooooo #
|
||||
# o o* #
|
||||
# oo> o o #
|
||||
# o oooooooo o #
|
||||
#oooooooooooooo o oooo oooooooo#
|
||||
# o o o o o #
|
||||
##################################################</code></pre>
|
||||
<p>I’ll go back through myself now:</p>
|
||||
<pre><code>X:6/49 Y:14/16 S:165/658 B:3
|
||||
##################################################
|
||||
#oo o ooooo o o o#
|
||||
# oooo o ooo o#
|
||||
# ooooooooooooooooooo#
|
||||
# o #
|
||||
# oooooooooo o #
|
||||
# o o o #
|
||||
# o oooo o o #
|
||||
# o o o o #
|
||||
# ooooooooooooooo #
|
||||
# o o* #
|
||||
# ooo o o #
|
||||
# oo oooooooo o #
|
||||
#ooooo>oooooooo o oooo oooooooo#
|
||||
# o o o o o #
|
||||
##################################################</code></pre>
|
||||
<pre><code> X:6/49 Y:14/16 S:165/658 B:3
|
||||
##################################################
|
||||
#oo o ooooo o o o#
|
||||
# oooo o ooo o#
|
||||
# ooooooooooooooooooo#
|
||||
# o #
|
||||
# oooooooooo o #
|
||||
# o o o #
|
||||
# o oooo o o #
|
||||
# o o o o #
|
||||
# ooooooooooooooo #
|
||||
# o o* #
|
||||
# ooo o o #
|
||||
# oo oooooooo o #
|
||||
#ooooo>oooooooo o oooo oooooooo#
|
||||
# o o o o o #
|
||||
##################################################</code></pre>
|
||||
<p>If you note that the head is at (6),(14) I will go one more to the right and you
|
||||
will see that the arrow has moved over:</p>
|
||||
<pre><code>X:7/49 Y:14/16 S:165/658 B:3
|
||||
##################################################
|
||||
#oo o ooooo o o o#
|
||||
# oooo o ooo o#
|
||||
# ooooooooooooooooooo#
|
||||
# o #
|
||||
# oooooooooo o #
|
||||
# o o o #
|
||||
# o oooo o o #
|
||||
# o o o o #
|
||||
# ooooooooooooooo #
|
||||
# o o* #
|
||||
# ooo o o #
|
||||
# oo oooooooo o #
|
||||
#oooooo>ooooooo o oooo oooooooo#
|
||||
# o o o o o #
|
||||
##################################################</code></pre>
|
||||
<pre><code> X:7/49 Y:14/16 S:165/658 B:3
|
||||
##################################################
|
||||
#oo o ooooo o o o#
|
||||
# oooo o ooo o#
|
||||
# ooooooooooooooooooo#
|
||||
# o #
|
||||
# oooooooooo o #
|
||||
# o o o #
|
||||
# o oooo o o #
|
||||
# o o o o #
|
||||
# ooooooooooooooo #
|
||||
# o o* #
|
||||
# ooo o o #
|
||||
# oo oooooooo o #
|
||||
#oooooo>ooooooo o oooo oooooooo#
|
||||
# o o o o o #
|
||||
##################################################</code></pre>
|
||||
<p>Try this: get a reasonable length and then go back on yourself (if you’re going
|
||||
left go right etc.) and then after some length (but before you get beyond the
|
||||
snake) turn (so that you go perpendicular) and then watch as the snake starts
|
||||
@@ -452,9 +451,9 @@ setting the max size to a smaller value than the size you specify (or the
|
||||
default) or setting the size to higher than the default (or < 0 which will end
|
||||
up being > the max size though I suppose there might be some value that makes it
|
||||
less than again - I’m not going to try and figure that out however). Anyway:</p>
|
||||
<div class="sourceCode" id="cb14"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>-1 <span class="ex">./prog</span></span>
|
||||
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="ex">YOU</span> WIN!</span>
|
||||
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a><span class="ex">X:24/49</span> Y:8/16 S:658/658 B:0</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb14"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a> <span class="va">SIZE</span><span class="op">=</span>-1 <span class="ex">./prog</span></span>
|
||||
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">YOU</span> WIN!</span>
|
||||
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">X:24/49</span> Y:8/16 S:658/658 B:0</span></code></pre></div>
|
||||
<p>Observe that the size isn’t the default 997: because the screen size is too
|
||||
small for that value (see <a href="terminals.md">terminals.md</a>).</p>
|
||||
<p>The reason I chose 997 is that it leaves a bit of a challenge for some (maybe
|
||||
@@ -476,7 +475,7 @@ the default starting size and growth size of 5 the number of bugs needed before
|
||||
the game is won is 199 - also a prime!</p>
|
||||
<h1 id="gameplay-quitting"><a name="quitting" href="#toc">Gameplay: Quitting</a></h1>
|
||||
<p>If you wish to quit you can hit ‘q’ (case-insensitive). For example:</p>
|
||||
<pre><code>X:24/49 Y:8/16 S:5/658 B:0</code></pre>
|
||||
<pre><code> X:24/49 Y:8/16 S:5/658 B:0</code></pre>
|
||||
<h1 id="gameplay-modes">4. <a name="modes" href="#toc">Gameplay modes</a></h1>
|
||||
<p>Here I list a number of different modes of play. In the <a href="bugs.html">bugs.html</a>
|
||||
(<a href="bugs.md">bugs.md</a> on GitHub) file I even show how there’s a built-in test unit for some
|
||||
@@ -500,33 +499,33 @@ you have any form of epilepsy. Thank you.</strong></p>
|
||||
<p>If you want to draw the snake wherever you like on the screen you can do this by
|
||||
modifying the wait time (for input) to -1 (or any value < 0): then the snake
|
||||
does not move until you press a movement key. For example:</p>
|
||||
<div class="sourceCode" id="cb16"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="va">WAIT</span><span class="op">=</span>-1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb16"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a> <span class="va">WAIT</span><span class="op">=</span>-1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>When you eat a bug the snake will grow and you can draw more. If you want to
|
||||
make it so you can go through yourself:</p>
|
||||
<div class="sourceCode" id="cb17"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="va">WAIT</span><span class="op">=</span>-1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb17"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a> <span class="va">WAIT</span><span class="op">=</span>-1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>If you don’t want to start out so small (i.e. you want to be able to draw more
|
||||
quickly) you can just set the size to a bigger number (and you could do the same
|
||||
with growth and moult/shed):</p>
|
||||
<div class="sourceCode" id="cb18"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>50 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">WAIT</span><span class="op">=</span>-1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb18"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a> <span class="va">SIZE</span><span class="op">=</span>50 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">WAIT</span><span class="op">=</span>-1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>Do note that although you’re a bigger size you still grow one movement at a
|
||||
time.</p>
|
||||
<p>Okay but then if you get too many bugs the drawing will be over. If this proves
|
||||
to be a problem simply do:</p>
|
||||
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>100 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">WAIT</span><span class="op">=</span>-1 <span class="va">GROW</span><span class="op">=</span>0 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a> <span class="va">SIZE</span><span class="op">=</span>100 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">WAIT</span><span class="op">=</span>-1 <span class="va">GROW</span><span class="op">=</span>0 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>Or something like that (maybe make the size bigger but that’s up to you). You
|
||||
could also set the max size to be the highest possible by saying</p>
|
||||
<div class="sourceCode" id="cb20"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="va">MAXSIZE</span><span class="op">=</span>-1</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb20"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a> <span class="va">MAXSIZE</span><span class="op">=</span>-1</span></code></pre></div>
|
||||
<p>Which I’ve done in the <a href="play.sh">play.sh</a> script.</p>
|
||||
<p>I discuss how this mode works in [spoilers.markdown][].</p>
|
||||
<p>Here’s an example run where I spelt ‘SNAKE’. As you can see it’s far from
|
||||
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
|
||||
@@ -537,7 +536,7 @@ different colours and depending on the exact parameters you specify it could
|
||||
easily be in the trigger range for epilepsy but potentially stimulation overload
|
||||
too.</p>
|
||||
<p>If you’re still here you can create this effect like:</p>
|
||||
<div class="sourceCode" id="cb22"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a><span class="va">WAIT</span><span class="op">=</span>0 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb22"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a> <span class="va">WAIT</span><span class="op">=</span>0 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>As long as the bug evades you’ll find that the snake is growing because it’s
|
||||
actually eating bugs; the computer is actually playing the game by itself! You
|
||||
can still move the snake though it won’t seem like you have much control over
|
||||
@@ -554,14 +553,14 @@ happen because the bug has to find a X and Y coordinate that’s not occupied an
|
||||
so with fewer available it has a harder time finding a place in that one line.</p>
|
||||
<h3 id="computer-player-variations"><a name="auto-variations" href="#toc">Computer player variations</a></h3>
|
||||
<p>Here’s how to make the bug move every time the snake moves:</p>
|
||||
<div class="sourceCode" id="cb23"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">WAIT</span><span class="op">=</span>0 <span class="va">EVADE</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb23"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a> <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">WAIT</span><span class="op">=</span>0 <span class="va">EVADE</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<h4 id="help-the-computer-win-fairly-quickly">Help the computer win fairly quickly</h4>
|
||||
<p>If you want to see the game ‘win’ try something like:</p>
|
||||
<div class="sourceCode" id="cb24"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">WAIT</span><span class="op">=</span>0 <span class="va">EVADE</span><span class="op">=</span>1 <span class="va">MAXSIZE</span><span class="op">=</span>10 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb24"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a> <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">WAIT</span><span class="op">=</span>0 <span class="va">EVADE</span><span class="op">=</span>1 <span class="va">MAXSIZE</span><span class="op">=</span>10 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<h4 id="negative-growth-shrink-automatic-mode">Negative growth (Shrink) Automatic mode</h4>
|
||||
<p>Here’s a fun one I just thought of (a long time after these other modes were
|
||||
thought of):</p>
|
||||
<div class="sourceCode" id="cb25"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a><span class="va">WAIT</span><span class="op">=</span>0 <span class="va">EVADE</span><span class="op">=</span>1 <span class="va">GROW</span><span class="op">=</span>-1 <span class="va">SIZE</span><span class="op">=</span>9 <span class="va">MAXSIZE</span><span class="op">=</span>10 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb25"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a> <span class="va">WAIT</span><span class="op">=</span>0 <span class="va">EVADE</span><span class="op">=</span>1 <span class="va">GROW</span><span class="op">=</span>-1 <span class="va">SIZE</span><span class="op">=</span>9 <span class="va">MAXSIZE</span><span class="op">=</span>10 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>What you’ll see is that first the snake will get to the size of 9 - whether it
|
||||
shows to be 10 characters depends on whether or not it gets a bug before it can
|
||||
get to that length - and then it’ll start shrinking until it’s just the head
|
||||
@@ -569,7 +568,7 @@ then the head again (i.e. 1 then 0 in size) and then win! This is also in the
|
||||
<a href="play.sh">play.sh</a> script.</p>
|
||||
<h4 id="adjusting-the-timespeed">Adjusting the time/speed</h4>
|
||||
<p>Of course you can also do something like:</p>
|
||||
<div class="sourceCode" id="cb26"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a><span class="va">WAIT</span><span class="op">=</span>5 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb26"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a> <span class="va">WAIT</span><span class="op">=</span>5 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>Which although might not seem like it is significantly slower.</p>
|
||||
<h4 id="moving-the-snake-about-to-create-patterns">Moving the snake about to create patterns</h4>
|
||||
<p>If you press different direction keys in some pattern you will see a pattern
|
||||
@@ -579,11 +578,11 @@ suppose also how much the bug moves and the chance of being eaten also).</p>
|
||||
<p>Here’s an idea: how many moves is needed to make it possible to have some sort
|
||||
of success in catching bugs? Obviously the dimensions will affect this value.</p>
|
||||
<p>How long will it take for the snake to run into itself? For instance by doing:</p>
|
||||
<div class="sourceCode" id="cb27"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a><span class="va">WAIT</span><span class="op">=</span>0 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb27"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a> <span class="va">WAIT</span><span class="op">=</span>0 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>On my 13” MacBook Pro (replaced later by a 16”) at the default settings going
|
||||
horizontally the snake ran into itself at:</p>
|
||||
<pre><code>OW!
|
||||
X:57/156 Y:20/41 S:155/997 B:30</code></pre>
|
||||
<pre><code> OW!
|
||||
X:57/156 Y:20/41 S:155/997 B:30</code></pre>
|
||||
<p>What if you set the size to a high value? The lowest? There are bound to be
|
||||
other games to play with this feature!</p>
|
||||
<h2 id="gameplay-mode-grow-shrink-mode-positive-and-negative-winning"><a name="grow-shrink" href="#toc">Gameplay mode: Grow-Shrink mode (Positive and Negative Winning)</a></h2>
|
||||
@@ -593,7 +592,7 @@ or growing to the full size directly. This is how it works:</p>
|
||||
<p>You have a negative shedding growth and a positive growth size: negative and
|
||||
positive winning. Depending on the parameters specified it might go one way over
|
||||
the other. Try:</p>
|
||||
<div class="sourceCode" id="cb29"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>150 <span class="va">SHEDS</span><span class="op">=</span>-5 <span class="va">GROW</span><span class="op">=</span>10 <span class="va">SHED</span><span class="op">=</span>50 <span class="va">MAXSIZE</span><span class="op">=</span>250 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb29"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a> <span class="va">SIZE</span><span class="op">=</span>150 <span class="va">SHEDS</span><span class="op">=</span>-5 <span class="va">GROW</span><span class="op">=</span>10 <span class="va">SHED</span><span class="op">=</span>50 <span class="va">MAXSIZE</span><span class="op">=</span>250 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>What this does is set the size to 150 (to make it not go down so quickly) and
|
||||
then for each bug you eat it adds 5 to the size; for every 50 moves (that you
|
||||
don’t get the bug) you shrink by 5. You will find that at times you might only
|
||||
@@ -609,7 +608,7 @@ dumps with this idea.</p>
|
||||
<p>You could also have it so that eating a bug makes you shrink and moving so many
|
||||
moves you grow. I tried this and for me it was far more fun. The <a href="play.sh">play.sh</a>
|
||||
also has this mode:</p>
|
||||
<div class="sourceCode" id="cb30"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb30-1"><a href="#cb30-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>100 <span class="va">SHEDS</span><span class="op">=</span>5 <span class="va">GROW</span><span class="op">=</span>-10 <span class="va">SHED</span><span class="op">=</span>50 <span class="va">MAXSIZE</span><span class="op">=</span>250 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb30"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb30-1"><a href="#cb30-1" aria-hidden="true" tabindex="-1"></a> <span class="va">SIZE</span><span class="op">=</span>100 <span class="va">SHEDS</span><span class="op">=</span>5 <span class="va">GROW</span><span class="op">=</span>-10 <span class="va">SHED</span><span class="op">=</span>50 <span class="va">MAXSIZE</span><span class="op">=</span>250 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>Obviously there are many other variations. The <a href="play.sh">play.sh</a> script has some
|
||||
of them (the above is option 5; others are 4, 15 and 16 but only options 4 and 5
|
||||
are called Grow / Shrink).</p>
|
||||
@@ -623,7 +622,7 @@ typical range of seizures is 3 to 30 flashes per seconds (but can be higher) and
|
||||
that means that at <strong>EVADE=1</strong> every 231ms there will be a flash in addition to the
|
||||
snake moving too.</p>
|
||||
<p>Anyway this might sound absurd but it can be somewhat hypnotic by doing:</p>
|
||||
<div class="sourceCode" id="cb31"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb31-1"><a href="#cb31-1" aria-hidden="true" tabindex="-1"></a><span class="va">EVADE</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb31"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb31-1"><a href="#cb31-1" aria-hidden="true" tabindex="-1"></a> <span class="va">EVADE</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>And just moving the snake about not trying to catch any bugs - just let whatever
|
||||
happens happen.</p>
|
||||
<h2 id="gameplay-mode-stimulation-calming-mode"><a name="stim" href="#toc">Gameplay mode: Stimulation / Calming mode</a></h2>
|
||||
@@ -632,7 +631,7 @@ want to play a game without having to worry about winning or losing you can set
|
||||
the growth size to 0 and then just move the snake round and round eating bugs
|
||||
until you want to quit. You can enable cannibalism so that you don’t have to
|
||||
worry about even running into yourself and losing:</p>
|
||||
<div class="sourceCode" id="cb32"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb32-1"><a href="#cb32-1" aria-hidden="true" tabindex="-1"></a><span class="va">GROW</span><span class="op">=</span>0 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb32"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb32-1"><a href="#cb32-1" aria-hidden="true" tabindex="-1"></a> <span class="va">GROW</span><span class="op">=</span>0 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<h2 id="gameplay-mode-expansibility"><a name="expansibility" href="#toc">Gameplay mode: Expansibility</a></h2>
|
||||
<p>As I was writing this document and the game modes I have thought of other game
|
||||
modes (they were added) and I have come back to this document to add more modes.
|
||||
@@ -651,9 +650,9 @@ reason as well as I simply enjoy it and thinking up new modes.</p>
|
||||
this file discusses as well as allowing to easily change the colours.</p>
|
||||
<h2 id="colours-selection-snake-colours"><a name="colours" href="#toc">Colours selection: snake-colours</a></h2>
|
||||
<p>To do this use the <a href="snake-colours">snake-colours</a> script like so:</p>
|
||||
<div class="sourceCode" id="cb33"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb33-1"><a href="#cb33-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./snake-colours</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb33"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb33-1"><a href="#cb33-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./snake-colours</span></span></code></pre></div>
|
||||
<p>If you want to pass in specific variables you can do that too e.g.:</p>
|
||||
<div class="sourceCode" id="cb34"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb34-1"><a href="#cb34-1" aria-hidden="true" tabindex="-1"></a><span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./snake-colours</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb34"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb34-1"><a href="#cb34-1" aria-hidden="true" tabindex="-1"></a> <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./snake-colours</span></span></code></pre></div>
|
||||
<p>The script will prompt you for the colour of the walls, snake head, body and the
|
||||
bug.</p>
|
||||
<h2 id="automate-the-above-gameplay-modes"><a name="preset" href="#toc">Automate the above gameplay modes</a></h2>
|
||||
@@ -665,9 +664,9 @@ snake-colours above) and then gives you a list of game modes to play. You can
|
||||
pass in the game variables but note that if you pass in a variable that the mode
|
||||
you choose uses then the script will override what you pass in.</p>
|
||||
<p>To use you can do something like:</p>
|
||||
<div class="sourceCode" id="cb35"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb35-1"><a href="#cb35-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./play.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb35"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb35-1"><a href="#cb35-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./play.sh</span></span></code></pre></div>
|
||||
<p>Or to make it so walls are an obstacle:</p>
|
||||
<div class="sourceCode" id="cb36"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb36-1"><a href="#cb36-1" aria-hidden="true" tabindex="-1"></a><span class="va">WALLS</span><span class="op">=</span>0 <span class="ex">./play.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb36"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb36-1"><a href="#cb36-1" aria-hidden="true" tabindex="-1"></a> <span class="va">WALLS</span><span class="op">=</span>0 <span class="ex">./play.sh</span></span></code></pre></div>
|
||||
<h1 id="notes-about-some-of-the-game-variables">6. <a name="variables" href="#toc">Notes about some of the game variables</a></h1>
|
||||
<p>The game variables can be used for a variety of things including different
|
||||
gameplay modes (as shown above) but here are some general notes about a few of them.</p>
|
||||
|
||||
+216
-218
@@ -88,24 +88,23 @@ below. Note that the top line is the score/status line: the top wall is at line
|
||||
to the number in the diagram:
|
||||
|
||||
```
|
||||
X:24/49 Y:8/16 S:5/658 B:0
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# + #
|
||||
# #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################
|
||||
|
||||
X:24/49 Y:8/16 S:5/658 B:0
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# + #
|
||||
# #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################
|
||||
```
|
||||
|
||||
- The snake (`+`) is at (24),(8). The bug char is `*` and the wall char is
|
||||
@@ -133,46 +132,46 @@ X:24/49 Y:8/16 S:5/658 B:0
|
||||
|
||||
|
||||
```
|
||||
X:39/49 Y:8/16 S:5/658 B:0
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# oooo> #
|
||||
# #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################
|
||||
X:39/49 Y:8/16 S:5/658 B:0
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# oooo> #
|
||||
# #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################
|
||||
```
|
||||
|
||||
I let the snake grow to its full size (with the head at (39),(8)) and I'm two
|
||||
places above the bug so let's go down:
|
||||
|
||||
```
|
||||
X:39/49 Y:9/16 S:5/658 B:0
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# oooo #
|
||||
# v #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################
|
||||
X:39/49 Y:9/16 S:5/658 B:0
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# oooo #
|
||||
# v #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################
|
||||
```
|
||||
|
||||
|
||||
@@ -180,23 +179,23 @@ Now you see that the snake is going down and in one move the bug will be eaten.
|
||||
Let's do that:
|
||||
|
||||
```
|
||||
X:36/49 Y:10/16 S:10/658 B:1
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# ^ o #
|
||||
# oooo #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################
|
||||
X:36/49 Y:10/16 S:10/658 B:1
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# ^ o #
|
||||
# oooo #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################
|
||||
```
|
||||
|
||||
Observe that the bug was eaten and a new bug spawned elsewhere. I went left
|
||||
@@ -210,46 +209,46 @@ through the top wall:
|
||||
|
||||
|
||||
```
|
||||
X:36/49 Y:15/16 S:10/658 B:1
|
||||
##################################################
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# * o #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# ^ #
|
||||
##################################################
|
||||
X:36/49 Y:15/16 S:10/658 B:1
|
||||
##################################################
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# * o #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# ^ #
|
||||
##################################################
|
||||
```
|
||||
|
||||
There you can see I have grown to the full size and went through the top wall;
|
||||
the head is now at the opposite wall. Continuing:
|
||||
|
||||
```
|
||||
X:36/49 Y:11/16 S:10/658 B:1
|
||||
##################################################
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# * o #
|
||||
# o #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# ^ #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
##################################################
|
||||
X:36/49 Y:11/16 S:10/658 B:1
|
||||
##################################################
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# * o #
|
||||
# o #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# ^ #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
##################################################
|
||||
```
|
||||
|
||||
I might then have turned to the left and then shortly go up to get the bug. This
|
||||
@@ -260,23 +259,23 @@ When you specify **WALLS=0** the walls become an obstacle that end the game. It
|
||||
might look like (I set the starting size to 150 and had only just started):
|
||||
|
||||
```
|
||||
X:20/49 Y:2/16 S:150/658 B:0
|
||||
##################################################
|
||||
# ^ #
|
||||
# o #
|
||||
# o * #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# ooooo #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################
|
||||
X:20/49 Y:2/16 S:150/658 B:0
|
||||
##################################################
|
||||
# ^ #
|
||||
# o #
|
||||
# o * #
|
||||
# o #
|
||||
# o #
|
||||
# o #
|
||||
# ooooo #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################
|
||||
```
|
||||
|
||||
If I continue going up I will see:
|
||||
@@ -294,31 +293,31 @@ By default cannibalism is disabled (**CANNIBAL=0**) so if you run into yourself
|
||||
something like:
|
||||
|
||||
```
|
||||
X:45/49 Y:10/16 S:10/658 B:1
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# ooooo #
|
||||
# ^ o #
|
||||
# ooo #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################
|
||||
X:45/49 Y:10/16 S:10/658 B:1
|
||||
##################################################
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# * #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# ooooo #
|
||||
# ^ o #
|
||||
# ooo #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
# #
|
||||
##################################################
|
||||
```
|
||||
|
||||
If I were to do any movement but turn to the left I would run into myself. I'll
|
||||
go to the right two spaces:
|
||||
|
||||
```
|
||||
OW!
|
||||
X:47/49 Y:10/16 S:10/658 B:1
|
||||
OW!
|
||||
X:47/49 Y:10/16 S:10/658 B:1
|
||||
```
|
||||
|
||||
But **CANNIBAL=1** can look very funny both in movement and still especially
|
||||
@@ -326,68 +325,68 @@ when you go through yourself several times when the snake is rather long. For
|
||||
example going through walls and the snake a few times:
|
||||
|
||||
```
|
||||
X:4/49 Y:12/16 S:165/658 B:3
|
||||
##################################################
|
||||
#oo o ooooo o o o#
|
||||
# oooo o ooo o#
|
||||
# ooooooooooooooooooo#
|
||||
# o #
|
||||
# oooooooooo o #
|
||||
# o o o #
|
||||
# o oooo o o #
|
||||
# o o o o #
|
||||
# ooooooooooooooo #
|
||||
# o o* #
|
||||
# oo> o o #
|
||||
# o oooooooo o #
|
||||
#oooooooooooooo o oooo oooooooo#
|
||||
# o o o o o #
|
||||
##################################################
|
||||
X:4/49 Y:12/16 S:165/658 B:3
|
||||
##################################################
|
||||
#oo o ooooo o o o#
|
||||
# oooo o ooo o#
|
||||
# ooooooooooooooooooo#
|
||||
# o #
|
||||
# oooooooooo o #
|
||||
# o o o #
|
||||
# o oooo o o #
|
||||
# o o o o #
|
||||
# ooooooooooooooo #
|
||||
# o o* #
|
||||
# oo> o o #
|
||||
# o oooooooo o #
|
||||
#oooooooooooooo o oooo oooooooo#
|
||||
# o o o o o #
|
||||
##################################################
|
||||
```
|
||||
|
||||
I'll go back through myself now:
|
||||
|
||||
```
|
||||
X:6/49 Y:14/16 S:165/658 B:3
|
||||
##################################################
|
||||
#oo o ooooo o o o#
|
||||
# oooo o ooo o#
|
||||
# ooooooooooooooooooo#
|
||||
# o #
|
||||
# oooooooooo o #
|
||||
# o o o #
|
||||
# o oooo o o #
|
||||
# o o o o #
|
||||
# ooooooooooooooo #
|
||||
# o o* #
|
||||
# ooo o o #
|
||||
# oo oooooooo o #
|
||||
#ooooo>oooooooo o oooo oooooooo#
|
||||
# o o o o o #
|
||||
##################################################
|
||||
X:6/49 Y:14/16 S:165/658 B:3
|
||||
##################################################
|
||||
#oo o ooooo o o o#
|
||||
# oooo o ooo o#
|
||||
# ooooooooooooooooooo#
|
||||
# o #
|
||||
# oooooooooo o #
|
||||
# o o o #
|
||||
# o oooo o o #
|
||||
# o o o o #
|
||||
# ooooooooooooooo #
|
||||
# o o* #
|
||||
# ooo o o #
|
||||
# oo oooooooo o #
|
||||
#ooooo>oooooooo o oooo oooooooo#
|
||||
# o o o o o #
|
||||
##################################################
|
||||
```
|
||||
|
||||
If you note that the head is at (6),(14) I will go one more to the right and you
|
||||
will see that the arrow has moved over:
|
||||
|
||||
```
|
||||
X:7/49 Y:14/16 S:165/658 B:3
|
||||
##################################################
|
||||
#oo o ooooo o o o#
|
||||
# oooo o ooo o#
|
||||
# ooooooooooooooooooo#
|
||||
# o #
|
||||
# oooooooooo o #
|
||||
# o o o #
|
||||
# o oooo o o #
|
||||
# o o o o #
|
||||
# ooooooooooooooo #
|
||||
# o o* #
|
||||
# ooo o o #
|
||||
# oo oooooooo o #
|
||||
#oooooo>ooooooo o oooo oooooooo#
|
||||
# o o o o o #
|
||||
##################################################
|
||||
X:7/49 Y:14/16 S:165/658 B:3
|
||||
##################################################
|
||||
#oo o ooooo o o o#
|
||||
# oooo o ooo o#
|
||||
# ooooooooooooooooooo#
|
||||
# o #
|
||||
# oooooooooo o #
|
||||
# o o o #
|
||||
# o oooo o o #
|
||||
# o o o o #
|
||||
# ooooooooooooooo #
|
||||
# o o* #
|
||||
# ooo o o #
|
||||
# oo oooooooo o #
|
||||
#oooooo>ooooooo o oooo oooooooo#
|
||||
# o o o o o #
|
||||
##################################################
|
||||
```
|
||||
|
||||
Try this: get a reasonable length and then go back on yourself (if you're going
|
||||
@@ -417,9 +416,9 @@ up being > the max size though I suppose there might be some value that makes it
|
||||
less than again - I'm not going to try and figure that out however). Anyway:
|
||||
|
||||
```sh
|
||||
SIZE=-1 ./prog
|
||||
YOU WIN!
|
||||
X:24/49 Y:8/16 S:658/658 B:0
|
||||
SIZE=-1 ./prog
|
||||
YOU WIN!
|
||||
X:24/49 Y:8/16 S:658/658 B:0
|
||||
```
|
||||
|
||||
Observe that the size isn't the default 997: because the screen size is too
|
||||
@@ -451,11 +450,10 @@ the game is won is 199 - also a prime!
|
||||
If you wish to quit you can hit 'q' (case-insensitive). For example:
|
||||
|
||||
```
|
||||
X:24/49 Y:8/16 S:5/658 B:0
|
||||
X:24/49 Y:8/16 S:5/658 B:0
|
||||
```
|
||||
|
||||
|
||||
|
||||
# 4. <a name="modes" href="#toc">Gameplay modes</a>
|
||||
|
||||
Here I list a number of different modes of play. In the [bugs.html][]
|
||||
@@ -490,7 +488,7 @@ modifying the wait time (for input) to -1 (or any value < 0): then the snake
|
||||
does not move until you press a movement key. For example:
|
||||
|
||||
```sh
|
||||
WAIT=-1 ./prog
|
||||
WAIT=-1 ./prog
|
||||
```
|
||||
|
||||
|
||||
@@ -498,7 +496,7 @@ When you eat a bug the snake will grow and you can draw more. If you want to
|
||||
make it so you can go through yourself:
|
||||
|
||||
```sh
|
||||
WAIT=-1 CANNIBAL=1 ./prog
|
||||
WAIT=-1 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
If you don't want to start out so small (i.e. you want to be able to draw more
|
||||
@@ -506,7 +504,7 @@ quickly) you can just set the size to a bigger number (and you could do the same
|
||||
with growth and moult/shed):
|
||||
|
||||
```sh
|
||||
SIZE=50 CANNIBAL=1 WAIT=-1 ./prog
|
||||
SIZE=50 CANNIBAL=1 WAIT=-1 ./prog
|
||||
```
|
||||
|
||||
Do note that although you're a bigger size you still grow one movement at a
|
||||
@@ -516,14 +514,14 @@ Okay but then if you get too many bugs the drawing will be over. If this proves
|
||||
to be a problem simply do:
|
||||
|
||||
```sh
|
||||
SIZE=100 CANNIBAL=1 WAIT=-1 GROW=0 ./prog
|
||||
SIZE=100 CANNIBAL=1 WAIT=-1 GROW=0 ./prog
|
||||
```
|
||||
|
||||
Or something like that (maybe make the size bigger but that's up to you). You
|
||||
could also set the max size to be the highest possible by saying
|
||||
|
||||
```sh
|
||||
MAXSIZE=-1
|
||||
MAXSIZE=-1
|
||||
```
|
||||
|
||||
Which I've done in the [play.sh][] script.
|
||||
@@ -535,13 +533,13 @@ 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.
|
||||
|
||||
|
||||
|
||||
```
|
||||
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>
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -559,7 +557,7 @@ too.
|
||||
If you're still here you can create this effect like:
|
||||
|
||||
```sh
|
||||
WAIT=0 WALLS=1 CANNIBAL=1 ./prog
|
||||
WAIT=0 WALLS=1 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
As long as the bug evades you'll find that the snake is growing because it's
|
||||
@@ -585,7 +583,7 @@ so with fewer available it has a harder time finding a place in that one line.
|
||||
Here's how to make the bug move every time the snake moves:
|
||||
|
||||
```sh
|
||||
CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 ./prog
|
||||
CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 ./prog
|
||||
```
|
||||
|
||||
|
||||
@@ -594,7 +592,7 @@ CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 ./prog
|
||||
If you want to see the game 'win' try something like:
|
||||
|
||||
```sh
|
||||
CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 MAXSIZE=10 ./prog
|
||||
CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 MAXSIZE=10 ./prog
|
||||
```
|
||||
|
||||
|
||||
@@ -604,7 +602,7 @@ Here's a fun one I just thought of (a long time after these other modes were
|
||||
thought of):
|
||||
|
||||
```sh
|
||||
WAIT=0 EVADE=1 GROW=-1 SIZE=9 MAXSIZE=10 CANNIBAL=1 ./prog
|
||||
WAIT=0 EVADE=1 GROW=-1 SIZE=9 MAXSIZE=10 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
What you'll see is that first the snake will get to the size of 9 - whether it
|
||||
@@ -619,7 +617,7 @@ then the head again (i.e. 1 then 0 in size) and then win! This is also in the
|
||||
Of course you can also do something like:
|
||||
|
||||
```sh
|
||||
WAIT=5 WALLS=1 CANNIBAL=1 ./prog
|
||||
WAIT=5 WALLS=1 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
Which although might not seem like it is significantly slower.
|
||||
@@ -638,15 +636,15 @@ of success in catching bugs? Obviously the dimensions will affect this value.
|
||||
How long will it take for the snake to run into itself? For instance by doing:
|
||||
|
||||
```sh
|
||||
WAIT=0 ./prog
|
||||
WAIT=0 ./prog
|
||||
```
|
||||
|
||||
On my 13" MacBook Pro (replaced later by a 16") at the default settings going
|
||||
horizontally the snake ran into itself at:
|
||||
|
||||
```
|
||||
OW!
|
||||
X:57/156 Y:20/41 S:155/997 B:30
|
||||
OW!
|
||||
X:57/156 Y:20/41 S:155/997 B:30
|
||||
```
|
||||
|
||||
What if you set the size to a high value? The lowest? There are bound to be
|
||||
@@ -663,7 +661,7 @@ positive winning. Depending on the parameters specified it might go one way over
|
||||
the other. Try:
|
||||
|
||||
```sh
|
||||
SIZE=150 SHEDS=-5 GROW=10 SHED=50 MAXSIZE=250 ./prog
|
||||
SIZE=150 SHEDS=-5 GROW=10 SHED=50 MAXSIZE=250 ./prog
|
||||
```
|
||||
|
||||
What this does is set the size to 150 (to make it not go down so quickly) and
|
||||
@@ -686,7 +684,7 @@ moves you grow. I tried this and for me it was far more fun. The [play.sh][]
|
||||
also has this mode:
|
||||
|
||||
```sh
|
||||
SIZE=100 SHEDS=5 GROW=-10 SHED=50 MAXSIZE=250 ./prog
|
||||
SIZE=100 SHEDS=5 GROW=-10 SHED=50 MAXSIZE=250 ./prog
|
||||
```
|
||||
|
||||
Obviously there are many other variations. The [play.sh][] script has some
|
||||
@@ -708,7 +706,7 @@ snake moving too.
|
||||
Anyway this might sound absurd but it can be somewhat hypnotic by doing:
|
||||
|
||||
```sh
|
||||
EVADE=1 CANNIBAL=1 ./prog
|
||||
EVADE=1 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
And just moving the snake about not trying to catch any bugs - just let whatever
|
||||
@@ -724,7 +722,7 @@ until you want to quit. You can enable cannibalism so that you don't have to
|
||||
worry about even running into yourself and losing:
|
||||
|
||||
```sh
|
||||
GROW=0 CANNIBAL=1 ./prog
|
||||
GROW=0 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
|
||||
@@ -755,13 +753,13 @@ this file discusses as well as allowing to easily change the colours.
|
||||
To do this use the [snake-colours][] script like so:
|
||||
|
||||
```sh
|
||||
./snake-colours
|
||||
./snake-colours
|
||||
```
|
||||
|
||||
If you want to pass in specific variables you can do that too e.g.:
|
||||
|
||||
```sh
|
||||
CANNIBAL=1 ./snake-colours
|
||||
CANNIBAL=1 ./snake-colours
|
||||
```
|
||||
|
||||
The script will prompt you for the colour of the walls, snake head, body and the
|
||||
@@ -780,13 +778,13 @@ you choose uses then the script will override what you pass in.
|
||||
To use you can do something like:
|
||||
|
||||
```sh
|
||||
./play.sh
|
||||
./play.sh
|
||||
```
|
||||
|
||||
Or to make it so walls are an obstacle:
|
||||
|
||||
```sh
|
||||
WALLS=0 ./play.sh
|
||||
WALLS=0 ./play.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
+17
-18
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Cody_Boone_Ferguson">Cody Boone Ferguson</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,14 +141,14 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
|
||||
<!-- 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>
|
||||
<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#2020_ferguson1">2020 ferguson1 bugs</a>.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="va">WAIT</span><span class="op">=</span>N <span class="va">WALLS</span><span class="op">=</span><span class="pp">[</span><span class="ss">01</span><span class="pp">]</span> <span class="va">EVADE</span><span class="op">=</span>N <span class="va">SIZE</span><span class="op">=</span>N <span class="va">MAXSIZE</span><span class="op">=</span>N <span class="va">GROW</span><span class="op">=</span>N <span class="va">SHEDS</span><span class="op">=</span>N <span class="va">SHED</span><span class="op">=</span>N <span class="va">CANNIBAL</span><span class="op">=</span><span class="pp">[</span><span class="ss">01</span><span class="pp">]</span> <span class="ex">./prog</span></span>
|
||||
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="co"># start pressing some arrow keys</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="va">WAIT</span><span class="op">=</span>N <span class="va">WALLS</span><span class="op">=</span><span class="pp">[</span><span class="ss">01</span><span class="pp">]</span> <span class="va">EVADE</span><span class="op">=</span>N <span class="va">SIZE</span><span class="op">=</span>N <span class="va">MAXSIZE</span><span class="op">=</span>N <span class="va">GROW</span><span class="op">=</span>N <span class="va">SHEDS</span><span class="op">=</span>N <span class="va">SHED</span><span class="op">=</span>N <span class="va">CANNIBAL</span><span class="op">=</span><span class="pp">[</span><span class="ss">01</span><span class="pp">]</span> <span class="ex">./prog</span></span>
|
||||
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="co"># start pressing some arrow keys</span></span></code></pre></div>
|
||||
<p>where <code>N</code> is a number and <code>[01]</code> is either <code>1</code> or <code>0</code> (or more correctly zero
|
||||
and non-zero).</p>
|
||||
<h3 id="variables">Variables:</h3>
|
||||
@@ -203,25 +202,25 @@ whether you can go through the Snake or not. Default is 0
|
||||
(cannot - die if you try).</p></li>
|
||||
</ul>
|
||||
<h2 id="try">Try:</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="fu">make</span> test</span>
|
||||
<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="fu">make</span> test</span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="va">WAIT</span><span class="op">=</span>75 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span>
|
||||
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="va">WAIT</span><span class="op">=</span>75 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span>
|
||||
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span></span>
|
||||
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span></span>
|
||||
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>-1 <span class="ex">./prog</span></span>
|
||||
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a> <span class="va">SIZE</span><span class="op">=</span>-1 <span class="ex">./prog</span></span>
|
||||
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a><span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">WAIT</span><span class="op">=</span>50 <span class="va">EVADE</span><span class="op">=</span>200 <span class="ex">./prog</span></span>
|
||||
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a> <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">WAIT</span><span class="op">=</span>50 <span class="va">EVADE</span><span class="op">=</span>200 <span class="ex">./prog</span></span>
|
||||
<span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb4-11"><a href="#cb4-11" aria-hidden="true" tabindex="-1"></a><span class="va">WAIT</span><span class="op">=</span>75 <span class="va">GROW</span><span class="op">=</span>-1 <span class="va">SIZE</span><span class="op">=</span>5 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span>
|
||||
<span id="cb4-11"><a href="#cb4-11" aria-hidden="true" tabindex="-1"></a> <span class="va">WAIT</span><span class="op">=</span>75 <span class="va">GROW</span><span class="op">=</span>-1 <span class="va">SIZE</span><span class="op">=</span>5 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span>
|
||||
<span id="cb4-12"><a href="#cb4-12" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb4-13"><a href="#cb4-13" aria-hidden="true" tabindex="-1"></a><span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">WAIT</span><span class="op">=</span>0 <span class="va">EVADE</span><span class="op">=</span>1 <span class="va">MAXSIZE</span><span class="op">=</span>10 <span class="ex">./prog</span></span>
|
||||
<span id="cb4-13"><a href="#cb4-13" aria-hidden="true" tabindex="-1"></a> <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">WAIT</span><span class="op">=</span>0 <span class="va">EVADE</span><span class="op">=</span>1 <span class="va">MAXSIZE</span><span class="op">=</span>10 <span class="ex">./prog</span></span>
|
||||
<span id="cb4-14"><a href="#cb4-14" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb4-15"><a href="#cb4-15" aria-hidden="true" tabindex="-1"></a><span class="ex">./play</span></span>
|
||||
<span id="cb4-16"><a href="#cb4-16" aria-hidden="true" tabindex="-1"></a><span class="co"># allows you to configure colours and has various pre-configured gameplay modes</span></span>
|
||||
<span id="cb4-15"><a href="#cb4-15" aria-hidden="true" tabindex="-1"></a> <span class="ex">./play</span></span>
|
||||
<span id="cb4-16"><a href="#cb4-16" aria-hidden="true" tabindex="-1"></a> <span class="co"># allows you to configure colours and has various pre-configured gameplay modes</span></span>
|
||||
<span id="cb4-17"><a href="#cb4-17" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb4-18"><a href="#cb4-18" aria-hidden="true" tabindex="-1"></a><span class="ex">./snake-colours</span></span>
|
||||
<span id="cb4-19"><a href="#cb4-19" aria-hidden="true" tabindex="-1"></a><span class="co"># allows for configuring colours</span></span></code></pre></div>
|
||||
<span id="cb4-18"><a href="#cb4-18" aria-hidden="true" tabindex="-1"></a> <span class="ex">./snake-colours</span></span>
|
||||
<span id="cb4-19"><a href="#cb4-19" aria-hidden="true" tabindex="-1"></a> <span class="co"># allows for configuring colours</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>As the <a href="https://en.wikipedia.org/wiki/Gadsden_flag">Gadsden flag</a> warns, beware of the snake!
|
||||
This game has a number of configurable pitfalls including walls and snakes.</p>
|
||||
@@ -307,7 +306,7 @@ look like bugs but aren’t as well as documenting a built-in test unit for some
|
||||
features.</p>
|
||||
<p>Because all IOCCC entries should have a man page I have included one (even
|
||||
though much of it is what’s also above). To render try:</p>
|
||||
<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="fu">man</span> ./snake.1</span></code></pre></div>
|
||||
<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="fu">man</span> ./snake.1</span></code></pre></div>
|
||||
<p>The <a href="COMPILING.html">COMPILING.html</a> file has a few portability
|
||||
notes and the <a href="HACKING.html">HACKING.html</a> file has some
|
||||
information on how one might modify things, things that could be implemented
|
||||
|
||||
@@ -762,9 +762,9 @@ returning <code>E()</code> I am returning 1 but if the end of main() is reached
|
||||
returned. In either case curses is ended.</p>
|
||||
<p>One of these optimisations saved four bytes simply by taking advantage of the
|
||||
value of a loop iterator after the loop. The loop is:</p>
|
||||
<div class="sourceCode" id="cb27"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb27-1"><a href="#cb27-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> A <span class="op">&&</span> I <span class="op"><</span> A <span class="op">-</span> <span class="dv">1</span><span class="op">;</span> <span class="op">++</span>I<span class="op">)</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb27"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb27-1"><a href="#cb27-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> A <span class="op">&&</span> I <span class="op"><</span> A <span class="op">-</span> <span class="dv">1</span><span class="op">;</span> <span class="op">++</span>I<span class="op">)</span></span></code></pre></div>
|
||||
<p>However after the loop I had this:</p>
|
||||
<div class="sourceCode" id="cb28"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a>A <span class="op">></span> <span class="dv">1</span> <span class="op">&&</span> q<span class="op">(</span>n<span class="op">[</span>A <span class="op">-</span> <span class="dv">1</span><span class="op">],</span>e<span class="op">[</span>A <span class="op">-</span> <span class="dv">1</span><span class="op">],</span> <span class="ch">'o'</span><span class="op">);</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb28"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a> A <span class="op">></span> <span class="dv">1</span> <span class="op">&&</span> q<span class="op">(</span>n<span class="op">[</span>A <span class="op">-</span> <span class="dv">1</span><span class="op">],</span>e<span class="op">[</span>A <span class="op">-</span> <span class="dv">1</span><span class="op">],</span> <span class="ch">'o'</span><span class="op">);</span></span></code></pre></div>
|
||||
<p>When I was considering moving that line to before the loop it occurred to me
|
||||
that as long as <code>A > 0</code> then <code>A - 1 == I</code> after the loop. I still had to check
|
||||
for <code>A > 1</code> but I could refer to just <code>I</code> instead of <code>A - 1</code>!</p>
|
||||
@@ -779,31 +779,31 @@ place at this point) I was looking at the code to see if I could figure out how
|
||||
to save even more bytes. Here are some that I found interesting ways to go about
|
||||
the problem.</p>
|
||||
<p>First, the function that turns on colours looked like:</p>
|
||||
<div class="sourceCode" id="cb29"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> <span class="op">(</span>h<span class="op">)</span> attron<span class="op">(</span>m<span class="op">(</span>PAIR<span class="op">(</span>L<span class="op">)));</span></span>
|
||||
<span id="cb29-2"><a href="#cb29-2" aria-hidden="true" tabindex="-1"></a><span class="cf">else</span> attroff<span class="op">(</span>m<span class="op">(</span>PAIR<span class="op">(</span>L<span class="op">)));</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb29"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>h<span class="op">)</span> attron<span class="op">(</span>m<span class="op">(</span>PAIR<span class="op">(</span>L<span class="op">)));</span></span>
|
||||
<span id="cb29-2"><a href="#cb29-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">else</span> attroff<span class="op">(</span>m<span class="op">(</span>PAIR<span class="op">(</span>L<span class="op">)));</span></span></code></pre></div>
|
||||
<p>But I thought is that else actually needed? If I were to switch the order so
|
||||
that the <code>attroff()</code> is called first then I could just do an <code>if (h)</code> -
|
||||
therefore getting rid of the <code>else</code>! But then I thought why not do what I’ve
|
||||
done elsewhere? I had:</p>
|
||||
<div class="sourceCode" id="cb30"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb30-1"><a href="#cb30-1" aria-hidden="true" tabindex="-1"></a>attroff<span class="op">(</span>m<span class="op">(</span>PAIR<span class="op">(</span>L<span class="op">)));</span></span>
|
||||
<span id="cb30-2"><a href="#cb30-2" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> <span class="op">(</span>h<span class="op">)</span> attron<span class="op">(</span>m<span class="op">(</span>PAIR<span class="op">(</span>L<span class="op">)));</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb30"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb30-1"><a href="#cb30-1" aria-hidden="true" tabindex="-1"></a> attroff<span class="op">(</span>m<span class="op">(</span>PAIR<span class="op">(</span>L<span class="op">)));</span></span>
|
||||
<span id="cb30-2"><a href="#cb30-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>h<span class="op">)</span> attron<span class="op">(</span>m<span class="op">(</span>PAIR<span class="op">(</span>L<span class="op">)));</span></span></code></pre></div>
|
||||
<p>But I then saved an extra byte by making it:</p>
|
||||
<div class="sourceCode" id="cb31"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb31-1"><a href="#cb31-1" aria-hidden="true" tabindex="-1"></a>attroff<span class="op">(</span>m<span class="op">(</span>PAIR<span class="op">(</span>L<span class="op">)));</span></span>
|
||||
<span id="cb31-2"><a href="#cb31-2" aria-hidden="true" tabindex="-1"></a>h <span class="op">&&</span> attron<span class="op">(</span>m<span class="op">(</span>PAIR<span class="op">(</span>L<span class="op">)));</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb31"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb31-1"><a href="#cb31-1" aria-hidden="true" tabindex="-1"></a> attroff<span class="op">(</span>m<span class="op">(</span>PAIR<span class="op">(</span>L<span class="op">)));</span></span>
|
||||
<span id="cb31-2"><a href="#cb31-2" aria-hidden="true" tabindex="-1"></a> h <span class="op">&&</span> attron<span class="op">(</span>m<span class="op">(</span>PAIR<span class="op">(</span>L<span class="op">)));</span></span></code></pre></div>
|
||||
<p>That saved two bytes.</p>
|
||||
<p>Second let’s look at the <code>B()</code> function: there were two things I thought of that
|
||||
would save some bytes (I no longer know how many but a few at least possibly six
|
||||
or even more). I had the following code:</p>
|
||||
<div class="sourceCode" id="cb32"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb32-1"><a href="#cb32-1" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> <span class="op">(</span>V <span class="op">&&</span> U <span class="op">&&</span> o<span class="op">)</span> <span class="op">{</span> S<span class="op">(</span>N<span class="op">);</span> b<span class="op">(</span><span class="dv">1</span><span class="op">);</span> <span class="op">}</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb32"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb32-1"><a href="#cb32-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>V <span class="op">&&</span> U <span class="op">&&</span> o<span class="op">)</span> <span class="op">{</span> S<span class="op">(</span>N<span class="op">);</span> b<span class="op">(</span><span class="dv">1</span><span class="op">);</span> <span class="op">}</span></span></code></pre></div>
|
||||
<p>This made sure that only if the snake has caught a bug should it grow by the
|
||||
growth size and increase the bug count. But was checking for the <code>V</code> or <code>U</code>
|
||||
necessary? I gave it a look over and it occurred to me: the only time <code>B()</code> is
|
||||
called with <code>1</code> (thus <code>o</code> is 1 so the if is true) was if the bug actually is
|
||||
caught. That means I could remove the <code>V && U &&</code> part of the if! Thus it became
|
||||
instead:</p>
|
||||
<div class="sourceCode" id="cb33"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb33-1"><a href="#cb33-1" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> <span class="op">(</span>o<span class="op">)</span> <span class="op">{</span> S<span class="op">(</span>N<span class="op">);</span> b<span class="op">(</span><span class="dv">1</span><span class="op">);</span> <span class="op">}</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb33"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb33-1"><a href="#cb33-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>o<span class="op">)</span> <span class="op">{</span> S<span class="op">(</span>N<span class="op">);</span> b<span class="op">(</span><span class="dv">1</span><span class="op">);</span> <span class="op">}</span></span></code></pre></div>
|
||||
<p>Then this</p>
|
||||
<div class="sourceCode" id="cb34"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb34-1"><a href="#cb34-1" aria-hidden="true" tabindex="-1"></a><span class="op">!</span>o <span class="op">&&</span> V <span class="op">&&</span> U <span class="op">&&</span> q U<span class="op">,</span>V<span class="op">,</span><span class="ch">' '</span><span class="op">);</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb34"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb34-1"><a href="#cb34-1" aria-hidden="true" tabindex="-1"></a> <span class="op">!</span>o <span class="op">&&</span> V <span class="op">&&</span> U <span class="op">&&</span> q U<span class="op">,</span>V<span class="op">,</span><span class="ch">' '</span><span class="op">);</span></span></code></pre></div>
|
||||
<p>…is to make sure to only clear the spot the bug is (or was) at if
|
||||
the bug was NOT eaten. Why not eaten? Because if it was eaten it means the
|
||||
snake’s head will be there!</p>
|
||||
@@ -818,7 +818,7 @@ unfortunately the snake has to be placed first since the bug cannot be placed
|
||||
where the snake already is. So if I had to make sure the game had started (the
|
||||
snake has moved at least once) what could I check? In fact that means the
|
||||
direction is not 0! So I could just replace it with:</p>
|
||||
<div class="sourceCode" id="cb35"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb35-1"><a href="#cb35-1" aria-hidden="true" tabindex="-1"></a><span class="op">!</span>o <span class="op">&&</span> D <span class="op">&&</span> q <span class="op">*</span>U<span class="op">,*</span>V<span class="op">,</span><span class="ch">' '</span><span class="op">);</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb35"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb35-1"><a href="#cb35-1" aria-hidden="true" tabindex="-1"></a> <span class="op">!</span>o <span class="op">&&</span> D <span class="op">&&</span> q <span class="op">*</span>U<span class="op">,*</span>V<span class="op">,</span><span class="ch">' '</span><span class="op">);</span></span></code></pre></div>
|
||||
<p>That reduced the count further. But then I wondered if even that much is needed.
|
||||
The condition is that the bug has evaded which means the snake has moved already
|
||||
(so game started). What calls to this function happen before the game starts
|
||||
@@ -831,7 +831,7 @@ to check for is that <code>!o</code>: because after this call before the game ev
|
||||
the score line is updated: so the empty space will be overwritten anyway. And if
|
||||
the score line is made an empty string it doesn’t matter because it’ll appear as
|
||||
all spaces anyway. Thus I could save another three bytes by changing it to:</p>
|
||||
<div class="sourceCode" id="cb36"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb36-1"><a href="#cb36-1" aria-hidden="true" tabindex="-1"></a><span class="op">!</span>o <span class="op">&&</span> q <span class="op">*</span>U<span class="op">,*</span>V<span class="op">,</span><span class="ch">' '</span><span class="op">);</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb36"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb36-1"><a href="#cb36-1" aria-hidden="true" tabindex="-1"></a> <span class="op">!</span>o <span class="op">&&</span> q <span class="op">*</span>U<span class="op">,*</span>V<span class="op">,</span><span class="ch">' '</span><span class="op">);</span></span></code></pre></div>
|
||||
<p>Technically it would be a <code>" "</code> (see <a href="HACKING.html">HACKING.html</a> or on GitHub
|
||||
<a href="HACKING.md">HACKING.md</a>) else for N (not referring to the variable though it might very
|
||||
well matter here too) movements (i.e. due to sizes) you will at times (e.g.
|
||||
|
||||
+13
-13
@@ -819,13 +819,13 @@ One of these optimisations saved four bytes simply by taking advantage of the
|
||||
value of a loop iterator after the loop. The loop is:
|
||||
|
||||
```c
|
||||
for (I = 0; A && I < A - 1; ++I)
|
||||
for (I = 0; A && I < A - 1; ++I)
|
||||
```
|
||||
|
||||
However after the loop I had this:
|
||||
|
||||
```c
|
||||
A > 1 && q(n[A - 1],e[A - 1], 'o');
|
||||
A > 1 && q(n[A - 1],e[A - 1], 'o');
|
||||
```
|
||||
|
||||
When I was considering moving that line to before the loop it occurred to me
|
||||
@@ -848,8 +848,8 @@ the problem.
|
||||
First, the function that turns on colours looked like:
|
||||
|
||||
```c
|
||||
if (h) attron(m(PAIR(L)));
|
||||
else attroff(m(PAIR(L)));
|
||||
if (h) attron(m(PAIR(L)));
|
||||
else attroff(m(PAIR(L)));
|
||||
```
|
||||
|
||||
But I thought is that else actually needed? If I were to switch the order so
|
||||
@@ -858,15 +858,15 @@ therefore getting rid of the `else`! But then I thought why not do what I've
|
||||
done elsewhere? I had:
|
||||
|
||||
```c
|
||||
attroff(m(PAIR(L)));
|
||||
if (h) attron(m(PAIR(L)));
|
||||
attroff(m(PAIR(L)));
|
||||
if (h) attron(m(PAIR(L)));
|
||||
```
|
||||
|
||||
But I then saved an extra byte by making it:
|
||||
|
||||
```c
|
||||
attroff(m(PAIR(L)));
|
||||
h && attron(m(PAIR(L)));
|
||||
attroff(m(PAIR(L)));
|
||||
h && attron(m(PAIR(L)));
|
||||
```
|
||||
|
||||
That saved two bytes.
|
||||
@@ -876,7 +876,7 @@ would save some bytes (I no longer know how many but a few at least possibly six
|
||||
or even more). I had the following code:
|
||||
|
||||
```c
|
||||
if (V && U && o) { S(N); b(1); }
|
||||
if (V && U && o) { S(N); b(1); }
|
||||
```
|
||||
|
||||
This made sure that only if the snake has caught a bug should it grow by the
|
||||
@@ -887,13 +887,13 @@ caught. That means I could remove the `V && U &&` part of the if! Thus it became
|
||||
instead:
|
||||
|
||||
```c
|
||||
if (o) { S(N); b(1); }
|
||||
if (o) { S(N); b(1); }
|
||||
```
|
||||
|
||||
Then this
|
||||
|
||||
```c
|
||||
!o && V && U && q U,V,' ');
|
||||
!o && V && U && q U,V,' ');
|
||||
```
|
||||
|
||||
...is to make sure to only clear the spot the bug is (or was) at if
|
||||
@@ -914,7 +914,7 @@ snake has moved at least once) what could I check? In fact that means the
|
||||
direction is not 0! So I could just replace it with:
|
||||
|
||||
```c
|
||||
!o && D && q *U,*V,' ');
|
||||
!o && D && q *U,*V,' ');
|
||||
```
|
||||
|
||||
That reduced the count further. But then I wondered if even that much is needed.
|
||||
@@ -931,7 +931,7 @@ the score line is made an empty string it doesn't matter because it'll appear as
|
||||
all spaces anyway. Thus I could save another three bytes by changing it to:
|
||||
|
||||
```c
|
||||
!o && q *U,*V,' ');
|
||||
!o && q *U,*V,' ');
|
||||
```
|
||||
|
||||
Technically it would be a `" "` (see [HACKING.html][] or on GitHub
|
||||
|
||||
@@ -151,23 +151,23 @@ movement is required) I have provided a source file that can test your terminal
|
||||
for the capabilities I use in the entry.</p>
|
||||
<p>It also tries to determine the minimum number of columns to play without the
|
||||
status line overflowing - even with the dynamic length. Try:</p>
|
||||
<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="ex">$</span> make test</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="ex">$</span> make test</span></code></pre></div>
|
||||
<p>This compiles the program <a href="termcaps.c">termcaps.c</a> and runs it; you should see something like:</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 155 (153 playable)
|
||||
terminal rows 41 (38 playable)
|
||||
terminal cols 155 (153 playable)
|
||||
|
||||
snake size: 997 (max size: 5776)
|
||||
bugs: 199 (max size: 1155)
|
||||
snake size: 997 (max size: 5776)
|
||||
bugs: 199 (max size: 1155)
|
||||
|
||||
at least 34 columns (currently 155) recommended for snake size 997
|
||||
at least 37 columns (currently 155) recommended for capped snake size 5776
|
||||
at least 34 columns (currently 155) recommended for snake size 997
|
||||
at least 37 columns (currently 155) recommended for capped snake size 5776
|
||||
|
||||
No problems detected.</code></pre>
|
||||
No problems detected.</code></pre>
|
||||
<p>Terminal rows and cols are the current values (the number of columns shown later
|
||||
as well). The snake size is the default size to win (based on the variables, see
|
||||
below). The <code>max size: 5776</code> is the capped size (or ‘capsize’). The 199 bugs is
|
||||
@@ -178,21 +178,21 @@ maximum (capped) snake size.</p>
|
||||
<p>If I pass in any of the variables <strong>GROW</strong>, <strong>MAXSIZE</strong>, <strong>SIZE</strong> and/or
|
||||
<strong>LINES</strong> or <strong>COLUMNS</strong> it bases its calculations on those variables. For
|
||||
example:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> supports cursor movement</span>
|
||||
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> supports making cursor invisible</span>
|
||||
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> supports bold</span>
|
||||
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> supports colours</span>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">terminal</span> supports cursor movement</span>
|
||||
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">terminal</span> supports making cursor invisible</span>
|
||||
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">terminal</span> supports bold</span>
|
||||
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">terminal</span> supports colours</span>
|
||||
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> rows 41 <span class="er">(</span><span class="ex">38</span> playable<span class="kw">)</span></span>
|
||||
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> cols 155 <span class="er">(</span><span class="ex">153</span> playable<span class="kw">)</span></span>
|
||||
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">terminal</span> rows 41 <span class="er">(</span><span class="ex">38</span> playable<span class="kw">)</span></span>
|
||||
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">terminal</span> cols 155 <span class="er">(</span><span class="ex">153</span> playable<span class="kw">)</span></span>
|
||||
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a><span class="ex">snake</span> size: 5776 <span class="er">(</span><span class="ex">max</span> size: 5776<span class="kw">)</span></span>
|
||||
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a> <span class="ex">bugs:</span> 5771 <span class="er">(</span><span class="ex">max</span> size: 5771<span class="kw">)</span></span>
|
||||
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">snake</span> size: 5776 <span class="er">(</span><span class="ex">max</span> size: 5776<span class="kw">)</span></span>
|
||||
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a> <span class="ex">bugs:</span> 5771 <span class="er">(</span><span class="ex">max</span> size: 5771<span class="kw">)</span></span>
|
||||
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a><span class="ex">at</span> least 37 columns <span class="er">(</span><span class="ex">currently</span> 155<span class="kw">)</span> <span class="ex">recommended</span> for snake size 5776</span>
|
||||
<span id="cb3-13"><a href="#cb3-13" aria-hidden="true" tabindex="-1"></a><span class="ex">at</span> least 37 columns <span class="er">(</span><span class="ex">currently</span> 155<span class="kw">)</span> <span class="ex">recommended</span> for capped snake size 5776</span>
|
||||
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a> <span class="ex">at</span> least 37 columns <span class="er">(</span><span class="ex">currently</span> 155<span class="kw">)</span> <span class="ex">recommended</span> for snake size 5776</span>
|
||||
<span id="cb3-13"><a href="#cb3-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">at</span> least 37 columns <span class="er">(</span><span class="ex">currently</span> 155<span class="kw">)</span> <span class="ex">recommended</span> for capped snake size 5776</span>
|
||||
<span id="cb3-14"><a href="#cb3-14" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb3-15"><a href="#cb3-15" aria-hidden="true" tabindex="-1"></a><span class="ex">No</span> problems detected.</span></code></pre></div>
|
||||
<span id="cb3-15"><a href="#cb3-15" aria-hidden="true" tabindex="-1"></a> <span class="ex">No</span> problems detected.</span></code></pre></div>
|
||||
<p>As you can see it tells you the max size (the ‘capsized’ snake) as well as the
|
||||
requested max size (if the requested size is bigger than the capped size then it
|
||||
will be set to that value instead) of the snake. The capped size is like in the
|
||||
@@ -224,12 +224,12 @@ resize the window with first. But what if you want exacts?</p>
|
||||
<p>To specify the lines/columns of curses program per instance use the <code>LINES</code> and
|
||||
<code>COLUMNS</code> environmental variables.</p>
|
||||
<p>For demonstration consider the following:</p>
|
||||
<pre><code> $ echo $LINES $COLUMNS
|
||||
42 157</code></pre>
|
||||
<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">$</span> echo <span class="va">$LINES</span> <span class="va">$COLUMNS</span></span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">42</span> 157</span></code></pre></div>
|
||||
<p>Note: I subtract 1 from the max y/x and the max coords in the game output
|
||||
include the walls and score line but these values are for the terminal itself.</p>
|
||||
<p>Say you want 55 columns:</p>
|
||||
<pre><code> $ COLUMNS=55 ./prog</code></pre>
|
||||
<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">$</span> COLUMNS=55 ./prog</span></code></pre></div>
|
||||
<p>This will force curses to detect the max columns (X) of your terminal (for the
|
||||
game dimensions) - to be 55; it might look like this instead:</p>
|
||||
<pre><code> X:27/54 Y:20/41 S:5/997 B:0</code></pre>
|
||||
@@ -245,20 +245,21 @@ etc. For the game you might not see the final score.</p>
|
||||
<p>In my tests there is one thing that at least allows you to see the final score
|
||||
and that is by running <code>clear</code> before running the program. That’s what the
|
||||
prog.alt version does. You might run it as one of:</p>
|
||||
<pre><code> LINES=20 ./prog.alt
|
||||
LINES=20 ./snake.alt</code></pre>
|
||||
<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="va">LINES</span><span class="op">=</span>20 <span class="ex">./prog.alt</span></span>
|
||||
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="va">LINES</span><span class="op">=</span>20 <span class="ex">./snake.alt</span></span></code></pre></div>
|
||||
<p>Even if the final score is visible though the terminal may very well still be
|
||||
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>
|
||||
<p>You might have to run the <code>reset</code> tool like:</p>
|
||||
<pre><code> <LF>reset<LF>
|
||||
<pre><code> You might have to run the `reset` tool like:
|
||||
|
||||
(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>
|
||||
<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>
|
||||
<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="bu">echo</span> <span class="at">-e</span> <span class="dt">\\</span>033c</span></code></pre></div>
|
||||
<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
|
||||
@@ -270,10 +271,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>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="va">LINES</span><span class="op">=</span>997 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<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>
|
||||
<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="va">COLUMNS</span><span class="op">=</span>997 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<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
|
||||
@@ -305,7 +306,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>
|
||||
<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="va">TERM</span><span class="op">=</span>linux-m <span class="ex">./prog</span></span></code></pre></div>
|
||||
<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
|
||||
@@ -313,34 +314,33 @@ problems even with monochrome terminals. Later I say what to do to remove colour
|
||||
support in the source code itself.</p>
|
||||
<h2 id="colour-limitations"><a name="colourlimitations" href="#toc">Colour limitations</a></h2>
|
||||
<p>According to X/Open Curses, Issue 7 (pg. 57):</p>
|
||||
<pre><code>With init_pair() and pair_content(), the value of pair must be in a range
|
||||
from 0 to and including COLOR_PAIRS-1. (There may be an
|
||||
implementation-specific upper limit on the valid value of pair, but any such
|
||||
limit is at least 63.) Valid values for f and b are the range from 0 to and
|
||||
including COLORS-1.</code></pre>
|
||||
<pre><code> With init_pair() and pair_content(), the value of pair must be in a range
|
||||
from 0 to and including COLOR_PAIRS-1. (There may be an
|
||||
implementation-specific upper limit on the valid value of pair, but any such
|
||||
limit is at least 63.) Valid values for f and b are the range from 0 to and
|
||||
including COLORS-1.</code></pre>
|
||||
<p>The manpage for <code>init_pair()</code> says this:</p>
|
||||
<pre><code> These limits apply to color values and color pairs. Values outside these limits are not legal, and may result in a runtime error:
|
||||
<pre><code> These limits apply to color values and color pairs. Values outside these limits are not legal, and may result in a runtime error:
|
||||
|
||||
[...]
|
||||
[...]
|
||||
|
||||
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>
|
||||
<pre><code> #include <curses.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
initscr();
|
||||
start_color();
|
||||
printw("COLORS: %d\nCOLOR_PAIRS: %d\n", COLORS, COLOR_PAIRS);
|
||||
getch();
|
||||
endwin();
|
||||
}
|
||||
|
||||
TERM=linux-m ./colour_pairs
|
||||
COLORS: 0
|
||||
COLOR_PAIRS: 0</code></pre>
|
||||
<div class="sourceCode" id="cb15"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">#include </span><span class="im"><curses.h></span></span>
|
||||
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span> main<span class="op">()</span></span>
|
||||
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
|
||||
<span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a> initscr<span class="op">();</span></span>
|
||||
<span id="cb15-6"><a href="#cb15-6" aria-hidden="true" tabindex="-1"></a> start_color<span class="op">();</span></span>
|
||||
<span id="cb15-7"><a href="#cb15-7" aria-hidden="true" tabindex="-1"></a> printw<span class="op">(</span><span class="st">"COLORS: </span><span class="sc">%d\n</span><span class="st">COLOR_PAIRS: </span><span class="sc">%d\n</span><span class="st">"</span><span class="op">,</span> COLORS<span class="op">,</span> COLOR_PAIRS<span class="op">);</span></span>
|
||||
<span id="cb15-8"><a href="#cb15-8" aria-hidden="true" tabindex="-1"></a> getch<span class="op">();</span></span>
|
||||
<span id="cb15-9"><a href="#cb15-9" aria-hidden="true" tabindex="-1"></a> endwin<span class="op">();</span></span>
|
||||
<span id="cb15-10"><a href="#cb15-10" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb16"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a> <span class="va">TERM</span><span class="op">=</span>linux-m <span class="ex">./colour_pairs</span></span>
|
||||
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">COLORS:</span> 0</span>
|
||||
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">COLOR_PAIRS:</span> 0</span></code></pre></div>
|
||||
<p>Without specifying the TERM I get:</p>
|
||||
<pre><code> COLORS: 256
|
||||
COLOR_PAIRS: 32767</code></pre>
|
||||
@@ -348,22 +348,22 @@ confirm this I wrote the following code with the output below:</p>
|
||||
possible colour pairs than I have used so that’s not a problem either. Perhaps
|
||||
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();
|
||||
|
||||
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();
|
||||
}</code></pre>
|
||||
<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="dt">int</span> main<span class="op">()</span></span>
|
||||
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
|
||||
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a> initscr<span class="op">();</span></span>
|
||||
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a> start_color<span class="op">();</span></span>
|
||||
<span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb18-6"><a href="#cb18-6" aria-hidden="true" tabindex="-1"></a> init_pair<span class="op">(</span>COLOR_PAIRS<span class="op">+</span><span class="dv">1</span><span class="op">,</span> COLOR_WHITE<span class="op">,</span> COLOR_GREEN<span class="op">);</span></span>
|
||||
<span id="cb18-7"><a href="#cb18-7" aria-hidden="true" tabindex="-1"></a> bkgd<span class="op">(</span>COLOR_PAIR<span class="op">(</span>COLOR_PAIRS<span class="op">+</span><span class="dv">1</span><span class="op">));</span></span>
|
||||
<span id="cb18-8"><a href="#cb18-8" aria-hidden="true" tabindex="-1"></a> init_pair<span class="op">(</span><span class="dv">1</span><span class="op">,</span> COLOR_WHITE<span class="op">,</span> COLOR_BLACK<span class="op">);</span></span>
|
||||
<span id="cb18-9"><a href="#cb18-9" aria-hidden="true" tabindex="-1"></a> attron<span class="op">(</span>COLOR_PAIR<span class="op">(</span><span class="dv">1</span><span class="op">));</span></span>
|
||||
<span id="cb18-10"><a href="#cb18-10" aria-hidden="true" tabindex="-1"></a> printw<span class="op">(</span><span class="st">"COLORS: </span><span class="sc">%d\n</span><span class="st">COLOR_PAIRS: </span><span class="sc">%d\n</span><span class="st">"</span><span class="op">,</span> COLORS<span class="op">,</span> COLOR_PAIRS<span class="op">);</span></span>
|
||||
<span id="cb18-11"><a href="#cb18-11" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb18-12"><a href="#cb18-12" aria-hidden="true" tabindex="-1"></a> getch<span class="op">();</span></span>
|
||||
<span id="cb18-13"><a href="#cb18-13" aria-hidden="true" tabindex="-1"></a> endwin<span class="op">();</span></span>
|
||||
<span id="cb18-14"><a href="#cb18-14" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span></code></pre></div>
|
||||
<p>Running it like</p>
|
||||
<pre><code> TERM=linux-m ./colour_pairs</code></pre>
|
||||
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a> <span class="va">TERM</span><span class="op">=</span>linux-m <span class="ex">./colour_pairs</span></span></code></pre></div>
|
||||
<p>I got the output as if colours weren’t used: 0 and 0. With coloured terminals
|
||||
however it was not visible. If I however comment out the call to <code>bkgd()</code> I get
|
||||
instead:</p>
|
||||
|
||||
+101
-72
@@ -31,28 +31,28 @@ It also tries to determine the minimum number of columns to play without the
|
||||
status line overflowing - even with the dynamic length. Try:
|
||||
|
||||
```sh
|
||||
$ make test
|
||||
$ make test
|
||||
```
|
||||
|
||||
This compiles the program [termcaps.c](termcaps.c) and runs it; you should see something like:
|
||||
|
||||
|
||||
```
|
||||
terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
terminal supports bold
|
||||
terminal supports colours
|
||||
terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
terminal supports bold
|
||||
terminal supports colours
|
||||
|
||||
terminal rows 41 (38 playable)
|
||||
terminal cols 155 (153 playable)
|
||||
terminal rows 41 (38 playable)
|
||||
terminal cols 155 (153 playable)
|
||||
|
||||
snake size: 997 (max size: 5776)
|
||||
bugs: 199 (max size: 1155)
|
||||
snake size: 997 (max size: 5776)
|
||||
bugs: 199 (max size: 1155)
|
||||
|
||||
at least 34 columns (currently 155) recommended for snake size 997
|
||||
at least 37 columns (currently 155) recommended for capped snake size 5776
|
||||
at least 34 columns (currently 155) recommended for snake size 997
|
||||
at least 37 columns (currently 155) recommended for capped snake size 5776
|
||||
|
||||
No problems detected.
|
||||
No problems detected.
|
||||
```
|
||||
|
||||
Terminal rows and cols are the current values (the number of columns shown later
|
||||
@@ -68,21 +68,21 @@ If I pass in any of the variables **GROW**, **MAXSIZE**, **SIZE** and/or
|
||||
example:
|
||||
|
||||
```sh
|
||||
terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
terminal supports bold
|
||||
terminal supports colours
|
||||
terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
terminal supports bold
|
||||
terminal supports colours
|
||||
|
||||
terminal rows 41 (38 playable)
|
||||
terminal cols 155 (153 playable)
|
||||
terminal rows 41 (38 playable)
|
||||
terminal cols 155 (153 playable)
|
||||
|
||||
snake size: 5776 (max size: 5776)
|
||||
bugs: 5771 (max size: 5771)
|
||||
snake size: 5776 (max size: 5776)
|
||||
bugs: 5771 (max size: 5771)
|
||||
|
||||
at least 37 columns (currently 155) recommended for snake size 5776
|
||||
at least 37 columns (currently 155) recommended for capped snake size 5776
|
||||
at least 37 columns (currently 155) recommended for snake size 5776
|
||||
at least 37 columns (currently 155) recommended for capped snake size 5776
|
||||
|
||||
No problems detected.
|
||||
No problems detected.
|
||||
```
|
||||
|
||||
As you can see it tells you the max size (the 'capsized' snake) as well as the
|
||||
@@ -129,15 +129,19 @@ To specify the lines/columns of curses program per instance use the `LINES` and
|
||||
|
||||
For demonstration consider the following:
|
||||
|
||||
$ echo $LINES $COLUMNS
|
||||
42 157
|
||||
```sh
|
||||
$ echo $LINES $COLUMNS
|
||||
42 157
|
||||
```
|
||||
|
||||
Note: I subtract 1 from the max y/x and the max coords in the game output
|
||||
include the walls and score line but these values are for the terminal itself.
|
||||
|
||||
Say you want 55 columns:
|
||||
|
||||
$ COLUMNS=55 ./prog
|
||||
```sh
|
||||
$ COLUMNS=55 ./prog
|
||||
```
|
||||
|
||||
This will force curses to detect the max columns (X) of your terminal (for the
|
||||
game dimensions) - to be 55; it might look like this instead:
|
||||
@@ -162,9 +166,10 @@ In my tests there is one thing that at least allows you to see the final score
|
||||
and that is by running `clear` before running the program. That's what the
|
||||
prog.alt version does. You might run it as one of:
|
||||
|
||||
LINES=20 ./prog.alt
|
||||
LINES=20 ./snake.alt
|
||||
|
||||
```sh
|
||||
LINES=20 ./prog.alt
|
||||
LINES=20 ./snake.alt
|
||||
```
|
||||
|
||||
Even if the final score is visible though the terminal may very well still be
|
||||
messed up. There are numerous things you might try but probably the easiest is
|
||||
@@ -174,17 +179,20 @@ even just the `reset` command.
|
||||
|
||||
The Linux man page says:
|
||||
|
||||
```
|
||||
You might have to run the `reset` tool like:
|
||||
|
||||
<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.
|
||||
|
||||
```
|
||||
|
||||
If you don't have the reset utility you can try:
|
||||
|
||||
echo -e \\033c
|
||||
```sh
|
||||
echo -e \\033c
|
||||
```
|
||||
|
||||
Otherwise try `clear; stty sane` (that will turn on echo also) or if all else
|
||||
fails log out and back in.
|
||||
@@ -201,12 +209,16 @@ 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:
|
||||
|
||||
LINES=997 ./prog
|
||||
```sh
|
||||
LINES=997 ./prog
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
COLUMNS=997 ./prog
|
||||
```sh
|
||||
COLUMNS=997 ./prog
|
||||
```
|
||||
|
||||
Then they will see a different effect. Again the same reason: the player trying
|
||||
to be funny.
|
||||
@@ -253,7 +265,9 @@ 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:
|
||||
|
||||
TERM=linux-m ./prog
|
||||
```sh
|
||||
TERM=linux-m ./prog
|
||||
```
|
||||
|
||||
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
|
||||
@@ -265,74 +279,90 @@ support in the source code itself.
|
||||
|
||||
According to X/Open Curses, Issue 7 (pg. 57):
|
||||
|
||||
With init_pair() and pair_content(), the value of pair must be in a range
|
||||
from 0 to and including COLOR_PAIRS-1. (There may be an
|
||||
implementation-specific upper limit on the valid value of pair, but any such
|
||||
limit is at least 63.) Valid values for f and b are the range from 0 to and
|
||||
including COLORS-1.
|
||||
```
|
||||
With init_pair() and pair_content(), the value of pair must be in a range
|
||||
from 0 to and including COLOR_PAIRS-1. (There may be an
|
||||
implementation-specific upper limit on the valid value of pair, but any such
|
||||
limit is at least 63.) Valid values for f and b are the range from 0 to and
|
||||
including COLORS-1.
|
||||
```
|
||||
|
||||
The manpage for `init_pair()` says this:
|
||||
|
||||
These limits apply to color values and color pairs. Values outside these limits are not legal, and may result in a runtime error:
|
||||
```
|
||||
These limits apply to color values and color pairs. Values outside these limits are not legal, and may result in a runtime error:
|
||||
|
||||
[...]
|
||||
[...]
|
||||
|
||||
COLOR_PAIRS corresponds to the terminal database's max_pairs capability, (see terminfo(5)).
|
||||
COLOR_PAIRS corresponds to the terminal database's max_pairs capability, (see terminfo(5)).
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
#include <curses.h>
|
||||
```c
|
||||
#include <curses.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
initscr();
|
||||
start_color();
|
||||
printw("COLORS: %d\nCOLOR_PAIRS: %d\n", COLORS, COLOR_PAIRS);
|
||||
getch();
|
||||
endwin();
|
||||
}
|
||||
int main()
|
||||
{
|
||||
initscr();
|
||||
start_color();
|
||||
printw("COLORS: %d\nCOLOR_PAIRS: %d\n", COLORS, COLOR_PAIRS);
|
||||
getch();
|
||||
endwin();
|
||||
}
|
||||
```
|
||||
|
||||
TERM=linux-m ./colour_pairs
|
||||
COLORS: 0
|
||||
COLOR_PAIRS: 0
|
||||
```sh
|
||||
TERM=linux-m ./colour_pairs
|
||||
COLORS: 0
|
||||
COLOR_PAIRS: 0
|
||||
```
|
||||
|
||||
Without specifying the TERM I get:
|
||||
|
||||
COLORS: 256
|
||||
COLOR_PAIRS: 32767
|
||||
```
|
||||
COLORS: 256
|
||||
COLOR_PAIRS: 32767
|
||||
```
|
||||
|
||||
In the case that colour is supported the standard states that there will be more
|
||||
possible colour pairs than I have used so that's not a problem either. Perhaps
|
||||
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:
|
||||
|
||||
int main()
|
||||
{
|
||||
initscr();
|
||||
start_color();
|
||||
```c
|
||||
int main()
|
||||
{
|
||||
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();
|
||||
}
|
||||
```
|
||||
|
||||
Running it like
|
||||
|
||||
TERM=linux-m ./colour_pairs
|
||||
```sh
|
||||
TERM=linux-m ./colour_pairs
|
||||
```
|
||||
|
||||
I got the output as if colours weren't used: 0 and 0. With coloured terminals
|
||||
however it was not visible. If I however comment out the call to `bkgd()` I get
|
||||
instead:
|
||||
|
||||
COLORS: 256
|
||||
COLOR_PAIRS: 32767
|
||||
```
|
||||
COLORS: 256
|
||||
COLOR_PAIRS: 32767
|
||||
```
|
||||
|
||||
Which leads me to believe that if you try using a value outside the range it
|
||||
won't work for a colour-capable terminal but it doesn't matter for monochrome
|
||||
@@ -351,7 +381,6 @@ you can also comment out the `init_pair()` calls.
|
||||
Perhaps you only need to add the `return;` to `C()`. My guess is that's the case
|
||||
but I do not know for certain.
|
||||
|
||||
|
||||
[HACKING.md]: HACKING.md
|
||||
[HACKING.html]: HACKING.html
|
||||
[Linux keyboard and console HOWTO]: https://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO.html
|
||||
|
||||
@@ -372,7 +372,7 @@ hit a key every time to move because it is blocking.</p></li>
|
||||
</ul>
|
||||
<h2 id="on-environmental-variables-more-generally-and-string-to-int-conversions"><a name="envvars" href="#toc">On environmental variables more generally and string to int conversions</a></h2>
|
||||
<p>What happens if you do:</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="va">WALLS</span><span class="op">=</span> <span class="ex">./prog</span></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="va">WALLS</span><span class="op">=</span> <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>Can you run into the wall since you didn’t specify a value and the default is 1?
|
||||
No. That’s not the way it works. By saying WALLS= you have told the system that
|
||||
there is that environmental variable. However the way the <code>strtoul()</code> functions
|
||||
@@ -381,29 +381,29 @@ it’s wasteful (iocccsize wise) and I have never felt that having invalid input
|
||||
for a number could have a better value than 0.</p>
|
||||
<p>If however you were to give valid input followed by invalid input the valid
|
||||
input would be parsed. For example:</p>
|
||||
<div class="sourceCode" id="cb13"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="va">WALLS</span><span class="op">=</span>1test <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb13"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a> <span class="va">WALLS</span><span class="op">=</span>1test <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>would let you go through the walls. On the other hand</p>
|
||||
<div class="sourceCode" id="cb14"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="va">WALLS</span><span class="op">=</span>test1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb14"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a> <span class="va">WALLS</span><span class="op">=</span>test1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>would not. Furthermore if you specify the same variable more than once it’s the
|
||||
last one that counts. For example:</p>
|
||||
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="va">WALLS</span><span class="op">=</span>0 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>0 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a> <span class="va">WALLS</span><span class="op">=</span>0 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>0 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>would allow you to go through walls but you could not cannibalise.</p>
|
||||
<p>Also note that I specify base 0 which means that you can also have it in hex and
|
||||
octal. These are all the same:</p>
|
||||
<pre><code>SIZE=0x3
|
||||
SIZE=3
|
||||
SIZE=03</code></pre>
|
||||
<pre><code> SIZE=0x3
|
||||
SIZE=3
|
||||
SIZE=03</code></pre>
|
||||
<p>The way the functions work is if 0x (or 0X) it’s considered hex; if prefixed
|
||||
with a 0 it’s octal and otherwise it’s decimal. If you specify invalid data
|
||||
(even if only at the beginning of the string) the functions return 0. For
|
||||
example:</p>
|
||||
<pre><code>SIZE=0
|
||||
SIZE=f
|
||||
SIZE=-
|
||||
SIZE=f1</code></pre>
|
||||
<pre><code> SIZE=0
|
||||
SIZE=f
|
||||
SIZE=-
|
||||
SIZE=f1</code></pre>
|
||||
<p>are all equivalent.</p>
|
||||
<p>Observe that:</p>
|
||||
<pre><code>SIZE=08</code></pre>
|
||||
<pre><code> SIZE=08</code></pre>
|
||||
<p>is invalid input because octal only has digits 0 - 7: the resulting size will be
|
||||
0.</p>
|
||||
<p>I discuss the signed/unsigned issue to do with curses and sizes in C being
|
||||
@@ -421,17 +421,17 @@ will end (yes things that haven’t begun can be ended).</p>
|
||||
<p>If <code>calloc()</code> fails to obtain the needed memory you’ll see something like (here it
|
||||
was before I added proper - to make the perfect and obvious pun - capsizing
|
||||
so that by setting the size to -1 it went to the max unsigned value):</p>
|
||||
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> MAXSIZE=-1 ./prog</span>
|
||||
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a><span class="ex">memory</span> error</span>
|
||||
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a><span class="ex">X:0/157</span> Y:0/42 S:3/18446744073709551614 B:0</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> MAXSIZE=-1 ./prog</span>
|
||||
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">memory</span> error</span>
|
||||
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">X:0/157</span> Y:0/42 S:3/18446744073709551614 B:0</span></code></pre></div>
|
||||
<p>BTW: There are two arrays that have to be <strong>MAXSIZE</strong> (technically + 1).</p>
|
||||
<p>Is it possible that some value specified by the user could mess this up? I do
|
||||
not know but what I do know is that because it’s unsigned it can’t be negative;
|
||||
if the max size is 0 then the array size will be 1 but it won’t matter because
|
||||
the snake size will be >= that max anyway. But here’s a curious output:</p>
|
||||
<div class="sourceCode" id="cb20"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>1 <span class="va">MAXSIZE</span><span class="op">=</span>0 <span class="ex">./prog</span></span>
|
||||
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="ex">YOU</span> WIN!</span>
|
||||
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a><span class="ex">X:78/156</span> Y:20/41 S:0/0 B:0</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb20"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a> <span class="va">SIZE</span><span class="op">=</span>1 <span class="va">MAXSIZE</span><span class="op">=</span>0 <span class="ex">./prog</span></span>
|
||||
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">YOU</span> WIN!</span>
|
||||
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">X:78/156</span> Y:20/41 S:0/0 B:0</span></code></pre></div>
|
||||
<p>Why does it show snake size as 0 when I specified 1? It’s because the max size
|
||||
is 0 and I limit the size to be no bigger than the max size.</p>
|
||||
<!--
|
||||
|
||||
@@ -329,7 +329,7 @@ hit a key every time to move because it is blocking.
|
||||
What happens if you do:
|
||||
|
||||
```sh
|
||||
WALLS= ./prog
|
||||
WALLS= ./prog
|
||||
```
|
||||
|
||||
Can you run into the wall since you didn't specify a value and the default is 1?
|
||||
@@ -343,20 +343,20 @@ If however you were to give valid input followed by invalid input the valid
|
||||
input would be parsed. For example:
|
||||
|
||||
```sh
|
||||
WALLS=1test ./prog
|
||||
WALLS=1test ./prog
|
||||
```
|
||||
|
||||
would let you go through the walls. On the other hand
|
||||
|
||||
```sh
|
||||
WALLS=test1 ./prog
|
||||
WALLS=test1 ./prog
|
||||
```
|
||||
|
||||
would not. Furthermore if you specify the same variable more than once it's the
|
||||
last one that counts. For example:
|
||||
|
||||
```sh
|
||||
WALLS=0 WALLS=1 CANNIBAL=1 CANNIBAL=0 ./prog
|
||||
WALLS=0 WALLS=1 CANNIBAL=1 CANNIBAL=0 ./prog
|
||||
```
|
||||
|
||||
would allow you to go through walls but you could not cannibalise.
|
||||
@@ -365,9 +365,9 @@ Also note that I specify base 0 which means that you can also have it in hex and
|
||||
octal. These are all the same:
|
||||
|
||||
```
|
||||
SIZE=0x3
|
||||
SIZE=3
|
||||
SIZE=03
|
||||
SIZE=0x3
|
||||
SIZE=3
|
||||
SIZE=03
|
||||
```
|
||||
|
||||
The way the functions work is if 0x (or 0X) it's considered hex; if prefixed
|
||||
@@ -376,10 +376,10 @@ with a 0 it's octal and otherwise it's decimal. If you specify invalid data
|
||||
example:
|
||||
|
||||
```
|
||||
SIZE=0
|
||||
SIZE=f
|
||||
SIZE=-
|
||||
SIZE=f1
|
||||
SIZE=0
|
||||
SIZE=f
|
||||
SIZE=-
|
||||
SIZE=f1
|
||||
```
|
||||
|
||||
are all equivalent.
|
||||
@@ -387,7 +387,7 @@ are all equivalent.
|
||||
Observe that:
|
||||
|
||||
```
|
||||
SIZE=08
|
||||
SIZE=08
|
||||
```
|
||||
|
||||
is invalid input because octal only has digits 0 - 7: the resulting size will be
|
||||
@@ -415,9 +415,9 @@ was before I added proper - to make the perfect and obvious pun - capsizing
|
||||
so that by setting the size to -1 it went to the max unsigned value):
|
||||
|
||||
```sh
|
||||
$ MAXSIZE=-1 ./prog
|
||||
memory error
|
||||
X:0/157 Y:0/42 S:3/18446744073709551614 B:0
|
||||
$ MAXSIZE=-1 ./prog
|
||||
memory error
|
||||
X:0/157 Y:0/42 S:3/18446744073709551614 B:0
|
||||
```
|
||||
|
||||
|
||||
@@ -429,9 +429,9 @@ if the max size is 0 then the array size will be 1 but it won't matter because
|
||||
the snake size will be >= that max anyway. But here's a curious output:
|
||||
|
||||
```sh
|
||||
SIZE=1 MAXSIZE=0 ./prog
|
||||
YOU WIN!
|
||||
X:78/156 Y:20/41 S:0/0 B:0
|
||||
SIZE=1 MAXSIZE=0 ./prog
|
||||
YOU WIN!
|
||||
X:78/156 Y:20/41 S:0/0 B:0
|
||||
```
|
||||
|
||||
Why does it show snake size as 0 when I specified 1? It's because the max size
|
||||
|
||||
Reference in new issue
Block a user