add rules, guidelines, fix HTML code, move compressed tarball in inventory
By changing the _inventory_order_ of the compressed tarball from
**100000** to **1415926535**, the compressed tarball will land at
the top of the secondary file list and remain still easy to find.
Updated the `manifest.numbers` spreadsheet and rebuilt
the `.entry.json` files.
Added `next/` directory to hold the next IOCCC rules and guidelines.
Added `next/README.md` that `bin/gen-top-html.sh` uses to form
the `next/index.html` file.
Added _Rules and Guidelines_ link to the sidenav bar to link to the
`next/index.html` file.
Added _IOCCC Rules_ as `next/rules.md` that `bin/gen-top-html.sh`
uses to form the `next/rules.html` file.
Added _IOCCC Guidelines_ as `next/guidelines.md` that `bin/gen-top-html.sh`
uses to form the `next/guidelines.html` file.
Changed `bin/gen-top-html.sh` VERSION from "1.2.4 2024-04-13"
to "1.3 2024-04-14".
Prevent `pandoc(1)` from interpreting the commented out language
of a markdown code block as a code class. So a markdown such as:
````
``` <!---sh-->
...
```
````
that produced HTML of the form:
```html
<pre class="<!---sh-->"><code>...</code></pre>
```
will now produce HTML of the form:
```html
<pre><code>...</code></pre>
```
NOTE: Before when the language of a markdown code block
was not commented, the HTML produced by `pandoc(1)` was
oddly indented with extra whitespace on the first line
of the code block. While commenting out the language
of the code block removed some of the odd intending,
it left a weird class in the HTML pre block that
surrounded the HTML code block. This hack prevents
`pandoc(1)` from assigning a class to the HTML pre block.
Changed `in/md2html.sh` VERSION from "1.2.1 2024-04-13"
to "1.3 2024-04-14".
Added `make gen_sitemap` to end of both `make www` and `make
quick_www` in top level Makefile.
Ram `make www` to test under macOS and to perform the above.
**IMPORTANT NOTE**: The current `next/rules.md` and `next/guidelines.md`
are simply the 2020 IOCCC Rules and Guidelines converted into
markdown form. There are **NOT** the Rules and Guidelines that
will be used the IOCCC MOCK, nor the next IOCCC.
TODO: Improve the `bin/gen-status.sh` tool to modify the top of the
`next/rules.md` and `next/guidelines.md` files to keep them
in sync with the _contest_status_ as found in `status.json`.
TODO: Improve the look and feel of the `next/rules.md` and
`next/guidelines.md` markdown files.
This commit is contained in:
1 parent
a672335d2d
commit
518a6336d0
734 files changed
+7919
-4119
No files matched your search
@@ -179,7 +179,7 @@
|
||||
},
|
||||
{
|
||||
"file_path" : "2020_ferguson1.tar.bz2",
|
||||
"inventory_order" : 100000,
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -146,7 +147,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>
|
||||
<pre class="<!---sh-->"><code> sudo xcode-select --install</code></pre>
|
||||
<pre><code> sudo xcode-select --install</code></pre>
|
||||
<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 +160,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>
|
||||
<pre class="<!---sh-->"><code> sudo dnf install ncurses-devel ncurses make gcc</code></pre>
|
||||
<pre><code> sudo dnf install ncurses-devel ncurses make gcc</code></pre>
|
||||
<p>or</p>
|
||||
<pre class="<!---sh-->"><code> # dnf install ncurses-devel ncurses make gcc</code></pre>
|
||||
<pre><code> # dnf install ncurses-devel ncurses make gcc</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> sudo yum install ncurses-devel ncurses make gcc</code></pre>
|
||||
<pre><code> sudo yum install ncurses-devel ncurses make gcc</code></pre>
|
||||
<p>or</p>
|
||||
<pre class="<!---sh-->"><code> # yum install ncurses-devel ncurses make gcc</code></pre>
|
||||
<pre><code> # yum install ncurses-devel ncurses make gcc</code></pre>
|
||||
<p>or</p>
|
||||
<pre class="<!---sh-->"><code> sudo dnf install ncurses-devel ncurses make gcc</code></pre>
|
||||
<pre><code> sudo dnf install ncurses-devel ncurses make gcc</code></pre>
|
||||
<p>or</p>
|
||||
<pre class="<!---sh-->"><code> # dnf install ncurses-devel ncurses make gcc</code></pre>
|
||||
<pre><code> # dnf install ncurses-devel ncurses make gcc</code></pre>
|
||||
<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
|
||||
|
||||
+14
-13
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -192,12 +193,12 @@ 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>
|
||||
<pre class="<!---c-->"><code> init_pair(5, COLOR_BLACK, COLOR_WHITE);
|
||||
<pre><code> init_pair(5, COLOR_BLACK, COLOR_WHITE);
|
||||
bkgd(COLOR_PAIR(5));</code></pre>
|
||||
<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>
|
||||
<pre class="<!---c-->"><code> COLOR_BLACK
|
||||
<pre><code> COLOR_BLACK
|
||||
COLOR_RED
|
||||
COLOR_GREEN
|
||||
COLOR_YELLOW
|
||||
@@ -220,16 +221,16 @@ source code (<strong>include the single quotes!</strong>) respectively:</p>
|
||||
<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>
|
||||
<pre class="<!---c-->"><code> case KEY_LEFT:
|
||||
<pre><code> case KEY_LEFT:
|
||||
case KEY_RIGHT:
|
||||
case KEY_UP:
|
||||
case KEY_DOWN:</code></pre>
|
||||
<p>Replace <code>KEY_LEFT</code> with:</p>
|
||||
<pre class="<!---c-->"><code> 'l'</code></pre>
|
||||
<pre><code> 'l'</code></pre>
|
||||
<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>
|
||||
<pre class="<!---c-->"><code> case KEY_LEFT: case 'l':</code></pre>
|
||||
<pre><code> case KEY_LEFT: case 'l':</code></pre>
|
||||
<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 +246,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>
|
||||
<pre class="<!---c-->"><code> #define J " " );</code></pre>
|
||||
<pre><code> #define J " " );</code></pre>
|
||||
<p>If you don’t care about brief displays of ‘o’ at 0,0 you can just have:</p>
|
||||
<pre class="<!---c-->"><code> #define J "");</code></pre>
|
||||
<pre><code> #define J "");</code></pre>
|
||||
<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 +263,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>
|
||||
<pre class="<!---c-->"><code> #define J Z(X:%d/%d Y:%d/%d S:%zu/%zu B:%zu\n), Y, y[-2], X,*y,A,g, c);</code></pre>
|
||||
<pre><code> #define J Z(X:%d/%d Y:%d/%d S:%zu/%zu B:%zu\n), Y, y[-2], X,*y,A,g, c);</code></pre>
|
||||
<p>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,7 +281,7 @@ 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>
|
||||
<pre class="<!---c-->"><code> #define J Z(SIZE: %zu BUGS: %zu\n), A, c);</code></pre>
|
||||
<pre><code> #define J Z(SIZE: %zu BUGS: %zu\n), A, c);</code></pre>
|
||||
<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
|
||||
@@ -307,9 +308,9 @@ come to mind as information that might be of interest.</p>
|
||||
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>
|
||||
<pre class="<!---c-->"><code> X = H / 2; Y = *x / 2;</code></pre>
|
||||
<pre><code> X = H / 2; Y = *x / 2;</code></pre>
|
||||
<p>To be something like:</p>
|
||||
<pre class="<!---c-->"><code> X = R(1,H-1);
|
||||
<pre><code> X = R(1,H-1);
|
||||
Y = R(2,*x-1);</code></pre>
|
||||
<p>Or whatever you might want it to be… (question to answer: will this work at
|
||||
all? You decide!)</p>
|
||||
@@ -407,7 +408,7 @@ 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>
|
||||
<pre class="<!---c-->"><code> if (p && !(*O>=O[1]||H>=M(1)))
|
||||
<pre><code> if (p && !(*O>=O[1]||H>=M(1)))
|
||||
{
|
||||
if (X<1||X>=H)
|
||||
X = X<1?H-1:1;
|
||||
@@ -420,7 +421,7 @@ 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>
|
||||
<pre class="<!---c-->"><code> X=X<1?1:*H-1;
|
||||
<pre><code> X=X<1?1:*H-1;
|
||||
|
||||
Y=Y<2?2:*O-1;</code></pre>
|
||||
<p>Again though that’s just the idea; the code is dramatically different. The above
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,7 +142,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>
|
||||
<pre class="<!---sh-->"><code> SIZE=0 SHED=1 SHEDS=1 EVADE=10 ./prog</code></pre>
|
||||
<pre><code> SIZE=0 SHED=1 SHEDS=1 EVADE=10 ./prog</code></pre>
|
||||
<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 +155,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>
|
||||
<pre class="<!---sh-->"><code> SIZE=100 ./prog</code></pre>
|
||||
<pre><code> SIZE=100 ./prog</code></pre>
|
||||
<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
|
||||
@@ -201,23 +202,23 @@ way negative size will force a win.</p>
|
||||
<p>Here’s a fun output:</p>
|
||||
<pre><code> < <<<+</code></pre>
|
||||
<p>That’s from:</p>
|
||||
<pre class="<!---sh-->"><code> SHED=1 SHEDS=-1 ./prog</code></pre>
|
||||
<pre><code> SHED=1 SHEDS=-1 ./prog</code></pre>
|
||||
<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>
|
||||
<p>Try this though:</p>
|
||||
<pre class="<!---sh-->"><code> SHEDS=-1 SHED=25 ./prog</code></pre>
|
||||
<pre><code> SHEDS=-1 SHED=25 ./prog</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> SIZE=1 GROW=-1 ./prog</code></pre>
|
||||
<pre><code> SIZE=1 GROW=-1 ./prog</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> YOU WIN!
|
||||
<pre><code> YOU WIN!
|
||||
X:81/156 Y:35/41 S:997/997 B:2</code></pre>
|
||||
<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
|
||||
@@ -271,7 +272,7 @@ 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>
|
||||
<pre class="<!---sh-->"><code> $ make test
|
||||
<pre><code> $ make test
|
||||
terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
terminal supports bold
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -274,7 +275,7 @@ most of them.</p>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> CANNIBAL=1 SIZE=1500 GROW=2 MAXSIZE=1600 ./prog</code></pre>
|
||||
<pre><code> CANNIBAL=1 SIZE=1500 GROW=2 MAXSIZE=1600 ./prog</code></pre>
|
||||
<p>It looked like:</p>
|
||||
<pre><code> X:55/89 Y:11/25 S:1564/1600 B:32
|
||||
##########################################################################################
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -123,7 +124,7 @@
|
||||
<!-- 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>
|
||||
<pre class="<!---sh-->"><code> SIZE=100 SHEDS=5 GROW=-10 SHED=50 MAXSIZE=250 ./prog</code></pre>
|
||||
<pre><code> SIZE=100 SHEDS=5 GROW=-10 SHED=50 MAXSIZE=250 ./prog</code></pre>
|
||||
<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
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -451,7 +452,7 @@ 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>
|
||||
<pre class="<!---sh-->"><code> SIZE=-1 ./prog
|
||||
<pre><code> SIZE=-1 ./prog
|
||||
YOU WIN!
|
||||
X:24/49 Y:8/16 S:658/658 B:0</code></pre>
|
||||
<p>Observe that the size isn’t the default 997: because the screen size is too
|
||||
@@ -499,22 +500,22 @@ 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>
|
||||
<pre class="<!---sh-->"><code> WAIT=-1 ./prog</code></pre>
|
||||
<pre><code> WAIT=-1 ./prog</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> WAIT=-1 CANNIBAL=1 ./prog</code></pre>
|
||||
<pre><code> WAIT=-1 CANNIBAL=1 ./prog</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> SIZE=50 CANNIBAL=1 WAIT=-1 ./prog</code></pre>
|
||||
<pre><code> SIZE=50 CANNIBAL=1 WAIT=-1 ./prog</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> SIZE=100 CANNIBAL=1 WAIT=-1 GROW=0 ./prog</code></pre>
|
||||
<pre><code> SIZE=100 CANNIBAL=1 WAIT=-1 GROW=0 ./prog</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> MAXSIZE=-1</code></pre>
|
||||
<pre><code> MAXSIZE=-1</code></pre>
|
||||
<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
|
||||
@@ -536,7 +537,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>
|
||||
<pre class="<!---sh-->"><code> WAIT=0 WALLS=1 CANNIBAL=1 ./prog</code></pre>
|
||||
<pre><code> WAIT=0 WALLS=1 CANNIBAL=1 ./prog</code></pre>
|
||||
<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
|
||||
@@ -553,14 +554,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>
|
||||
<pre class="<!---sh-->"><code> CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 ./prog</code></pre>
|
||||
<pre><code> CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 ./prog</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 MAXSIZE=10 ./prog</code></pre>
|
||||
<pre><code> CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 MAXSIZE=10 ./prog</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> WAIT=0 EVADE=1 GROW=-1 SIZE=9 MAXSIZE=10 CANNIBAL=1 ./prog</code></pre>
|
||||
<pre><code> WAIT=0 EVADE=1 GROW=-1 SIZE=9 MAXSIZE=10 CANNIBAL=1 ./prog</code></pre>
|
||||
<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
|
||||
@@ -568,7 +569,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>
|
||||
<pre class="<!---sh-->"><code> WAIT=5 WALLS=1 CANNIBAL=1 ./prog</code></pre>
|
||||
<pre><code> WAIT=5 WALLS=1 CANNIBAL=1 ./prog</code></pre>
|
||||
<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
|
||||
@@ -578,7 +579,7 @@ 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>
|
||||
<pre class="<!---sh-->"><code> WAIT=0 ./prog</code></pre>
|
||||
<pre><code> WAIT=0 ./prog</code></pre>
|
||||
<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!
|
||||
@@ -592,7 +593,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>
|
||||
<pre class="<!---sh-->"><code> SIZE=150 SHEDS=-5 GROW=10 SHED=50 MAXSIZE=250 ./prog</code></pre>
|
||||
<pre><code> SIZE=150 SHEDS=-5 GROW=10 SHED=50 MAXSIZE=250 ./prog</code></pre>
|
||||
<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
|
||||
@@ -608,7 +609,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>
|
||||
<pre class="<!---sh-->"><code> SIZE=100 SHEDS=5 GROW=-10 SHED=50 MAXSIZE=250 ./prog</code></pre>
|
||||
<pre><code> SIZE=100 SHEDS=5 GROW=-10 SHED=50 MAXSIZE=250 ./prog</code></pre>
|
||||
<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>
|
||||
@@ -622,7 +623,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>
|
||||
<pre class="<!---sh-->"><code> EVADE=1 CANNIBAL=1 ./prog</code></pre>
|
||||
<pre><code> EVADE=1 CANNIBAL=1 ./prog</code></pre>
|
||||
<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>
|
||||
@@ -631,7 +632,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>
|
||||
<pre class="<!---sh-->"><code> GROW=0 CANNIBAL=1 ./prog</code></pre>
|
||||
<pre><code> GROW=0 CANNIBAL=1 ./prog</code></pre>
|
||||
<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.
|
||||
@@ -650,9 +651,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>
|
||||
<pre class="<!---sh-->"><code> ./snake-colours</code></pre>
|
||||
<pre><code> ./snake-colours</code></pre>
|
||||
<p>If you want to pass in specific variables you can do that too e.g.:</p>
|
||||
<pre class="<!---sh-->"><code> CANNIBAL=1 ./snake-colours</code></pre>
|
||||
<pre><code> CANNIBAL=1 ./snake-colours</code></pre>
|
||||
<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>
|
||||
@@ -664,9 +665,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>
|
||||
<pre class="<!---sh-->"><code> ./play.sh</code></pre>
|
||||
<pre><code> ./play.sh</code></pre>
|
||||
<p>Or to make it so walls are an obstacle:</p>
|
||||
<pre class="<!---sh-->"><code> WALLS=0 ./play.sh</code></pre>
|
||||
<pre><code> WALLS=0 ./play.sh</code></pre>
|
||||
<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>
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,13 +142,13 @@ 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>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<pre><code> make</code></pre>
|
||||
<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>
|
||||
<p>For more detailed information see <a href="../../bugs.html#2020_ferguson1">2020 ferguson1 bugs</a>.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---sh-->"><code> WAIT=N WALLS=[01] EVADE=N SIZE=N MAXSIZE=N GROW=N SHEDS=N SHED=N CANNIBAL=[01] ./prog
|
||||
<pre><code> WAIT=N WALLS=[01] EVADE=N SIZE=N MAXSIZE=N GROW=N SHEDS=N SHED=N CANNIBAL=[01] ./prog
|
||||
# start pressing some arrow keys</code></pre>
|
||||
<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>
|
||||
@@ -202,7 +203,7 @@ 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>
|
||||
<pre class="<!---sh-->"><code> make test
|
||||
<pre><code> make test
|
||||
|
||||
WAIT=75 WALLS=1 CANNIBAL=1 ./prog
|
||||
|
||||
@@ -306,7 +307,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>
|
||||
<pre class="<!---sh-->"><code> man ./snake.1</code></pre>
|
||||
<pre><code> man ./snake.1</code></pre>
|
||||
<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
|
||||
@@ -640,10 +641,10 @@ email but I’m more likely to respond to mastodon messages.</p>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/prog.3-j.c">prog.3-j.c</a> - source with artistic layout and shorter j macro</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/snake.1">snake.1</a> - snake game man page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/termcaps.c">termcaps.c</a> - terminal capability test source code</li>
|
||||
<li><a href="2020_ferguson1.tar.bz2">2020_ferguson1.tar.bz2</a> - download entry tarball</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2020_ferguson1.tar.bz2">2020_ferguson1.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/COMPILING.md">COMPILING.md</a> - markdown source for COMPILING.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/HACKING.md">HACKING.md</a> - markdown source for HACKING.html</li>
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -762,9 +763,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>
|
||||
<pre class="<!---c-->"><code> for (I = 0; A && I < A - 1; ++I)</code></pre>
|
||||
<pre><code> for (I = 0; A && I < A - 1; ++I)</code></pre>
|
||||
<p>However after the loop I had this:</p>
|
||||
<pre class="<!---c-->"><code> A > 1 && q(n[A - 1],e[A - 1], 'o');</code></pre>
|
||||
<pre><code> A > 1 && q(n[A - 1],e[A - 1], 'o');</code></pre>
|
||||
<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 +780,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>
|
||||
<pre class="<!---c-->"><code> if (h) attron(m(PAIR(L)));
|
||||
<pre><code> if (h) attron(m(PAIR(L)));
|
||||
else attroff(m(PAIR(L)));</code></pre>
|
||||
<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>
|
||||
<pre class="<!---c-->"><code> attroff(m(PAIR(L)));
|
||||
<pre><code> attroff(m(PAIR(L)));
|
||||
if (h) attron(m(PAIR(L)));</code></pre>
|
||||
<p>But I then saved an extra byte by making it:</p>
|
||||
<pre class="<!---c-->"><code> attroff(m(PAIR(L)));
|
||||
<pre><code> attroff(m(PAIR(L)));
|
||||
h && attron(m(PAIR(L)));</code></pre>
|
||||
<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>
|
||||
<pre class="<!---c-->"><code> if (V && U && o) { S(N); b(1); }</code></pre>
|
||||
<pre><code> if (V && U && o) { S(N); b(1); }</code></pre>
|
||||
<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>
|
||||
<pre class="<!---c-->"><code> if (o) { S(N); b(1); }</code></pre>
|
||||
<pre><code> if (o) { S(N); b(1); }</code></pre>
|
||||
<p>Then this</p>
|
||||
<pre class="<!---c-->"><code> !o && V && U && q U,V,' ');</code></pre>
|
||||
<pre><code> !o && V && U && q U,V,' ');</code></pre>
|
||||
<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 +819,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>
|
||||
<pre class="<!---c-->"><code> !o && D && q *U,*V,' ');</code></pre>
|
||||
<pre><code> !o && D && q *U,*V,' ');</code></pre>
|
||||
<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 +832,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>
|
||||
<pre class="<!---c-->"><code> !o && q *U,*V,' ');</code></pre>
|
||||
<pre><code> !o && q *U,*V,' ');</code></pre>
|
||||
<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.
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -151,7 +152,7 @@ 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>
|
||||
<pre class="<!---sh-->"><code> $ make test</code></pre>
|
||||
<pre><code> $ make test</code></pre>
|
||||
<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
|
||||
@@ -178,7 +179,7 @@ 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>
|
||||
<pre class="<!---sh-->"><code> terminal supports cursor movement
|
||||
<pre><code> terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
terminal supports bold
|
||||
terminal supports colours
|
||||
@@ -224,12 +225,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 class="<!---sh-->"><code> $ echo $LINES $COLUMNS
|
||||
<pre><code> $ echo $LINES $COLUMNS
|
||||
42 157</code></pre>
|
||||
<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 class="<!---sh-->"><code> $ COLUMNS=55 ./prog</code></pre>
|
||||
<pre><code> $ COLUMNS=55 ./prog</code></pre>
|
||||
<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,7 +246,7 @@ 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 class="<!---sh-->"><code> LINES=20 ./prog.alt
|
||||
<pre><code> LINES=20 ./prog.alt
|
||||
LINES=20 ./snake.alt</code></pre>
|
||||
<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
|
||||
@@ -259,7 +260,7 @@ even just the <code>reset</code> command.</p>
|
||||
(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 class="<!---sh-->"><code> echo -e \\033c</code></pre>
|
||||
<pre><code> echo -e \\033c</code></pre>
|
||||
<p>Otherwise try <code>clear; stty sane</code> (that will turn on echo also) or if all else
|
||||
fails log out and back in.</p>
|
||||
<p>For more information on this subject generally see the <a href="https://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO.html">Linux keyboard and
|
||||
@@ -271,10 +272,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 class="<!---sh-->"><code> LINES=997 ./prog</code></pre>
|
||||
<pre><code> LINES=997 ./prog</code></pre>
|
||||
<p>What then? Well expect trouble; curses will not know any better and the max
|
||||
number of lines will be 997. If they were to do:</p>
|
||||
<pre class="<!---sh-->"><code> COLUMNS=997 ./prog</code></pre>
|
||||
<pre><code> COLUMNS=997 ./prog</code></pre>
|
||||
<p>Then they will see a different effect. Again the same reason: the player trying
|
||||
to be funny.</p>
|
||||
<p>The game will try and be funny in return and you can expect it to not function
|
||||
@@ -306,7 +307,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 class="<!---sh-->"><code> TERM=linux-m ./prog</code></pre>
|
||||
<pre><code> TERM=linux-m ./prog</code></pre>
|
||||
<p>But I do not specifically check if the terminal has colours. Is there a curses
|
||||
implementation that has a problem here? Below I explain what to comment out
|
||||
should you need colours to be disabled but I personally have not run into any
|
||||
@@ -328,7 +329,7 @@ support in the source code itself.</p>
|
||||
<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 class="<!---c-->"><code> #include <curses.h>
|
||||
<pre><code> #include <curses.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -338,7 +339,7 @@ confirm this I wrote the following code with the output below:</p>
|
||||
getch();
|
||||
endwin();
|
||||
}</code></pre>
|
||||
<pre class="<!---sh-->"><code> TERM=linux-m ./colour_pairs
|
||||
<pre><code> TERM=linux-m ./colour_pairs
|
||||
COLORS: 0
|
||||
COLOR_PAIRS: 0</code></pre>
|
||||
<p>Without specifying the TERM I get:</p>
|
||||
@@ -348,7 +349,7 @@ 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 class="<!---c-->"><code> int main()
|
||||
<pre><code> int main()
|
||||
{
|
||||
initscr();
|
||||
start_color();
|
||||
@@ -363,7 +364,7 @@ number is out of the range? To try and figure this out I did another test:</p>
|
||||
endwin();
|
||||
}</code></pre>
|
||||
<p>Running it like</p>
|
||||
<pre class="<!---sh-->"><code> TERM=linux-m ./colour_pairs</code></pre>
|
||||
<pre><code> TERM=linux-m ./colour_pairs</code></pre>
|
||||
<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>
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -372,7 +373,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>
|
||||
<pre class="<!---sh-->"><code> WALLS= ./prog</code></pre>
|
||||
<pre><code> WALLS= ./prog</code></pre>
|
||||
<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,12 +382,12 @@ 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>
|
||||
<pre class="<!---sh-->"><code> WALLS=1test ./prog</code></pre>
|
||||
<pre><code> WALLS=1test ./prog</code></pre>
|
||||
<p>would let you go through the walls. On the other hand</p>
|
||||
<pre class="<!---sh-->"><code> WALLS=test1 ./prog</code></pre>
|
||||
<pre><code> WALLS=test1 ./prog</code></pre>
|
||||
<p>would not. Furthermore if you specify the same variable more than once it’s the
|
||||
last one that counts. For example:</p>
|
||||
<pre class="<!---sh-->"><code> WALLS=0 WALLS=1 CANNIBAL=1 CANNIBAL=0 ./prog</code></pre>
|
||||
<pre><code> WALLS=0 WALLS=1 CANNIBAL=1 CANNIBAL=0 ./prog</code></pre>
|
||||
<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>
|
||||
@@ -421,7 +422,7 @@ 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>
|
||||
<pre class="<!---sh-->"><code> $ MAXSIZE=-1 ./prog
|
||||
<pre><code> $ MAXSIZE=-1 ./prog
|
||||
memory error
|
||||
X:0/157 Y:0/42 S:3/18446744073709551614 B:0</code></pre>
|
||||
<p>BTW: There are two arrays that have to be <strong>MAXSIZE</strong> (technically + 1).</p>
|
||||
@@ -429,7 +430,7 @@ so that by setting the size to -1 it went to the max unsigned value):</p>
|
||||
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>
|
||||
<pre class="<!---sh-->"><code> SIZE=1 MAXSIZE=0 ./prog
|
||||
<pre><code> SIZE=1 MAXSIZE=0 ./prog
|
||||
YOU WIN!
|
||||
X:78/156 Y:20/41 S:0/0 B:0</code></pre>
|
||||
<p>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