fix links in entry HTML files other than index.html
Fixed internal links in entry HTML files other than index.html. Removed links to markdown files that otherwise used to generate HTML files other than index.html. Ran `make gen_other_html` to perform the above.
This commit is contained in:
1 parent
2d3712ed36
commit
99cf726783
38 files changed
+644
-357
No files matched your search
@@ -135,7 +135,7 @@
|
|||||||
|
|
||||||
<!-- BEFORE: 1st line of markdown file: 1994/shapiro/shapiro.md -->
|
<!-- BEFORE: 1st line of markdown file: 1994/shapiro/shapiro.md -->
|
||||||
<h1 id="hints">HINTS</h1>
|
<h1 id="hints">HINTS</h1>
|
||||||
<p>For the first program (<a href="shapiro.c">shapiro.c</a>):</p>
|
<p>For the first program (<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1994/shapiro/shapiro.c">shapiro.c</a>):</p>
|
||||||
<p>This is a very simple program:</p>
|
<p>This is a very simple program:</p>
|
||||||
<pre><code> 1. #include <stdio.h>
|
<pre><code> 1. #include <stdio.h>
|
||||||
2. main()
|
2. main()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# HINTS
|
# HINTS
|
||||||
|
|
||||||
For the first program ([shapiro.c](shapiro.c)):
|
For the first program ([shapiro.c](%%REPO_URL%%/1994/shapiro/shapiro.c)):
|
||||||
|
|
||||||
|
|
||||||
This is a very simple program:
|
This is a very simple program:
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ command line tools installed which can be done like:</p>
|
|||||||
the entry, the alternate version has also removed this limitation despite <code>gcc</code>
|
the entry, the alternate version has also removed this limitation despite <code>gcc</code>
|
||||||
existing (though it’s <code>clang</code>) in macOS.</p>
|
existing (though it’s <code>clang</code>) in macOS.</p>
|
||||||
<p>Now as far as how this works if you look at the code of
|
<p>Now as far as how this works if you look at the code of
|
||||||
<a href="schweikh1.c">schweikh1.c</a>, on line 55 you’ll see a funny command (this goes for
|
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1998/schweikh1/schweikh1.c">schweikh1.c</a>, on line 55 you’ll see a funny command (this goes for
|
||||||
the alternate version as well but a bit different).</p>
|
the alternate version as well but a bit different).</p>
|
||||||
<p>Now the key is two magic numbers, one (two times) on a different line shortly below the
|
<p>Now the key is two magic numbers, one (two times) on a different line shortly below the
|
||||||
string and the other a couple lines further below.</p>
|
string and the other a couple lines further below.</p>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ the entry, the alternate version has also removed this limitation despite `gcc`
|
|||||||
existing (though it's `clang`) in macOS.
|
existing (though it's `clang`) in macOS.
|
||||||
|
|
||||||
Now as far as how this works if you look at the code of
|
Now as far as how this works if you look at the code of
|
||||||
[schweikh1.c](schweikh1.c), on line 55 you'll see a funny command (this goes for
|
[schweikh1.c](%%REPO_URL%%/1998/schweikh1/schweikh1.c), on line 55 you'll see a funny command (this goes for
|
||||||
the alternate version as well but a bit different).
|
the alternate version as well but a bit different).
|
||||||
|
|
||||||
Now the key is two magic numbers, one (two times) on a different line shortly below the
|
Now the key is two magic numbers, one (two times) on a different line shortly below the
|
||||||
|
|||||||
@@ -138,7 +138,7 @@
|
|||||||
<ol type="1">
|
<ol type="1">
|
||||||
<li><p>First, build the kernel and filesystem (just <code>make</code>). In short, you need to
|
<li><p>First, build the kernel and filesystem (just <code>make</code>). In short, you need to
|
||||||
build this on an x86 Linux machine. If you wish to try to compile on an OS
|
build this on an x86 Linux machine. If you wish to try to compile on an OS
|
||||||
other than Linux you may need modify the <a href="Makefile">Makefile</a> to compile <code>sh</code>
|
other than Linux you may need modify the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/gavin/Makefile">Makefile</a> to compile <code>sh</code>
|
||||||
using a cross-compiler that produces ELF binaries - i.e. a cross-compiler
|
using a cross-compiler that produces ELF binaries - i.e. a cross-compiler
|
||||||
targeting x86 Linux. In short, you need to build this on an x86 Linux machine.</p></li>
|
targeting x86 Linux. In short, you need to build this on an x86 Linux machine.</p></li>
|
||||||
<li><p>Next, find a suitable machine to run the OS on. It should be perfectly safe,
|
<li><p>Next, find a suitable machine to run the OS on. It should be perfectly safe,
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
1. First, build the kernel and filesystem (just `make`). In short, you need to
|
1. First, build the kernel and filesystem (just `make`). In short, you need to
|
||||||
build this on an x86 Linux machine. If you wish to try to compile on an OS
|
build this on an x86 Linux machine. If you wish to try to compile on an OS
|
||||||
other than Linux you may need modify the [Makefile](Makefile) to compile `sh`
|
other than Linux you may need modify the [Makefile](%%REPO_URL%%/2004/gavin/Makefile) to compile `sh`
|
||||||
using a cross-compiler that produces ELF binaries - i.e. a cross-compiler
|
using a cross-compiler that produces ELF binaries - i.e. a cross-compiler
|
||||||
targeting x86 Linux. In short, you need to build this on an x86 Linux machine.
|
targeting x86 Linux. In short, you need to build this on an x86 Linux machine.
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@
|
|||||||
the font description embedded in the source code. Notice that you don’t pass the
|
the font description embedded in the source code. Notice that you don’t pass the
|
||||||
file name, but the actual content as one long character string! If you want to
|
file name, but the actual content as one long character string! If you want to
|
||||||
define your personal music font, you can of course do so. The file layout must
|
define your personal music font, you can of course do so. The file layout must
|
||||||
be exactly the same as <a href="deckmyn.c">deckmyn.c</a> though, only the locations of
|
be exactly the same as <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/deckmyn/deckmyn.c">deckmyn.c</a> though, only the locations of
|
||||||
space (<code>" "</code>) may differ.</p>
|
space (<code>" "</code>) may differ.</p>
|
||||||
<p>The second argument is the actual music. Again it is one long string, not a file
|
<p>The second argument is the actual music. Again it is one long string, not a file
|
||||||
name. But it is possible to save your music in a file, of course.</p>
|
name. But it is possible to save your music in a file, of course.</p>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ This minimalistic music notator expects two command line arguments. The first is
|
|||||||
the font description embedded in the source code. Notice that you don't pass the
|
the font description embedded in the source code. Notice that you don't pass the
|
||||||
file name, but the actual content as one long character string! If you want to
|
file name, but the actual content as one long character string! If you want to
|
||||||
define your personal music font, you can of course do so. The file layout must
|
define your personal music font, you can of course do so. The file layout must
|
||||||
be exactly the same as [deckmyn.c](deckmyn.c) though, only the locations of
|
be exactly the same as [deckmyn.c](%%REPO_URL%%/2012/deckmyn/deckmyn.c) though, only the locations of
|
||||||
space (`" "`) may differ.
|
space (`" "`) may differ.
|
||||||
|
|
||||||
The second argument is the actual music. Again it is one long string, not a file
|
The second argument is the actual music. Again it is one long string, not a file
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ indirect source.</p>
|
|||||||
of up to 32 volumes, each with 64x64x64 cells. The volume 0 is the ‘top level’
|
of up to 32 volumes, each with 64x64x64 cells. The volume 0 is the ‘top level’
|
||||||
volume where the camera goes. Each cell of a volume can be empty, filled with a
|
volume where the camera goes. Each cell of a volume can be empty, filled with a
|
||||||
material, or another volume. The roundish characters in
|
material, or another volume. The roundish characters in
|
||||||
<a href="../old_default.scene">old_default.scene</a> and the carpet on the floor in this
|
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/hou/old_default.scene">old_default.scene</a> and the carpet on the floor in this
|
||||||
file are examples where a cell is defined to another volume. Materials will be
|
file are examples where a cell is defined to another volume. Materials will be
|
||||||
explained later.</p>
|
explained later.</p>
|
||||||
<p>The volume shader for the i-th volume is named as the (i+1)-th capital letter.
|
<p>The volume shader for the i-th volume is named as the (i+1)-th capital letter.
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ indirect source.
|
|||||||
of up to 32 volumes, each with 64x64x64 cells. The volume 0 is the 'top level'
|
of up to 32 volumes, each with 64x64x64 cells. The volume 0 is the 'top level'
|
||||||
volume where the camera goes. Each cell of a volume can be empty, filled with a
|
volume where the camera goes. Each cell of a volume can be empty, filled with a
|
||||||
material, or another volume. The roundish characters in
|
material, or another volume. The roundish characters in
|
||||||
[old_default.scene](../old_default.scene) and the carpet on the floor in this
|
[old_default.scene](%%REPO_URL%%/2013/hou/old_default.scene) and the carpet on the floor in this
|
||||||
file are examples where a cell is defined to another volume. Materials will be
|
file are examples where a cell is defined to another volume. Materials will be
|
||||||
explained later.
|
explained later.
|
||||||
|
|
||||||
|
|||||||
+13
-13
@@ -187,8 +187,8 @@ instruction set is carefully selected to minimize the sizes of both <code><ma
|
|||||||
</ul></li>
|
</ul></li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>The instructions have variable lengths, but many of them are represented as one
|
<p>The instructions have variable lengths, but many of them are represented as one
|
||||||
printable character. (See <a href="machine.rb">machine.rb</a> and
|
printable character. (See <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2014/endoh1/machine.rb">machine.rb</a> and
|
||||||
<a href="assemble.rb">assemble.rb</a> in detail.) The mapping between instructions and
|
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2014/endoh1/assemble.rb">assemble.rb</a> in detail.) The mapping between instructions and
|
||||||
characters is also carefully designed to minimize <code><VM code></code>, which makes the
|
characters is also carefully designed to minimize <code><VM code></code>, which makes the
|
||||||
resulted program non-human-readable.</p>
|
resulted program non-human-readable.</p>
|
||||||
<h2 id="how-did-i-create-the-main-code">How did I create the main code?</h2>
|
<h2 id="how-did-i-create-the-main-code">How did I create the main code?</h2>
|
||||||
@@ -196,8 +196,8 @@ resulted program non-human-readable.</p>
|
|||||||
code in Ruby syntax and created a Ruby-to-VM compiler that involves alpha
|
code in Ruby syntax and created a Ruby-to-VM compiler that involves alpha
|
||||||
renaming and automatic register allocation only for this purpose.</p>
|
renaming and automatic register allocation only for this purpose.</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="src.rb">src.rb</a>: the source code of QR code encoder written in Ruby syntax.</li>
|
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2014/endoh1/src.rb">src.rb</a>: the source code of QR code encoder written in Ruby syntax.</li>
|
||||||
<li><a href="vm.c">vm.c</a>: the source code of the VM.</li>
|
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2014/endoh1/vm.c">vm.c</a>: the source code of the VM.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>The compiler tool chain is the following.</p>
|
<p>The compiler tool chain is the following.</p>
|
||||||
<pre><code> src.rb interp.c
|
<pre><code> src.rb interp.c
|
||||||
@@ -232,14 +232,14 @@ renaming and automatic register allocation only for this purpose.</p>
|
|||||||
V
|
V
|
||||||
prog.c</code></pre>
|
prog.c</code></pre>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="parse.rb">parse.rb</a> converts Ruby to AST.</li>
|
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2014/endoh1/parse.rb">parse.rb</a> converts Ruby to AST.</li>
|
||||||
<li><a href="serialize.rb">serialize.rb</a> converts AST to intermediate instruction sequence.</li>
|
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2014/endoh1/serialize.rb">serialize.rb</a> converts AST to intermediate instruction sequence.</li>
|
||||||
<li><a href="alpha.rb">alpha.rb</a> applies “alpha-renaming” to the instruction sequence.</li>
|
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2014/endoh1/alpha.rb">alpha.rb</a> applies “alpha-renaming” to the instruction sequence.</li>
|
||||||
<li><a href="register.rb">register.rb</a> applies “register allocation”.</li>
|
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2014/endoh1/register.rb">register.rb</a> applies “register allocation”.</li>
|
||||||
<li><a href="assemble.rb">assemble.rb</a> converts the sequence to the final stack-machine instructions.</li>
|
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2014/endoh1/assemble.rb">assemble.rb</a> converts the sequence to the final stack-machine instructions.</li>
|
||||||
<li><a href="interp.c">interp.c</a> is an implementation of the VM.</li>
|
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2014/endoh1/interp.c">interp.c</a> is an implementation of the VM.</li>
|
||||||
<li><a href="link.rb">link.rb</a> generates <code>main.c</code> by linking the instructions and interpreter source.</li>
|
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2014/endoh1/link.rb">link.rb</a> generates <code>main.c</code> by linking the instructions and interpreter source.</li>
|
||||||
<li><a href="gen-prog.c">gen-prog.c</a> generates <a href="prog.c">prog.c</a> based on <code>main.c</code>.</li>
|
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2014/endoh1/gen-prog.c">gen-prog.c</a> generates <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2014/endoh1/prog.c">prog.c</a> based on <code>main.c</code>.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>You can run the process by <code>rake</code> command. <code>ruby-minisat</code> gem is needed.</p>
|
<p>You can run the process by <code>rake</code> command. <code>ruby-minisat</code> gem is needed.</p>
|
||||||
<pre><code> $ gem install ruby-minisat
|
<pre><code> $ gem install ruby-minisat
|
||||||
@@ -254,7 +254,7 @@ renaming and automatic register allocation only for this purpose.</p>
|
|||||||
found at
|
found at
|
||||||
<code>https://play.google.com/store/apps/details?id=com.google.zxing.client.android</code>
|
<code>https://play.google.com/store/apps/details?id=com.google.zxing.client.android</code>
|
||||||
but it appears to no longer exist.</p>
|
but it appears to no longer exist.</p>
|
||||||
<p>You can use <a href="tool.rb">tool.rb</a> to convert the output to a png file.</p>
|
<p>You can use <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2014/endoh1/tool.rb">tool.rb</a> to convert the output to a png file.</p>
|
||||||
<pre><code> ./main Hello | ruby tool.rb > hello.png
|
<pre><code> ./main Hello | ruby tool.rb > hello.png
|
||||||
|
|
||||||
$ zbarimg -q hello.png
|
$ zbarimg -q hello.png
|
||||||
|
|||||||
+13
-13
@@ -60,8 +60,8 @@ code>` and `<VM code>`.
|
|||||||
* putchar, exit
|
* putchar, exit
|
||||||
|
|
||||||
The instructions have variable lengths, but many of them are represented as one
|
The instructions have variable lengths, but many of them are represented as one
|
||||||
printable character. (See [machine.rb](machine.rb) and
|
printable character. (See [machine.rb](%%REPO_URL%%/2014/endoh1/machine.rb) and
|
||||||
[assemble.rb](assemble.rb) in detail.) The mapping between instructions and
|
[assemble.rb](%%REPO_URL%%/2014/endoh1/assemble.rb) in detail.) The mapping between instructions and
|
||||||
characters is also carefully designed to minimize `<VM code>`, which makes the
|
characters is also carefully designed to minimize `<VM code>`, which makes the
|
||||||
resulted program non-human-readable.
|
resulted program non-human-readable.
|
||||||
|
|
||||||
@@ -72,8 +72,8 @@ It is too tedious to write the machine language directly. So I wrote the source
|
|||||||
code in Ruby syntax and created a Ruby-to-VM compiler that involves alpha
|
code in Ruby syntax and created a Ruby-to-VM compiler that involves alpha
|
||||||
renaming and automatic register allocation only for this purpose.
|
renaming and automatic register allocation only for this purpose.
|
||||||
|
|
||||||
* [src.rb](src.rb): the source code of QR code encoder written in Ruby syntax.
|
* [src.rb](%%REPO_URL%%/2014/endoh1/src.rb): the source code of QR code encoder written in Ruby syntax.
|
||||||
* [vm.c](vm.c): the source code of the VM.
|
* [vm.c](%%REPO_URL%%/2014/endoh1/vm.c): the source code of the VM.
|
||||||
|
|
||||||
The compiler tool chain is the following.
|
The compiler tool chain is the following.
|
||||||
|
|
||||||
@@ -111,14 +111,14 @@ The compiler tool chain is the following.
|
|||||||
prog.c
|
prog.c
|
||||||
```
|
```
|
||||||
|
|
||||||
* [parse.rb](parse.rb) converts Ruby to AST.
|
* [parse.rb](%%REPO_URL%%/2014/endoh1/parse.rb) converts Ruby to AST.
|
||||||
* [serialize.rb](serialize.rb) converts AST to intermediate instruction sequence.
|
* [serialize.rb](%%REPO_URL%%/2014/endoh1/serialize.rb) converts AST to intermediate instruction sequence.
|
||||||
* [alpha.rb](alpha.rb) applies "alpha-renaming" to the instruction sequence.
|
* [alpha.rb](%%REPO_URL%%/2014/endoh1/alpha.rb) applies "alpha-renaming" to the instruction sequence.
|
||||||
* [register.rb](register.rb) applies "register allocation".
|
* [register.rb](%%REPO_URL%%/2014/endoh1/register.rb) applies "register allocation".
|
||||||
* [assemble.rb](assemble.rb) converts the sequence to the final stack-machine instructions.
|
* [assemble.rb](%%REPO_URL%%/2014/endoh1/assemble.rb) converts the sequence to the final stack-machine instructions.
|
||||||
* [interp.c](interp.c) is an implementation of the VM.
|
* [interp.c](%%REPO_URL%%/2014/endoh1/interp.c) is an implementation of the VM.
|
||||||
* [link.rb](link.rb) generates `main.c` by linking the instructions and interpreter source.
|
* [link.rb](%%REPO_URL%%/2014/endoh1/link.rb) generates `main.c` by linking the instructions and interpreter source.
|
||||||
* [gen-prog.c](gen-prog.c) generates [prog.c](prog.c) based on `main.c`.
|
* [gen-prog.c](%%REPO_URL%%/2014/endoh1/gen-prog.c) generates [prog.c](%%REPO_URL%%/2014/endoh1/prog.c) based on `main.c`.
|
||||||
|
|
||||||
You can run the process by `rake` command. `ruby-minisat` gem is needed.
|
You can run the process by `rake` command. `ruby-minisat` gem is needed.
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ but it appears to no longer exist.
|
|||||||
|
|
||||||
[1]: http://zbar.sourceforge.net/
|
[1]: http://zbar.sourceforge.net/
|
||||||
|
|
||||||
You can use [tool.rb](tool.rb) to convert the output to a png file.
|
You can use [tool.rb](%%REPO_URL%%/2014/endoh1/tool.rb) to convert the output to a png file.
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
./main Hello | ruby tool.rb > hello.png
|
./main Hello | ruby tool.rb > hello.png
|
||||||
|
|||||||
@@ -254,17 +254,17 @@ Obscurity now increased!</p>
|
|||||||
<p>Around this time, the formatted code no longer fit with the 2053 limit (due to a
|
<p>Around this time, the formatted code no longer fit with the 2053 limit (due to a
|
||||||
lack of comprehension of the significance of the space-after-brace-and-semi
|
lack of comprehension of the significance of the space-after-brace-and-semi
|
||||||
rule, and a layout program that did not know how to do this). Frustrated, I
|
rule, and a layout program that did not know how to do this). Frustrated, I
|
||||||
wrote another program to reformat this code into <a href="rule2.c">rule2.c</a>, which was a
|
wrote another program to reformat this code into <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/burton/rule2.c">rule2.c</a>, which was a
|
||||||
single C token per line. This solved the formatting problem, but intriguingly
|
single C token per line. This solved the formatting problem, but intriguingly
|
||||||
introduced another. Now I was faced with the 4096 rule as well as the 2053
|
introduced another. Now I was faced with the 4096 rule as well as the 2053
|
||||||
rule. But this was a challenge!</p>
|
rule. But this was a challenge!</p>
|
||||||
<p>I wrote a de-obfuscator, and worked on both the unobfuscated version and the
|
<p>I wrote a de-obfuscator, and worked on both the unobfuscated version and the
|
||||||
master code. I worked on the template formatter to make this as automated as
|
master code. I worked on the template formatter to make this as automated as
|
||||||
possible, and worked to achieve both a perfectly presented picture AND the
|
possible, and worked to achieve both a perfectly presented picture AND the
|
||||||
single-line exactly-at-4096 <a href="rule2.c">rule2.c</a>.</p>
|
single-line exactly-at-4096 <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/burton/rule2.c">rule2.c</a>.</p>
|
||||||
<p>Finally, “perfection”, with assignable memories! Where perfection is defined
|
<p>Finally, “perfection”, with assignable memories! Where perfection is defined
|
||||||
as a nicely formatted picture at less than 2053, and exactly 4096
|
as a nicely formatted picture at less than 2053, and exactly 4096
|
||||||
token-per-line <a href="rule2.c">rule2.c</a>.</p>
|
token-per-line <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/burton/rule2.c">rule2.c</a>.</p>
|
||||||
<h2 id="testing-testing-testing">Testing Testing Testing</h2>
|
<h2 id="testing-testing-testing">Testing Testing Testing</h2>
|
||||||
<p>Cross platform, it works on Mac OSX, fails on Linux. It works if <code>#include <stdlib.h></code>, but it dumps core without it (the only change!)?. 64-bits without
|
<p>Cross platform, it works on Mac OSX, fails on Linux. It works if <code>#include <stdlib.h></code>, but it dumps core without it (the only change!)?. 64-bits without
|
||||||
proper declaration of <code>int</code>s in syscalls yields unpredictable results. 32-bit
|
proper declaration of <code>int</code>s in syscalls yields unpredictable results. 32-bit
|
||||||
@@ -298,7 +298,7 @@ unobfuscated version; think: a complex chain of ternary expressions is a single
|
|||||||
statement). This involved careful examination of all the expressions within the
|
statement). This involved careful examination of all the expressions within the
|
||||||
logic, trying to find a different way of getting the same result, but typically
|
logic, trying to find a different way of getting the same result, but typically
|
||||||
within fewer bytes than before to allow for the added logic to fix the bugs.</p>
|
within fewer bytes than before to allow for the added logic to fix the bugs.</p>
|
||||||
<p>The bugs were fixed, the code re-formatted, and <a href="rule2.c">rule2.c</a> was again
|
<p>The bugs were fixed, the code re-formatted, and <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/burton/rule2.c">rule2.c</a> was again
|
||||||
4096 bytes.</p>
|
4096 bytes.</p>
|
||||||
<p>But wouldn’t it be nice for unary plus to work?</p>
|
<p>But wouldn’t it be nice for unary plus to work?</p>
|
||||||
<p>Add unary plus, re-balance. Little things now take a fair bit of work. Adding
|
<p>Add unary plus, re-balance. Little things now take a fair bit of work. Adding
|
||||||
@@ -327,7 +327,7 @@ relatively tight. But changing around the stable initialization code – by now
|
|||||||
the largest piece of logic – yielded the necessary bytes, and improved
|
the largest piece of logic – yielded the necessary bytes, and improved
|
||||||
obscurity by double duty encoding of the operations initialization.</p>
|
obscurity by double duty encoding of the operations initialization.</p>
|
||||||
<p>The utility is now truly functional, and feature complete, and obscure. Without
|
<p>The utility is now truly functional, and feature complete, and obscure. Without
|
||||||
<a href="src.doc.txt">src.doc.txt</a> (basic documentation of the code structure), and some
|
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/burton/src.doc.txt">src.doc.txt</a> (basic documentation of the code structure), and some
|
||||||
commented expanded logic stashed away, and the familiarity I have with the code
|
commented expanded logic stashed away, and the familiarity I have with the code
|
||||||
having written and revised it repeatedly, I would not even want to attempt to
|
having written and revised it repeatedly, I would not even want to attempt to
|
||||||
decipher the logic. Many times in the debugging, I was thwarted by my own
|
decipher the logic. Many times in the debugging, I was thwarted by my own
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ But wouldn't it be nice to have assignable memories?
|
|||||||
Around this time, the formatted code no longer fit with the 2053 limit (due to a
|
Around this time, the formatted code no longer fit with the 2053 limit (due to a
|
||||||
lack of comprehension of the significance of the space-after-brace-and-semi
|
lack of comprehension of the significance of the space-after-brace-and-semi
|
||||||
rule, and a layout program that did not know how to do this). Frustrated, I
|
rule, and a layout program that did not know how to do this). Frustrated, I
|
||||||
wrote another program to reformat this code into [rule2.c](rule2.c), which was a
|
wrote another program to reformat this code into [rule2.c](%%REPO_URL%%/2015/burton/rule2.c), which was a
|
||||||
single C token per line. This solved the formatting problem, but intriguingly
|
single C token per line. This solved the formatting problem, but intriguingly
|
||||||
introduced another. Now I was faced with the 4096 rule as well as the 2053
|
introduced another. Now I was faced with the 4096 rule as well as the 2053
|
||||||
rule. But this was a challenge!
|
rule. But this was a challenge!
|
||||||
@@ -154,11 +154,11 @@ rule. But this was a challenge!
|
|||||||
I wrote a de-obfuscator, and worked on both the unobfuscated version and the
|
I wrote a de-obfuscator, and worked on both the unobfuscated version and the
|
||||||
master code. I worked on the template formatter to make this as automated as
|
master code. I worked on the template formatter to make this as automated as
|
||||||
possible, and worked to achieve both a perfectly presented picture AND the
|
possible, and worked to achieve both a perfectly presented picture AND the
|
||||||
single-line exactly-at-4096 [rule2.c](rule2.c).
|
single-line exactly-at-4096 [rule2.c](%%REPO_URL%%/2015/burton/rule2.c).
|
||||||
|
|
||||||
Finally, "perfection", with assignable memories! Where perfection is defined
|
Finally, "perfection", with assignable memories! Where perfection is defined
|
||||||
as a nicely formatted picture at less than 2053, and exactly 4096
|
as a nicely formatted picture at less than 2053, and exactly 4096
|
||||||
token-per-line [rule2.c](rule2.c).
|
token-per-line [rule2.c](%%REPO_URL%%/2015/burton/rule2.c).
|
||||||
|
|
||||||
|
|
||||||
## Testing Testing Testing
|
## Testing Testing Testing
|
||||||
@@ -202,7 +202,7 @@ statement). This involved careful examination of all the expressions within the
|
|||||||
logic, trying to find a different way of getting the same result, but typically
|
logic, trying to find a different way of getting the same result, but typically
|
||||||
within fewer bytes than before to allow for the added logic to fix the bugs.
|
within fewer bytes than before to allow for the added logic to fix the bugs.
|
||||||
|
|
||||||
The bugs were fixed, the code re-formatted, and [rule2.c](rule2.c) was again
|
The bugs were fixed, the code re-formatted, and [rule2.c](%%REPO_URL%%/2015/burton/rule2.c) was again
|
||||||
4096 bytes.
|
4096 bytes.
|
||||||
|
|
||||||
But wouldn't it be nice for unary plus to work?
|
But wouldn't it be nice for unary plus to work?
|
||||||
@@ -243,7 +243,7 @@ the largest piece of logic -- yielded the necessary bytes, and improved
|
|||||||
obscurity by double duty encoding of the operations initialization.
|
obscurity by double duty encoding of the operations initialization.
|
||||||
|
|
||||||
The utility is now truly functional, and feature complete, and obscure. Without
|
The utility is now truly functional, and feature complete, and obscure. Without
|
||||||
[src.doc.txt](src.doc.txt) (basic documentation of the code structure), and some
|
[src.doc.txt](%%REPO_URL%%/2015/burton/src.doc.txt) (basic documentation of the code structure), and some
|
||||||
commented expanded logic stashed away, and the familiarity I have with the code
|
commented expanded logic stashed away, and the familiarity I have with the code
|
||||||
having written and revised it repeatedly, I would not even want to attempt to
|
having written and revised it repeatedly, I would not even want to attempt to
|
||||||
decipher the logic. Many times in the debugging, I was thwarted by my own
|
decipher the logic. Many times in the debugging, I was thwarted by my own
|
||||||
|
|||||||
@@ -138,7 +138,7 @@
|
|||||||
<p><code>calc</code> is a recursive-descent parser. It allocates from the stack deep enough
|
<p><code>calc</code> is a recursive-descent parser. It allocates from the stack deep enough
|
||||||
that all expressions are exhausted before the recursion stack depth reaches the
|
that all expressions are exhausted before the recursion stack depth reaches the
|
||||||
allocations. The memory map and source is documented in
|
allocations. The memory map and source is documented in
|
||||||
<a href="src.doc.txt">src.doc.txt</a>. Tokens are encoded using values 0-20, where 0 is an
|
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/burton/src.doc.txt">src.doc.txt</a>. Tokens are encoded using values 0-20, where 0 is an
|
||||||
invalid token, 1 is minus, 2 is space, 3 is plus, etc. The necessary constants
|
invalid token, 1 is minus, 2 is space, 3 is plus, etc. The necessary constants
|
||||||
are derived at the start of the program, using the guarantee that globals are
|
are derived at the start of the program, using the guarantee that globals are
|
||||||
initialized to zero; so a correct NULL pointer is obtained from an uninitialized
|
initialized to zero; so a correct NULL pointer is obtained from an uninitialized
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
`calc` is a recursive-descent parser. It allocates from the stack deep enough
|
`calc` is a recursive-descent parser. It allocates from the stack deep enough
|
||||||
that all expressions are exhausted before the recursion stack depth reaches the
|
that all expressions are exhausted before the recursion stack depth reaches the
|
||||||
allocations. The memory map and source is documented in
|
allocations. The memory map and source is documented in
|
||||||
[src.doc.txt](src.doc.txt). Tokens are encoded using values 0-20, where 0 is an
|
[src.doc.txt](%%REPO_URL%%/2015/burton/src.doc.txt). Tokens are encoded using values 0-20, where 0 is an
|
||||||
invalid token, 1 is minus, 2 is space, 3 is plus, etc. The necessary constants
|
invalid token, 1 is minus, 2 is space, 3 is plus, etc. The necessary constants
|
||||||
are derived at the start of the program, using the guarantee that globals are
|
are derived at the start of the program, using the guarantee that globals are
|
||||||
initialized to zero; so a correct NULL pointer is obtained from an uninitialized
|
initialized to zero; so a correct NULL pointer is obtained from an uninitialized
|
||||||
|
|||||||
@@ -139,14 +139,14 @@
|
|||||||
<p>The source code of the font is <a href="glyphs.txt">glyphs.txt</a>, which is a sequence of
|
<p>The source code of the font is <a href="glyphs.txt">glyphs.txt</a>, which is a sequence of
|
||||||
chunks that is a ASCII code (65-90) followed by points data: <code>x,y,ctrl</code>.</p>
|
chunks that is a ASCII code (65-90) followed by points data: <code>x,y,ctrl</code>.</p>
|
||||||
<p>If <code>ctrl</code> is 1, the point is used as control point for quadratic bezier curve.</p>
|
<p>If <code>ctrl</code> is 1, the point is used as control point for quadratic bezier curve.</p>
|
||||||
<p><a href="code.c">code.c</a> is the main logic for the program, which has some placeholders
|
<p><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/code.c">code.c</a> is the main logic for the program, which has some placeholders
|
||||||
for font data and something.</p>
|
for font data and something.</p>
|
||||||
<p>It decompresses the font data and renders a given text by projection. It
|
<p>It decompresses the font data and renders a given text by projection. It
|
||||||
exploits <code>C99</code>’s <code>double complex</code> type to represent 2D points, but carefully
|
exploits <code>C99</code>’s <code>double complex</code> type to represent 2D points, but carefully
|
||||||
coded so that it does not require any <code>math.h</code> functions; you don’t have to pass
|
coded so that it does not require any <code>math.h</code> functions; you don’t have to pass
|
||||||
<code>-lm</code> to <code>cc</code>.</p>
|
<code>-lm</code> to <code>cc</code>.</p>
|
||||||
<p><a href="tmpl.txt">tmpl.txt</a> is a template for the program. <a href="gen.rb">gen.rb</a> composes
|
<p><a href="tmpl.txt">tmpl.txt</a> is a template for the program. <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/gen.rb">gen.rb</a> composes
|
||||||
the all items and generates <a href="prog.c">prog.c</a>.</p>
|
the all items and generates <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/prog.c">prog.c</a>.</p>
|
||||||
<hr style="width:10%;text-align:left;margin-left:0">
|
<hr style="width:10%;text-align:left;margin-left:0">
|
||||||
<p>Jump to: <a href="#">top</a></p>
|
<p>Jump to: <a href="#">top</a></p>
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ chunks that is a ASCII code (65-90) followed by points data: `x,y,ctrl`.
|
|||||||
|
|
||||||
If `ctrl` is 1, the point is used as control point for quadratic bezier curve.
|
If `ctrl` is 1, the point is used as control point for quadratic bezier curve.
|
||||||
|
|
||||||
[code.c](code.c) is the main logic for the program, which has some placeholders
|
[code.c](%%REPO_URL%%/2020/endoh2/code.c) is the main logic for the program, which has some placeholders
|
||||||
for font data and something.
|
for font data and something.
|
||||||
|
|
||||||
It decompresses the font data and renders a given text by projection. It
|
It decompresses the font data and renders a given text by projection. It
|
||||||
@@ -15,8 +15,8 @@ exploits `C99`'s `double complex` type to represent 2D points, but carefully
|
|||||||
coded so that it does not require any `math.h` functions; you don't have to pass
|
coded so that it does not require any `math.h` functions; you don't have to pass
|
||||||
`-lm` to `cc`.
|
`-lm` to `cc`.
|
||||||
|
|
||||||
[tmpl.txt](tmpl.txt) is a template for the program. [gen.rb](gen.rb) composes
|
[tmpl.txt](tmpl.txt) is a template for the program. [gen.rb](%%REPO_URL%%/2020/endoh2/gen.rb) composes
|
||||||
the all items and generates [prog.c](prog.c).
|
the all items and generates [prog.c](%%REPO_URL%%/2020/endoh2/prog.c).
|
||||||
|
|
||||||
|
|
||||||
<hr style="width:10%;text-align:left;margin-left:0">
|
<hr style="width:10%;text-align:left;margin-left:0">
|
||||||
|
|||||||
@@ -139,7 +139,8 @@ C99+ and ncurses; note that for some platforms (e.g. Red Hat based Linux) you
|
|||||||
will need two different packages: the library itself but also the dev package
|
will need two different packages: the library itself but also the dev package
|
||||||
that has the header files etc. If you use the Makefile obviously you need <code>make</code>
|
that has the header files etc. If you use the Makefile obviously you need <code>make</code>
|
||||||
too.</p>
|
too.</p>
|
||||||
<p>In <a href="gameplay.md">gameplay.md</a> I show how to easily customise the colours, set up
|
<p>In <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/gameplay.html">gameplay.html</a>
|
||||||
|
I show how to easily customise the colours, set up
|
||||||
different gameplay modes and various other things. The troubleshooting.md
|
different gameplay modes and various other things. The troubleshooting.md
|
||||||
and terminals.md as well as bugs.md include a variety of information
|
and terminals.md as well as bugs.md include a variety of information
|
||||||
should you run into trouble.</p>
|
should you run into trouble.</p>
|
||||||
@@ -162,7 +163,7 @@ matters; I only have Intel CPUs and arm64 (MacBook Pro M1).</p>
|
|||||||
<p>You don’t need Xcode itself and it appears that the command line tools (as above
|
<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
|
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
|
needs to be done. But I’m not actually sure of this - I’m seeing conflicting
|
||||||
information and it’s been too long; anyway there’s always <a href="https://www.macports.org">MacPorts</a> and also
|
information and it’s been too long; anyway there’s always [MacPorts][] and also
|
||||||
Homebrew which should be sufficient; I do <em>NOT</em> recommend Homebrew however:
|
Homebrew which should be sufficient; I do <em>NOT</em> recommend Homebrew however:
|
||||||
it takes ownership of /usr/local: as in the user you run it as is the new owner
|
it takes ownership of /usr/local: as in the user you run it as is the new owner
|
||||||
so that you don’t need sudo because … Well never mind.</p>
|
so that you don’t need sudo because … Well never mind.</p>
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ will need two different packages: the library itself but also the dev package
|
|||||||
that has the header files etc. If you use the Makefile obviously you need `make`
|
that has the header files etc. If you use the Makefile obviously you need `make`
|
||||||
too.
|
too.
|
||||||
|
|
||||||
In [gameplay.md](gameplay.md) I show how to easily customise the colours, set up
|
In [gameplay.html](%%REPO_URL%%/2020/ferguson1/gameplay.html)
|
||||||
|
I show how to easily customise the colours, set up
|
||||||
different gameplay modes and various other things. The troubleshooting.md
|
different gameplay modes and various other things. The troubleshooting.md
|
||||||
and terminals.md as well as bugs.md include a variety of information
|
and terminals.md as well as bugs.md include a variety of information
|
||||||
should you run into trouble.
|
should you run into trouble.
|
||||||
@@ -110,8 +111,6 @@ If it's an unsigned int I believe you will have to opt for an unsigned long (so
|
|||||||
Anything else I do not know other than just changing the typedef and updating to
|
Anything else I do not know other than just changing the typedef and updating to
|
||||||
the proper function (and/or cast to the right type).
|
the proper function (and/or cast to the right type).
|
||||||
|
|
||||||
[MacPorts]: https://www.macports.org
|
|
||||||
|
|
||||||
|
|
||||||
<hr style="width:10%;text-align:left;margin-left:0">
|
<hr style="width:10%;text-align:left;margin-left:0">
|
||||||
|
|
||||||
|
|||||||
@@ -217,9 +217,9 @@ but that changes the background of the program anyway.</p>
|
|||||||
COLOR_MAGENTA
|
COLOR_MAGENTA
|
||||||
COLOR_CYAN
|
COLOR_CYAN
|
||||||
COLOR_WHITE</code></pre>
|
COLOR_WHITE</code></pre>
|
||||||
<p>See Linux Journal for more information article
|
<p>See <a href="https://www.linuxjournal.com/content/programming-color-ncurses">Linux Journal for more information
|
||||||
<a href="https://www.linuxjournal.com/content/programming-color-ncurses" class="uri">https://www.linuxjournal.com/content/programming-color-ncurses</a> for more
|
article</a>
|
||||||
details.</p>
|
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>
|
<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
|
<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>
|
source code (<strong>include the single quotes!</strong>) respectively:</p>
|
||||||
|
|||||||
@@ -100,9 +100,9 @@ The standard colour identifiers are:
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
See Linux Journal for more information article
|
See [Linux Journal for more information
|
||||||
<https://www.linuxjournal.com/content/programming-color-ncurses> for more
|
article](https://www.linuxjournal.com/content/programming-color-ncurses)
|
||||||
details.
|
for more details.
|
||||||
|
|
||||||
|
|
||||||
## Modifying the characters for the wall, bug and snake
|
## Modifying the characters for the wall, bug and snake
|
||||||
|
|||||||
+25
-11
@@ -162,7 +162,9 @@ size 10 of course (but in fact if you observe the snake won’t appear to be
|
|||||||
of size 20 yet).</p>
|
of size 20 yet).</p>
|
||||||
<p>There probably are combinations that can test these types of things I just
|
<p>There probably are combinations that can test these types of things I just
|
||||||
don’t at this time remember any I might have done.</p>
|
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>
|
<div id="stillsnake">
|
||||||
|
<h1 id="the-snake-doesnt-seem-to-be-moving"><a href="#toc">The snake doesn’t seem to be moving</a></h1>
|
||||||
|
</div>
|
||||||
<p>One way to show this is in full is to set the initial size and growth size to a
|
<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>
|
high value; then try each one individually. For example:</p>
|
||||||
<pre><code> SIZE=100 ./prog</code></pre>
|
<pre><code> SIZE=100 ./prog</code></pre>
|
||||||
@@ -172,7 +174,7 @@ When it has reached the full size then the entire body of the snake will
|
|||||||
start to move too (i.e. if the tail isn’t moving it is growing or else paused).</p>
|
start to move too (i.e. if the tail isn’t moving it is growing or else paused).</p>
|
||||||
<p>In several tests I set the initial size to a high value, the max to a higher
|
<p>In several tests I set the initial size to a high value, the max to a higher
|
||||||
value still and enabled cannibalism and much of the screen was full of the snake
|
value still and enabled cannibalism and much of the screen was full of the snake
|
||||||
before it started to move. The <a href="cannibalism.log.md">cannibalism.log.md</a> has some examples of both
|
before it started to move. The [cannibalism.log.md][] has some examples of both
|
||||||
cannibalism and a long snake that didn’t move for most of the game.</p>
|
cannibalism and a long snake that didn’t move for most of the game.</p>
|
||||||
<p>If however you let the snake get to the full size then eat a bug there can
|
<p>If however you let the snake get to the full size then eat a bug there can
|
||||||
be a moment of lingering where it appears the snake moves for a few places
|
be a moment of lingering where it appears the snake moves for a few places
|
||||||
@@ -186,11 +188,15 @@ occupied or not.</p>
|
|||||||
<p>Basically if the snake head is moving you can consider the snake to be
|
<p>Basically if the snake head is moving you can consider the snake to be
|
||||||
moving or growing and that’s the important point (if you have the default
|
moving or growing and that’s the important point (if you have the default
|
||||||
status line you can also see the coordinates being updated to show this).</p>
|
status line you can also see the coordinates being updated to show this).</p>
|
||||||
<h1 id="getch-also-accepts-input-from-some-input-hardware-other-than-keyboards"><a name="getch" href="#toc">getch() also accepts input from some input hardware other than keyboards</a></h1>
|
<div id="getch">
|
||||||
|
<h1 id="getch-also-accepts-input-from-some-input-hardware-other-than-keyboards"><a href="#toc">getch() also accepts input from some input hardware other than keyboards</a></h1>
|
||||||
|
</div>
|
||||||
<p>On my MacBook Pro the trackpad has actually triggered directions; if I were to
|
<p>On my MacBook Pro the trackpad has actually triggered directions; if I were to
|
||||||
swipe up and then down the snake would run into itself. I believe this has to do
|
swipe up and then down the snake would run into itself. I believe this has to do
|
||||||
with the function call <code>keypad(v, 1);</code> which enables arrow keys.</p>
|
with the function call <code>keypad(v, 1);</code> which enables arrow keys.</p>
|
||||||
<h1 id="size0-is-the-same-as-size1-and-other-oddities"><a name="size" href="#toc">SIZE=0 is the same as SIZE=1 and other oddities</a></h1>
|
<div id="size">
|
||||||
|
<h1 id="size0-is-the-same-as-size1-and-other-oddities"><a href="#toc">SIZE=0 is the same as SIZE=1 and other oddities</a></h1>
|
||||||
|
</div>
|
||||||
<p>What this means is that for both you will only have the snake head. At this point
|
<p>What this means is that for both you will only have the snake head. At this point
|
||||||
you can safely go back on yourself even without cannibalism enabled. This is
|
you can safely go back on yourself even without cannibalism enabled. This is
|
||||||
intentional; a snake size of 0 is pointless but why should it not be playable
|
intentional; a snake size of 0 is pointless but why should it not be playable
|
||||||
@@ -222,7 +228,7 @@ way negative size will force a win.</p>
|
|||||||
head several places until you end up getting to the max size (by way of it
|
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
|
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
|
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>
|
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/gameplay.html">gameplay.html</a> file.</p>
|
||||||
<p>Here’s another thing to be aware of. Let’s say you do:</p>
|
<p>Here’s another thing to be aware of. Let’s say you do:</p>
|
||||||
<pre><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
|
<p>How many bugs will it take before you win? In fact it’s two: you would see the
|
||||||
@@ -230,7 +236,9 @@ head twice: the second time once you ‘shrink’ down to size 0; it would then
|
|||||||
that if you get another bug you will be at the ‘max size’:</p>
|
that if you get another bug you will be at the ‘max size’:</p>
|
||||||
<pre><code> YOU WIN!
|
<pre><code> YOU WIN!
|
||||||
X:81/156 Y:35/41 S:997/997 B:2</code></pre>
|
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>
|
<div id="bitetail">
|
||||||
|
<h1 id="i-was-a-few-places-behind-my-tail-and-i-ran-into-it"><a href="#toc">‘I was a few places behind my tail and I ran into it!’</a></h1>
|
||||||
|
</div>
|
||||||
<p>I.e. what happens if you’re growing - for example after just eating a bug - and
|
<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
|
you’re racing towards your tail? If you’re behind it should be fine since you’re
|
||||||
going the same speed as the snake is, right? Not quite. Because you’re growing
|
going the same speed as the snake is, right? Not quite. Because you’re growing
|
||||||
@@ -238,7 +246,9 @@ you might end up running into your tail (depending on how much you’ve left to
|
|||||||
grow and how far away from your tail)! This happened to me once and it surprised
|
grow and how far away from your tail)! This happened to me once and it surprised
|
||||||
me and I figured I better note it.</p>
|
me and I figured I better note it.</p>
|
||||||
<p><strong>Remember: the tail at that point isn’t moving yet; the snake is growing!</strong></p>
|
<p><strong>Remember: the tail at that point isn’t moving yet; the snake is growing!</strong></p>
|
||||||
<h1 id="with-negative-growth-the-snake-drops-from-the-middle-of-the-body"><a name="middleofsnake" href="#toc">With negative growth the snake drops from the middle of the body</a></h1>
|
<div id="middleofsnake">
|
||||||
|
<h1 id="with-negative-growth-the-snake-drops-from-the-middle-of-the-body"><a href="#toc">With negative growth the snake drops from the middle of the body</a></h1>
|
||||||
|
</div>
|
||||||
<p>For instance it might look like this (the first line is as it happens, the
|
<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
|
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>
|
rest of the snake has gone through). Doing <code>SHED=100 SHEDS=-1</code>:</p>
|
||||||
@@ -261,8 +271,10 @@ go there! :)</p>
|
|||||||
that’s how they grow in the wild so it’s a misnomer. The shrinking was only
|
that’s how they grow in the wild so it’s a misnomer. The shrinking was only
|
||||||
‘discovered’ because it’s an unsigned number but happily it allows for different
|
‘discovered’ because it’s an unsigned number but happily it allows for different
|
||||||
gameplay modes.</p>
|
gameplay modes.</p>
|
||||||
<h1 id="it-looks-like-the-bug-is-in-the-snake"><a name="buginsnake" href="#toc">It looks like the bug is in the snake</a></h1>
|
<div id="buginsnake">
|
||||||
<p>I show a different example in the <a href="crazy.log.md">crazy.log.md</a> file but what defines a coordinate
|
<h1 id="it-looks-like-the-bug-is-in-the-snake"><a href="#toc">It looks like the bug is in the snake</a></h1>
|
||||||
|
</div>
|
||||||
|
<p>I show a different example in the [crazy.log.md][] file but what defines a coordinate
|
||||||
which the snake occupies? If the snake breaks apart then the only part
|
which the snake occupies? If the snake breaks apart then the only part
|
||||||
of the screen the snake is occupying is the place which is actually moving: if
|
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
|
the snake decreases in size by 3 then the three respective characters you can go
|
||||||
@@ -271,7 +283,9 @@ 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
|
<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>
|
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>
|
<div id="bugplacement">
|
||||||
|
<h1 id="on-the-safety-of-the-bug-placement-loop"><a href="#toc">On the safety of the bug placement loop</a></h1>
|
||||||
|
</div>
|
||||||
<p>Ilya Kurdyukov shared concern for the loop in the bug placement routine: is it
|
<p>Ilya Kurdyukov shared concern for the loop in the bug placement routine: is it
|
||||||
safe? What he refers to is that it’s a potential infinite loop. But is it? I
|
safe? What he refers to is that it’s a potential infinite loop. But is it? I
|
||||||
understand the concern and it’s something I played with a lot to be sure that it
|
understand the concern and it’s something I played with a lot to be sure that it
|
||||||
@@ -308,7 +322,7 @@ that 49 is the max snake size. How is this derived and why?</p>
|
|||||||
(<code>playable_rows * playable_columns</code>). I have played with this many
|
(<code>playable_rows * playable_columns</code>). I have played with this many
|
||||||
times and I do not believe there should be a problem. If there is it’s from a
|
times and I do not believe there should be a problem. If there is it’s from a
|
||||||
very poor implementation of rand() and I discuss this in
|
very poor implementation of rand() and I discuss this in
|
||||||
<a href="troubleshooting.html">troubleshooting.html</a> (<a href="troubleshooting.md">troubleshooting.md</a> on GitHub).</p>
|
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/troubleshooting.html">troubleshooting.html</a>.</p>
|
||||||
<p>There I also give some test outputs without the cap in place to give an idea of
|
<p>There I also give some test outputs without the cap in place to give an idea of
|
||||||
when it became a problem (or would have). In short this is known but I do not
|
when it became a problem (or would have). In short this is known but I do not
|
||||||
think it will be a problem and I have given resolutions. In any event without
|
think it will be a problem and I have given resolutions. In any event without
|
||||||
|
|||||||
+29
-18
@@ -38,7 +38,9 @@ There probably are combinations that can test these types of things I just
|
|||||||
don't at this time remember any I might have done.
|
don't at this time remember any I might have done.
|
||||||
|
|
||||||
|
|
||||||
# <a name="stillsnake" href="#toc">The snake doesn't seem to be moving</a>
|
<div id="stillsnake">
|
||||||
|
# <a href="#toc">The snake doesn't seem to be moving</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
One way to show this is in full is to set the initial size and growth size to a
|
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:
|
high value; then try each one individually. For example:
|
||||||
@@ -73,13 +75,17 @@ moving or growing and that's the important point (if you have the default
|
|||||||
status line you can also see the coordinates being updated to show this).
|
status line you can also see the coordinates being updated to show this).
|
||||||
|
|
||||||
|
|
||||||
# <a name="getch" href="#toc">getch() also accepts input from some input hardware other than keyboards</a>
|
<div id="getch">
|
||||||
|
# <a href="#toc">getch() also accepts input from some input hardware other than keyboards</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
On my MacBook Pro the trackpad has actually triggered directions; if I were to
|
On my MacBook Pro the trackpad has actually triggered directions; if I were to
|
||||||
swipe up and then down the snake would run into itself. I believe this has to do
|
swipe up and then down the snake would run into itself. I believe this has to do
|
||||||
with the function call `keypad(v, 1);` which enables arrow keys.
|
with the function call `keypad(v, 1);` which enables arrow keys.
|
||||||
|
|
||||||
# <a name="size" href="#toc">SIZE=0 is the same as SIZE=1 and other oddities</a>
|
<div id="size">
|
||||||
|
# <a href="#toc">SIZE=0 is the same as SIZE=1 and other oddities</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
What this means is that for both you will only have the snake head. At this point
|
What this means is that for both you will only have the snake head. At this point
|
||||||
you can safely go back on yourself even without cannibalism enabled. This is
|
you can safely go back on yourself even without cannibalism enabled. This is
|
||||||
@@ -133,7 +139,7 @@ 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
|
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
|
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
|
this is the basis of the grow/shrink mode of play that I talk about in the
|
||||||
[gameplay.html][] ([gameplay.md][] on GitHub) file.
|
[gameplay.html][] file.
|
||||||
|
|
||||||
Here's another thing to be aware of. Let's say you do:
|
Here's another thing to be aware of. Let's say you do:
|
||||||
|
|
||||||
@@ -150,7 +156,9 @@ that if you get another bug you will be at the 'max size':
|
|||||||
X:81/156 Y:35/41 S:997/997 B:2
|
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>
|
<div id="bitetail">
|
||||||
|
# <a href="#toc">'I was a few places behind my tail and I ran into it!'</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
I.e. what happens if you're growing - for example after just eating a bug - and
|
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
|
you're racing towards your tail? If you're behind it should be fine since you're
|
||||||
@@ -162,7 +170,9 @@ me and I figured I better note it.
|
|||||||
**Remember: the tail at that point isn't moving yet; the snake is growing!**
|
**Remember: the tail at that point isn't moving yet; the snake is growing!**
|
||||||
|
|
||||||
|
|
||||||
# <a name="middleofsnake" href="#toc">With negative growth the snake drops from the middle of the body</a>
|
<div id="middleofsnake">
|
||||||
|
# <a href="#toc">With negative growth the snake drops from the middle of the body</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
For instance it might look like this (the first line is as it happens, the
|
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
|
second pointing to where it happens and the third being what's left after the
|
||||||
@@ -196,7 +206,9 @@ that's how they grow in the wild so it's a misnomer. The shrinking was only
|
|||||||
'discovered' because it's an unsigned number but happily it allows for different
|
'discovered' because it's an unsigned number but happily it allows for different
|
||||||
gameplay modes.
|
gameplay modes.
|
||||||
|
|
||||||
# <a name="buginsnake" href="#toc">It looks like the bug is in the snake</a>
|
<div id="buginsnake">
|
||||||
|
# <a href="#toc">It looks like the bug is in the snake</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
I show a different example in the [crazy.log.md][] file but what defines a coordinate
|
I show a different example in the [crazy.log.md][] file but what defines a coordinate
|
||||||
which the snake occupies? If the snake breaks apart then the only part
|
which the snake occupies? If the snake breaks apart then the only part
|
||||||
@@ -212,7 +224,9 @@ something like:
|
|||||||
This is because the snake is no longer there: in fact in this run the snake was
|
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.
|
quite a bit lower on the screen and 25 in length.
|
||||||
|
|
||||||
# <a name="bugplacement" href="#toc">On the safety of the bug placement loop</a>
|
<div id="bugplacement">
|
||||||
|
# <a href="#toc">On the safety of the bug placement loop</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
Ilya Kurdyukov shared concern for the loop in the bug placement routine: is it
|
Ilya Kurdyukov shared concern for the loop in the bug placement routine: is it
|
||||||
safe? What he refers to is that it's a potential infinite loop. But is it? I
|
safe? What he refers to is that it's a potential infinite loop. But is it? I
|
||||||
@@ -257,7 +271,7 @@ With 10 rows and columns it's calculated as `7 * 7` (i.e. it's
|
|||||||
(`playable_rows * playable_columns`). I have played with this many
|
(`playable_rows * playable_columns`). I have played with this many
|
||||||
times and I do not believe there should be a problem. If there is it's from a
|
times and I do not believe there should be a problem. If there is it's from a
|
||||||
very poor implementation of rand() and I discuss this in
|
very poor implementation of rand() and I discuss this in
|
||||||
[troubleshooting.html][] ([troubleshooting.md][] on GitHub).
|
[troubleshooting.html][].
|
||||||
|
|
||||||
There I also give some test outputs without the cap in place to give an idea of
|
There I also give some test outputs without the cap in place to give an idea of
|
||||||
when it became a problem (or would have). In short this is known but I do not
|
when it became a problem (or would have). In short this is known but I do not
|
||||||
@@ -268,16 +282,13 @@ The obvious question is why didn't I put in a break? Because of the IOCCC size
|
|||||||
rule 2 and what would it do anyway? I guess it would win but to my mind that is
|
rule 2 and what would it do anyway? I guess it would win but to my mind that is
|
||||||
a bug and I prefer putting in restrictions to try and make it very unlikely.
|
a bug and I prefer putting in restrictions to try and make it very unlikely.
|
||||||
|
|
||||||
[crazy.log.md]: crazy.log.md
|
[crazy.log.html]: %%REPO_URL%%/2020/ferguson1/crazy.log.html
|
||||||
[gameplay.md]: gameplay.md
|
[gameplay.html]: %%REPO_URL%%/2020/ferguson1/gameplay.html
|
||||||
[troubleshooting.md]: troubleshooting.md
|
[troubleshooting.html]: %%REPO_URL%%/2020/ferguson1/troubleshooting.html
|
||||||
[troubleshooting.html]: troubleshooting.html
|
[gameplay.html]: %%REPO_URL%%/2020/ferguson1/gameplay.html
|
||||||
[gameplay.html]: gameplay.html
|
[cannibalism.log.html]: %%REPO_URL%%/2020/ferguson1/cannibalism.log.html
|
||||||
[gameplay.md]: gameplay.md
|
|
||||||
[cannibalism.log.md]: cannibalism.log.md
|
|
||||||
[https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms]: https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms
|
[https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms]: https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms
|
||||||
[spoilers]: spoilers.markdown
|
[spoilers.html]: %%REPO_URL%%/2020/ferguson1/spoilers.html
|
||||||
[screenshot of halfwidth vs fullwidth]: halfwidth_vs_fullwidth.png
|
|
||||||
|
|
||||||
|
|
||||||
<hr style="width:10%;text-align:left;margin-left:0">
|
<hr style="width:10%;text-align:left;margin-left:0">
|
||||||
|
|||||||
@@ -134,7 +134,8 @@
|
|||||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||||
|
|
||||||
<!-- BEFORE: 1st line of markdown file: 2020/ferguson1/cannibalism.log.md -->
|
<!-- BEFORE: 1st line of markdown file: 2020/ferguson1/cannibalism.log.md -->
|
||||||
<h1 id="extreme-cannibalism-in-2020-ioccc-dont-tread-on-me-snake-game">Extreme cannibalism in <a href="/2020/ferguson1/prog.c">2020 IOCCC ‘Don’t tread on me’ Snake game</a></h1>
|
<h1 id="extreme-cannibalism-in-a-snake-game">Extreme cannibalism in a Snake game</h1>
|
||||||
|
<p>See the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/prog.c">2020 IOCCC ‘Don’t tread on me’ Snake game source code</a>.</p>
|
||||||
<p>To give an idea what cannibalism can look like (it’s I believe a unique feature
|
<p>To give an idea what cannibalism can look like (it’s I believe a unique feature
|
||||||
to any other version of Snake), this file shows just how extreme cannibalism can
|
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
|
get with a long snake. I made a few changes, described below, to make it easier
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
# Extreme cannibalism in [2020 IOCCC 'Don't tread on me' Snake game](/2020/ferguson1/prog.c)
|
# Extreme cannibalism in a Snake game
|
||||||
|
|
||||||
|
See the [2020 IOCCC 'Don't tread on me' Snake game source code](%%REPO_URL%%/2020/ferguson1/prog.c).
|
||||||
|
|
||||||
To give an idea what cannibalism can look like (it's I believe a unique feature
|
To give an idea what cannibalism can look like (it's I believe a unique feature
|
||||||
to any other version of Snake), this file shows just how extreme cannibalism can
|
to any other version of Snake), this file shows just how extreme cannibalism can
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ something of my mum’s speciality. It’s complicated and I should warn that no
|
|||||||
has seemed to get it down as well as she has but it’s well worth the effort if
|
has seemed to get it down as well as she has but it’s well worth the effort if
|
||||||
you love chocolate and have the time and patience.</p>
|
you love chocolate and have the time and patience.</p>
|
||||||
<p>My late stepmum who only liked white ‘chocolate’ loved this cake! The picture
|
<p>My late stepmum who only liked white ‘chocolate’ loved this cake! The picture
|
||||||
below is after it’s been iced. The image <a href="ioccc-cake.jpg">ioccc-cake.jpg</a> was a
|
below is after it’s been iced. The image <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/cake.jpg">cake.jpg</a> was a
|
||||||
feeble attempt at drawing <code>IOCCC</code> into the cake before icing, a different time.
|
feeble attempt at drawing <code>IOCCC</code> into the cake before icing, a different time.
|
||||||
The picture below was taken for my birthday (14 February) in 2022 as it’s the
|
The picture below was taken for my birthday (14 February) in 2022 as it’s the
|
||||||
best one I have:</p>
|
best one I have:</p>
|
||||||
@@ -161,9 +161,9 @@ there of course. Please make sure to mention me so I get a push notification as
|
|||||||
I don’t check it very often. Thanks and again enjoy!</p>
|
I don’t check it very often. Thanks and again enjoy!</p>
|
||||||
<h2 id="measurements">Measurements</h2>
|
<h2 id="measurements">Measurements</h2>
|
||||||
<p>This was originally taken from an American magazine for women so the
|
<p>This was originally taken from an American magazine for women so the
|
||||||
measurements are in the US standards. A nice resource (that has much more than
|
measurements are in the US standards. There is a
|
||||||
just cooking) is <a href="http://www.onlineconversion.com/cooking.htm" class="uri">http://www.onlineconversion.com/cooking.htm</a>. This will
|
<a href="http://www.onlineconversion.com/cooking.htm">nice resource</a> that has much more than
|
||||||
particularly matter for cups, teaspoons, tablespoons and ounces.</p>
|
just cooking). This will particularly matter for cups, teaspoons, tablespoons and ounces.</p>
|
||||||
<h2 id="bakers-chocolate">Baker’s chocolate</h2>
|
<h2 id="bakers-chocolate">Baker’s chocolate</h2>
|
||||||
<p>Baker’s chocolate is a brand name and the product in question is unsweetened
|
<p>Baker’s chocolate is a brand name and the product in question is unsweetened
|
||||||
chocolate bars used for baking. According to a <a href="https://www.davidlebovitz.com/chocolate-faqs/">chocolates FAQ</a> it might be
|
chocolate bars used for baking. According to a <a href="https://www.davidlebovitz.com/chocolate-faqs/">chocolates FAQ</a> it might be
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ has seemed to get it down as well as she has but it's well worth the effort if
|
|||||||
you love chocolate and have the time and patience.
|
you love chocolate and have the time and patience.
|
||||||
|
|
||||||
My late stepmum who only liked white 'chocolate' loved this cake! The picture
|
My late stepmum who only liked white 'chocolate' loved this cake! The picture
|
||||||
below is after it's been iced. The image [ioccc-cake.jpg](ioccc-cake.jpg) was a
|
below is after it's been iced. The image [cake.jpg](%%REPO_URL%%/2020/ferguson1/cake.jpg) was a
|
||||||
feeble attempt at drawing `IOCCC` into the cake before icing, a different time.
|
feeble attempt at drawing `IOCCC` into the cake before icing, a different time.
|
||||||
The picture below was taken for my birthday (14 February) in 2022 as it's the
|
The picture below was taken for my birthday (14 February) in 2022 as it's the
|
||||||
best one I have:
|
best one I have:
|
||||||
@@ -35,9 +35,9 @@ I don't check it very often. Thanks and again enjoy!
|
|||||||
## Measurements
|
## Measurements
|
||||||
|
|
||||||
This was originally taken from an American magazine for women so the
|
This was originally taken from an American magazine for women so the
|
||||||
measurements are in the US standards. A nice resource (that has much more than
|
measurements are in the US standards. There is a
|
||||||
just cooking) is <http://www.onlineconversion.com/cooking.htm>. This will
|
[nice resource](http://www.onlineconversion.com/cooking.htm) that has much more than
|
||||||
particularly matter for cups, teaspoons, tablespoons and ounces.
|
just cooking). This will particularly matter for cups, teaspoons, tablespoons and ounces.
|
||||||
|
|
||||||
|
|
||||||
## Baker's chocolate
|
## Baker's chocolate
|
||||||
@@ -197,7 +197,7 @@ bowl can sit in.
|
|||||||
thick BUT not too thick. **Make *SURE* ICING DOES *NOT* GET WET!** The idea is to
|
thick BUT not too thick. **Make *SURE* ICING DOES *NOT* GET WET!** The idea is to
|
||||||
**MAKE THE BOWL IT'S IN COLD *BUT TO NOT LET THE ICING GET WET!***
|
**MAKE THE BOWL IT'S IN COLD *BUT TO NOT LET THE ICING GET WET!***
|
||||||
|
|
||||||
[IOCCC and chocolate]: ioccc-and-chocolate.pdf
|
[IOCCC and chocolate]: %%REPO_URL%%/2020/ferguson1/cake.jpg
|
||||||
[chocolates FAQ]: https://www.davidlebovitz.com/chocolate-faqs/
|
[chocolates FAQ]: https://www.davidlebovitz.com/chocolate-faqs/
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+102
-49
@@ -138,7 +138,7 @@
|
|||||||
have included much more than just the input keys and a few printouts of the
|
have included much more than just the input keys and a few printouts of the
|
||||||
game. For normal play you probably don’t even need this file at all unless it be
|
game. For normal play you probably don’t even need this file at all unless it be
|
||||||
for the input keys.</p>
|
for the input keys.</p>
|
||||||
<p><a name="toc"></a></p>
|
<div id="toc">
|
||||||
<ol type="1">
|
<ol type="1">
|
||||||
<li><p><a href="#support">Testing terminal environment/capabilities</a></p></li>
|
<li><p><a href="#support">Testing terminal environment/capabilities</a></p></li>
|
||||||
<li><p><a href="#input">Input keys</a></p></li>
|
<li><p><a href="#input">Input keys</a></p></li>
|
||||||
@@ -179,14 +179,19 @@ for the input keys.</p>
|
|||||||
</ul></li>
|
</ul></li>
|
||||||
<li><p><a href="#conclusions">Conclusion (and inspirational words for everyone)</a></p></li>
|
<li><p><a href="#conclusions">Conclusion (and inspirational words for everyone)</a></p></li>
|
||||||
</ol>
|
</ol>
|
||||||
<h1 id="testing-terminal-environmentcapabilities">1. <a name="support" href="#toc">Testing terminal environment/capabilities</a></h1>
|
</div>
|
||||||
|
<div id="support">
|
||||||
|
<h1 id="testing-terminal-environmentcapabilities">1. <a href="#toc">Testing terminal environment/capabilities</a></h1>
|
||||||
|
</div>
|
||||||
<p>Most people probably won’t have any issue at all but for those who have any
|
<p>Most people probably won’t have any issue at all but for those who have any
|
||||||
problems with the terminal see the <a href="terminals.html">terminals.html</a> (<a href="terminals.md">terminals.md</a> on
|
problems with the terminal see the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/terminals.html">terminals.html</a>
|
||||||
GitHub) file for more information on the terminal capabilities testing utility I
|
file for more information on the terminal capabilities testing utility I
|
||||||
include.</p>
|
include.</p>
|
||||||
<p>For troubleshooting other problems see <a href="troubleshooting.html">troubleshooting.html</a>
|
<p>For troubleshooting other problems see <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/troubleshooting.html">troubleshooting.html</a>
|
||||||
(<a href="troubleshooting.md">troubleshooting.md</a> on GitHub) and <a href="bugs.html">bugs.html</a> (<a href="bugs.md">bugs.md</a> on GitHub).</p>
|
and <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/bugs.html">bugs.html</a>.</p>
|
||||||
<h1 id="input-keys">2. <a name="input" href="#toc">Input keys</a></h1>
|
<div id="input">
|
||||||
|
<h1 id="input-keys">2. <a href="#toc">Input keys</a></h1>
|
||||||
|
</div>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Left, right, up and down <strong>arrow keys</strong>: move that direction.</li>
|
<li>Left, right, up and down <strong>arrow keys</strong>: move that direction.</li>
|
||||||
<li><code>q</code> (and <code>Q</code>): quit the game.</li>
|
<li><code>q</code> (and <code>Q</code>): quit the game.</li>
|
||||||
@@ -195,14 +200,16 @@ Note that no other keys will resume the game; however if you press a key
|
|||||||
that <code>getch()</code> picks up on and the game is not paused then it will be as if
|
that <code>getch()</code> picks up on and the game is not paused then it will be as if
|
||||||
you pressed the current direction key (assuming you already moved the snake).</li>
|
you pressed the current direction key (assuming you already moved the snake).</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h1 id="gameplay">3. <a name="gameplay" href="#toc">Gameplay</a></h1>
|
<h1 id="gameplay">3. <a href="#toc">Gameplay</a></h1>
|
||||||
<p>Here I will show the initial screen as well as what a few things look like. If
|
<p>Here I will show the initial screen as well as what a few things look like. If
|
||||||
you don’t feel you need this but you want to configure colours jump to <a href="#colours">colour
|
you don’t feel you need this but you want to configure colours jump to <a href="#colours">colour
|
||||||
selection</a>. You can also jump to <a href="#modes">gameplay modes</a> or <a href="#variables">game
|
selection</a>. You can also jump to <a href="#modes">gameplay modes</a> or <a href="#variables">game
|
||||||
variables</a>.</p>
|
variables</a>.</p>
|
||||||
<p>The bug colour by default is white; the snake head colour is red and the snake
|
<p>The bug colour by default is white; the snake head colour is red and the snake
|
||||||
body colour is green. The walls are cyan.</p>
|
body colour is green. The walls are cyan.</p>
|
||||||
<h2 id="gameplay-the-initial-screen"><a name="initial" href="#toc">Gameplay: The initial screen</a></h2>
|
<div id="initial">
|
||||||
|
<h2 id="gameplay-the-initial-screen"><a href="#toc">Gameplay: The initial screen</a></h2>
|
||||||
|
</div>
|
||||||
<p>When you load the game you will see a screen that looks something like the
|
<p>When you load the game you will see a screen that looks something like the
|
||||||
below. Note that the top line is the score/status line: the top wall is at line
|
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
|
1 and the left wall is column 0. Below I use the coordinates in the X/Y order
|
||||||
@@ -242,7 +249,9 @@ size.</p></li>
|
|||||||
it will always have an upper limit depending on the terminal size.</p></li>
|
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>
|
<li><p>The number of bugs eaten so far is 0.</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h2 id="gameplay-playing-the-game"><a name="playing" href="#toc">Gameplay: Playing the game</a></h2>
|
<div id="playing">
|
||||||
|
<h2 id="gameplay-playing-the-game"><a href="#toc">Gameplay: Playing the game</a></h2>
|
||||||
|
</div>
|
||||||
<pre><code> X:39/49 Y:8/16 S:5/658 B:0
|
<pre><code> X:39/49 Y:8/16 S:5/658 B:0
|
||||||
##################################################
|
##################################################
|
||||||
# #
|
# #
|
||||||
@@ -300,7 +309,9 @@ Let’s do that:</p>
|
|||||||
##################################################</code></pre>
|
##################################################</code></pre>
|
||||||
<p>Observe that the bug was eaten and a new bug spawned elsewhere. I went left
|
<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>
|
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>
|
<div id="walls">
|
||||||
|
<h1 id="gameplay-walls"><a href="#toc">Gameplay: Walls</a></h1>
|
||||||
|
</div>
|
||||||
<p>By default walls are passable (<strong>WALLS=1</strong>). Let’s get to full size and go
|
<p>By default walls are passable (<strong>WALLS=1</strong>). Let’s get to full size and go
|
||||||
through the top wall:</p>
|
through the top wall:</p>
|
||||||
<pre><code> X:36/49 Y:15/16 S:10/658 B:1
|
<pre><code> X:36/49 Y:15/16 S:10/658 B:1
|
||||||
@@ -363,7 +374,9 @@ might look like (I set the starting size to 150 and had only just started):</p>
|
|||||||
<p>If I continue going up I will see:</p>
|
<p>If I continue going up I will see:</p>
|
||||||
<pre><code>OUCH!
|
<pre><code>OUCH!
|
||||||
X:20/49 Y:1/16 S:150/658 B:0</code></pre>
|
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>
|
<div id="cannibalism">
|
||||||
|
<h1 id="gameplay-cannibalism"><a href="#toc">Gameplay: Cannibalism</a></h1>
|
||||||
|
</div>
|
||||||
<p>By default cannibalism is disabled (<strong>CANNIBAL=0</strong>) so if you run into yourself it might look
|
<p>By default cannibalism is disabled (<strong>CANNIBAL=0</strong>) so if you run into yourself it might look
|
||||||
something like:</p>
|
something like:</p>
|
||||||
<pre><code> X:45/49 Y:10/16 S:10/658 B:1
|
<pre><code> X:45/49 Y:10/16 S:10/658 B:1
|
||||||
@@ -448,16 +461,20 @@ will see that the arrow has moved over:</p>
|
|||||||
left go right etc.) and then after some length (but before you get beyond the
|
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
|
snake) turn (so that you go perpendicular) and then watch as the snake starts
|
||||||
unwinding at one place and then suddenly unwinds another direction.</p>
|
unwinding at one place and then suddenly unwinds another direction.</p>
|
||||||
<p>An example of extreme cannibalism is in the <a href="cannibalism.log.html">cannibalism.log.html</a>
|
<p>An example of extreme cannibalism is in the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/cannibalism.log.html">cannibalism.log.html</a>
|
||||||
(<a href="cannibalism.log.md">cannibalism.log.md</a> on GitHub) file. It explains information about the file
|
file. It explains information about the file
|
||||||
including how to find the bug, head and tail of the snake, at least where it was
|
including how to find the bug, head and tail of the snake, at least where it was
|
||||||
documented. The first run has several dumps. The final example has the snake
|
documented. The first run has several dumps. The final example has the snake
|
||||||
inside itself.</p>
|
inside itself.</p>
|
||||||
<h1 id="gameplay-shedding-stretching"><a name="shedding" href="#toc">Gameplay: Shedding (stretching)</a></h1>
|
<div id="shedding">
|
||||||
|
<h1 id="gameplay-shedding-stretching"><a href="#toc">Gameplay: Shedding (stretching)</a></h1>
|
||||||
|
</div>
|
||||||
<p>This feature will make you grow by the value of <strong>SHEDS</strong> for every <strong>SHED</strong>
|
<p>This feature will make you grow by the value of <strong>SHEDS</strong> for every <strong>SHED</strong>
|
||||||
movements (the counter isn’t incremented when you eat a bug). Basically growing
|
movements (the counter isn’t incremented when you eat a bug). Basically growing
|
||||||
without eating a bug (stretching would be better name here).</p>
|
without eating a bug (stretching would be better name here).</p>
|
||||||
<h1 id="gameplay-winning"><a name="winning" href="#toc">Gameplay: Winning</a></h1>
|
<div id="winning">
|
||||||
|
<h1 id="gameplay-winning"><a href="#toc">Gameplay: Winning</a></h1>
|
||||||
|
</div>
|
||||||
<p>If you ever get to the <strong>MAXSIZE</strong> the game is won. You can force a win by
|
<p>If you ever get to the <strong>MAXSIZE</strong> the game is won. You can force a win by
|
||||||
setting the max size to a smaller value than the size you specify (or the
|
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
|
default) or setting the size to higher than the default (or < 0 which will end
|
||||||
@@ -467,7 +484,7 @@ less than again - I’m not going to try and figure that out however). Anyway:</
|
|||||||
YOU WIN!
|
YOU WIN!
|
||||||
X:24/49 Y:8/16 S:658/658 B:0</code></pre>
|
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
|
<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>
|
small for that value (see [terminals.md][]).</p>
|
||||||
<p>The reason I chose 997 is that it leaves a bit of a challenge for some (maybe
|
<p>The reason I chose 997 is that it leaves a bit of a challenge for some (maybe
|
||||||
most) people but it’s still winnable. Previously even I couldn’t have won unless
|
most) people but it’s still winnable. Previously even I couldn’t have won unless
|
||||||
maybe a much bigger screen, if both cheat modes were disabled. I probably could
|
maybe a much bigger screen, if both cheat modes were disabled. I probably could
|
||||||
@@ -485,19 +502,25 @@ but then it occurred to me that there are prime numbers close to 1000 so why not
|
|||||||
choose one instead (that was less than 1000)? And so I did. Another fun fact: at
|
choose one instead (that was less than 1000)? And so I did. Another fun fact: at
|
||||||
the default starting size and growth size of 5 the number of bugs needed before
|
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>
|
the game is won is 199 - also a prime!</p>
|
||||||
<h1 id="gameplay-quitting"><a name="quitting" href="#toc">Gameplay: Quitting</a></h1>
|
<div id="quitting">
|
||||||
|
<h1 id="gameplay-quitting"><a href="#toc">Gameplay: Quitting</a></h1>
|
||||||
|
</div>
|
||||||
<p>If you wish to quit you can hit ‘q’ (case-insensitive). For example:</p>
|
<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>
|
<div id="modes">
|
||||||
<p>Here I list a number of different modes of play. In the <a href="bugs.html">bugs.html</a>
|
<h1 id="gameplay-modes">4. <a href="#toc">Gameplay modes</a></h1>
|
||||||
(<a href="bugs.md">bugs.md</a> on GitHub) file I even show how there’s a built-in test unit for some
|
</div>
|
||||||
|
<p>Here I list a number of different modes of play. In the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/bugs.html">bugs.html</a>
|
||||||
|
file I even show how there’s a built-in test unit for some
|
||||||
modes! There are certainly other modes that could be imagined: the modes below
|
modes! There are certainly other modes that could be imagined: the modes below
|
||||||
happened over time and some were simply an accidental discovery or something I
|
happened over time and some were simply an accidental discovery or something I
|
||||||
thought of by a chance; others were thought out from the beginning but were
|
thought of by a chance; others were thought out from the beginning but were
|
||||||
improved over time.</p>
|
improved over time.</p>
|
||||||
<p>The <a href="play.sh">play.sh</a> script sets up some of these automatically; I describe it after
|
<p>The <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/play.sh">play.sh</a> script sets up some of these automatically; I describe it after
|
||||||
the modes below.</p>
|
the modes below.</p>
|
||||||
<h2 id="photosensitive-epilepsystimulation-overload-trigger-warnings"><a name="warning" href="#toc">Photosensitive epilepsy/Stimulation overload trigger warnings</a></h2>
|
<div id="warning">
|
||||||
|
<h2 id="photosensitive-epilepsystimulation-overload-trigger-warnings"><a href="#toc">Photosensitive epilepsy/Stimulation overload trigger warnings</a></h2>
|
||||||
|
</div>
|
||||||
<p>If you have <strong>photosensitive epilepsy please be careful</strong> especially with low values
|
<p>If you have <strong>photosensitive epilepsy please be careful</strong> especially with low values
|
||||||
for both <strong>WAIT</strong> and <strong>EVADE</strong>. It appears that the <a href="https://www.epilepsysociety.org.uk/photosensitive-epilepsy#.Xjgpwi2ZOgQ">number of hertz (flashes)
|
for both <strong>WAIT</strong> and <strong>EVADE</strong>. It appears that the <a href="https://www.epilepsysociety.org.uk/photosensitive-epilepsy#.Xjgpwi2ZOgQ">number of hertz (flashes)
|
||||||
per second triggering seizures</a> is wide but depending on the variables it
|
per second triggering seizures</a> is wide but depending on the variables it
|
||||||
@@ -507,7 +530,9 @@ exercise caution. This could trigger seizures and <strong>it might also be too m
|
|||||||
stimulation for some people.</strong></p>
|
stimulation for some people.</strong></p>
|
||||||
<p><strong>Please be careful of these if these types of things have ever affected you or if
|
<p><strong>Please be careful of these if these types of things have ever affected you or if
|
||||||
you have any form of epilepsy. Thank you.</strong></p>
|
you have any form of epilepsy. Thank you.</strong></p>
|
||||||
<h2 id="gameplay-mode-drawing-practice-mode"><a name="drawing" href="#toc">Gameplay mode: Drawing / Practice mode</a></h2>
|
<div id="drawing">
|
||||||
|
<h2 id="gameplay-mode-drawing-practice-mode"><a href="#toc">Gameplay mode: Drawing / Practice mode</a></h2>
|
||||||
|
</div>
|
||||||
<p>If you want to draw the snake wherever you like on the screen you can do this by
|
<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
|
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>
|
does not move until you press a movement key. For example:</p>
|
||||||
@@ -527,7 +552,7 @@ to be a problem simply do:</p>
|
|||||||
<p>Or something like that (maybe make the size bigger but that’s up to you). You
|
<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>
|
could also set the max size to be the highest possible by saying</p>
|
||||||
<pre><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>Which I’ve done in the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/play.sh">play.sh</a> script.</p>
|
||||||
<p>I discuss how this mode works in [spoilers.markdown][].</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
|
<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
|
perfect: the snake after all does not leave gaps and the game does not support
|
||||||
@@ -538,7 +563,9 @@ for. But you can consider this mode drawing or practice mode.</p>
|
|||||||
oooo o oo ooooooo oooo ooooo
|
oooo o oo ooooooo oooo ooooo
|
||||||
o o ooo oo o ooo o
|
o o ooo oo o ooo o
|
||||||
oooo o oo ooo oooooooo></code></pre>
|
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>
|
<div id="auto">
|
||||||
|
<h2 id="gameplay-mode-computer-playing-automatic-mode-photosensitive-epilepsystimulation-overload-trigger"><a href="#toc">Gameplay mode: Computer playing / Automatic mode (Photosensitive epilepsy/Stimulation overload trigger)</a></h2>
|
||||||
|
</div>
|
||||||
<p><strong>Photosensitive epilepsy/stimulation overload trigger warning:</strong>
|
<p><strong>Photosensitive epilepsy/stimulation overload trigger warning:</strong>
|
||||||
For those who have epilepsy or are susceptible to stimulation overload from
|
For those who have epilepsy or are susceptible to stimulation overload from
|
||||||
flashing lights please do be careful with this mode. Depending on your
|
flashing lights please do be careful with this mode. Depending on your
|
||||||
@@ -563,7 +590,9 @@ by itself.</p>
|
|||||||
seems to take longer for it to get a bug as it gets longer. I believe these
|
seems to take longer for it to get a bug as it gets longer. I believe these
|
||||||
happen because the bug has to find a X and Y coordinate that’s not occupied and
|
happen because the bug has to find a X and Y coordinate that’s not occupied and
|
||||||
so with fewer available it has a harder time finding a place in that one line.</p>
|
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>
|
<div id="auto-variations">
|
||||||
|
<h3 id="computer-player-variations"><a href="#toc">Computer player variations</a></h3>
|
||||||
|
</div>
|
||||||
<p>Here’s how to make the bug move every time the snake moves:</p>
|
<p>Here’s how to make the bug move every time the snake moves:</p>
|
||||||
<pre><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>
|
<h4 id="help-the-computer-win-fairly-quickly">Help the computer win fairly quickly</h4>
|
||||||
@@ -577,7 +606,7 @@ thought of):</p>
|
|||||||
shows to be 10 characters depends on whether or not it gets a bug before it can
|
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
|
get to that length - and then it’ll start shrinking until it’s just the head
|
||||||
then the head again (i.e. 1 then 0 in size) and then win! This is also in the
|
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>
|
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/play.sh">play.sh</a> script.</p>
|
||||||
<h4 id="adjusting-the-timespeed">Adjusting the time/speed</h4>
|
<h4 id="adjusting-the-timespeed">Adjusting the time/speed</h4>
|
||||||
<p>Of course you can also do something like:</p>
|
<p>Of course you can also do something like:</p>
|
||||||
<pre><code> WAIT=5 WALLS=1 CANNIBAL=1 ./prog</code></pre>
|
<pre><code> WAIT=5 WALLS=1 CANNIBAL=1 ./prog</code></pre>
|
||||||
@@ -597,7 +626,9 @@ horizontally the snake ran into itself at:</p>
|
|||||||
X:57/156 Y:20/41 S:155/997 B:30</code></pre>
|
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
|
<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>
|
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>
|
<div id="grow-shrink">
|
||||||
|
<h2 id="gameplay-mode-grow-shrink-mode-positive-and-negative-winning"><a href="#toc">Gameplay mode: Grow-Shrink mode (Positive and Negative Winning)</a></h2>
|
||||||
|
</div>
|
||||||
<p>In this mode you’re simultaneously growing and shrinking but because the max
|
<p>In this mode you’re simultaneously growing and shrinking but because the max
|
||||||
size is unsigned you can win both by shrinking to the point of losing your body
|
size is unsigned you can win both by shrinking to the point of losing your body
|
||||||
or growing to the full size directly. This is how it works:</p>
|
or growing to the full size directly. This is how it works:</p>
|
||||||
@@ -615,16 +646,18 @@ actually tried it.</p>
|
|||||||
<p>The parameters above were chosen after playing with the mode a bit to find a
|
<p>The parameters above were chosen after playing with the mode a bit to find a
|
||||||
value that wouldn’t take that much time but still would pose a challenge. One
|
value that wouldn’t take that much time but still would pose a challenge. One
|
||||||
could reverse it so that one shrinks more than growing.</p>
|
could reverse it so that one shrinks more than growing.</p>
|
||||||
<p>The <a href="crazy.log.html">crazy.log.html</a> (<a href="crazy.log.md">crazy.log.md</a> on GitHub) file has several screen
|
<p>The <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/crazy.log.html">crazy.log.html</a> file has several screen
|
||||||
dumps with this idea.</p>
|
dumps with this idea.</p>
|
||||||
<p>You could also have it so that eating a bug makes you shrink and moving so many
|
<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>
|
moves you grow. I tried this and for me it was far more fun. The <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/play.sh">play.sh</a>
|
||||||
also has this mode:</p>
|
also has this mode:</p>
|
||||||
<pre><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
|
<p>Obviously there are many other variations. The <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/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
|
of them (the above is option 5; others are 4, 15 and 16 but only options 4 and 5
|
||||||
are called Grow / Shrink).</p>
|
are called Grow / Shrink).</p>
|
||||||
<h2 id="hypnotic-sleepy-mode-photosensitive-epilepsystimulation-overload-trigger"><a name="hypnotic" href="#toc">Hypnotic / Sleepy mode (<strong>Photosensitive epilepsy/Stimulation overload trigger</strong>)</a></h2>
|
<div id="hypnotic">
|
||||||
|
<h2 id="hypnotic-sleepy-mode-photosensitive-epilepsystimulation-overload-trigger"><a href="#toc">Hypnotic / Sleepy mode (<strong>Photosensitive epilepsy/Stimulation overload trigger</strong>)</a></h2>
|
||||||
|
</div>
|
||||||
<p><strong>Photosensitive epilepsy/stimulation overload trigger warning:</strong>
|
<p><strong>Photosensitive epilepsy/stimulation overload trigger warning:</strong>
|
||||||
For those who have epilepsy or are susceptible to stimulation overload from
|
For those who have epilepsy or are susceptible to stimulation overload from
|
||||||
flashing lights and patterns please do be careful with this mode. Depending on your
|
flashing lights and patterns please do be careful with this mode. Depending on your
|
||||||
@@ -637,14 +670,18 @@ snake moving too.</p>
|
|||||||
<pre><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
|
<p>And just moving the snake about not trying to catch any bugs - just let whatever
|
||||||
happens happen.</p>
|
happens happen.</p>
|
||||||
<h2 id="gameplay-mode-stimulation-calming-mode"><a name="stim" href="#toc">Gameplay mode: Stimulation / Calming mode</a></h2>
|
<div id="stim">
|
||||||
|
<h2 id="gameplay-mode-stimulation-calming-mode"><a href="#toc">Gameplay mode: Stimulation / Calming mode</a></h2>
|
||||||
|
</div>
|
||||||
<p>If you just need something to stimulate your mind to keep you calm or simply you
|
<p>If you just need something to stimulate your mind to keep you calm or simply you
|
||||||
want to play a game without having to worry about winning or losing you can set
|
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
|
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
|
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>
|
worry about even running into yourself and losing:</p>
|
||||||
<pre><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>
|
<div id="expansibility">
|
||||||
|
<h2 id="gameplay-mode-expansibility"><a href="#toc">Gameplay mode: Expansibility</a></h2>
|
||||||
|
</div>
|
||||||
<p>As I was writing this document and the game modes I have thought of other game
|
<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.
|
modes (they were added) and I have come back to this document to add more modes.
|
||||||
That’s the beauty of the variables I have implemented: together with the
|
That’s the beauty of the variables I have implemented: together with the
|
||||||
@@ -657,43 +694,55 @@ not be too hard either. And a game developer who does not play their games is a
|
|||||||
game developer who is detached from their player base and the wants and needs
|
game developer who is detached from their player base and the wants and needs
|
||||||
are therefore disregarded if even heard. I have played this game a lot for this
|
are therefore disregarded if even heard. I have played this game a lot for this
|
||||||
reason as well as I simply enjoy it and thinking up new modes.</p>
|
reason as well as I simply enjoy it and thinking up new modes.</p>
|
||||||
<h1 id="scripts">5. <a name="scripts" href="#toc">Scripts</a></h1>
|
<h1 id="scripts">5. <a href="#toc">Scripts</a></h1>
|
||||||
<p>The following scripts are provided to simplify and automate some of the things
|
<p>The following scripts are provided to simplify and automate some of the things
|
||||||
this file discusses as well as allowing to easily change the colours.</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>
|
<div id="colours">
|
||||||
<p>To do this use the <a href="snake-colours">snake-colours</a> script like so:</p>
|
<h2 id="colours-selection-snake-colours"><a href="#toc">Colours selection: snake-colours</a></h2>
|
||||||
<pre><code> ./snake-colours</code></pre>
|
</div>
|
||||||
|
<p>To do this use the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/snake-colours.sh">snake-colours.sh</a> script like so:</p>
|
||||||
|
<pre><code> ./snake-colours.sh</code></pre>
|
||||||
<p>If you want to pass in specific variables you can do that too e.g.:</p>
|
<p>If you want to pass in specific variables you can do that too e.g.:</p>
|
||||||
<pre><code> CANNIBAL=1 ./snake-colours</code></pre>
|
<pre><code> CANNIBAL=1 ./snake-colours.sh</code></pre>
|
||||||
<p>The script will prompt you for the colour of the walls, snake head, body and the
|
<p>The script will prompt you for the colour of the walls, snake head, body and the
|
||||||
bug.</p>
|
bug.</p>
|
||||||
<h2 id="automate-the-above-gameplay-modes"><a name="preset" href="#toc">Automate the above gameplay modes</a></h2>
|
<div id="preset">
|
||||||
<p>The <a href="play.sh">play.sh</a> script has the gameplay modes described in this file and is menu
|
<h2 id="automate-the-above-gameplay-modes"><a href="#toc">Automate the above gameplay modes</a></h2>
|
||||||
|
</div>
|
||||||
|
<p>The <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/play.sh">play.sh</a> script has the gameplay modes described in this file and is menu
|
||||||
based (there might be differences and some of the modes I include a variation).
|
based (there might be differences and some of the modes I include a variation).
|
||||||
The script tests the terminal (allowing you to continue even if problems are
|
The script tests the terminal (allowing you to continue even if problems are
|
||||||
detected), prompts you if you want to select colours (like those in
|
detected), prompts you if you want to select colours (like those in
|
||||||
snake-colours above) and then gives you a list of game modes to play. You can
|
snake-colours.sh 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
|
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>
|
you choose uses then the script will override what you pass in.</p>
|
||||||
<p>To use you can do something like:</p>
|
<p>To use you can do something like:</p>
|
||||||
<pre><code> ./play.sh</code></pre>
|
<pre><code> ./play.sh</code></pre>
|
||||||
<p>Or to make it so walls are an obstacle:</p>
|
<p>Or to make it so walls are an obstacle:</p>
|
||||||
<pre><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>
|
<div id="variables">
|
||||||
|
<h1 id="notes-about-some-of-the-game-variables">6. <a href="#toc">Notes about some of the game variables</a></h1>
|
||||||
|
</div>
|
||||||
<p>The game variables can be used for a variety of things including different
|
<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>
|
gameplay modes (as shown above) but here are some general notes about a few of them.</p>
|
||||||
<h2 id="wait-snake-speed"><a name="wait" href="#toc">WAIT: Snake speed</a></h2>
|
<div id="wait">
|
||||||
|
<h2 id="wait-snake-speed"><a href="#toc">WAIT: Snake speed</a></h2>
|
||||||
|
</div>
|
||||||
<p>Besides the different game modes, if you find it too fast/slow you can change it
|
<p>Besides the different game modes, if you find it too fast/slow you can change it
|
||||||
to a value that’s better for you. Remember it’s a wait time so if you want the
|
to a value that’s better for you. Remember it’s a wait time so if you want the
|
||||||
snake to move slower you have to increase the wait time!</p>
|
snake to move slower you have to increase the wait time!</p>
|
||||||
<h2 id="evade-bug-evasion-frequency"><a name="evade" href="#toc">EVADE: Bug evasion frequency</a></h2>
|
<div id="evade">
|
||||||
|
<h2 id="evade-bug-evasion-frequency"><a href="#toc">EVADE: Bug evasion frequency</a></h2>
|
||||||
|
</div>
|
||||||
<p>For every <strong>EVADE</strong> snake movements the bug will try and find a new place to
|
<p>For every <strong>EVADE</strong> snake movements the bug will try and find a new place to
|
||||||
occupy. It might be very close to it and I do not ensure it’s a new place at
|
occupy. It might be very close to it and I do not ensure it’s a new place at
|
||||||
all.</p>
|
all.</p>
|
||||||
<p>Each time the bug is placed the counter will be reset whether from eating the
|
<p>Each time the bug is placed the counter will be reset whether from eating the
|
||||||
bug or not reaching it in time. Default 300 moves.</p>
|
bug or not reaching it in time. Default 300 moves.</p>
|
||||||
<p>This can help you get out of a trap but it can also sometimes make it harder.</p>
|
<p>This can help you get out of a trap but it can also sometimes make it harder.</p>
|
||||||
<h2 id="size-maxsize-initial-max-snake-sizes"><a name="sizes" href="#toc">SIZE / MAXSIZE: Initial / Max snake sizes</a></h2>
|
<div id="sizes">
|
||||||
|
<h2 id="size-maxsize-initial-max-snake-sizes"><a href="#toc">SIZE / MAXSIZE: Initial / Max snake sizes</a></h2>
|
||||||
|
</div>
|
||||||
<p>997 might be a bit high for many people. Or maybe you don’t have enough time. Or
|
<p>997 might be a bit high for many people. Or maybe you don’t have enough time. Or
|
||||||
you’re not in the mood to lose. Or you want to get close to a size you were last
|
you’re not in the mood to lose. Or you want to get close to a size you were last
|
||||||
time but quickly. It might be in conjunction with drawing mode.</p>
|
time but quickly. It might be in conjunction with drawing mode.</p>
|
||||||
@@ -702,10 +751,14 @@ the snake will ‘populate’ in the snake arrays and the visible size: as I hav
|
|||||||
discussed here and there the snake doesn’t grow immediately so it takes time
|
discussed here and there the snake doesn’t grow immediately so it takes time
|
||||||
before the snake is visibly that many characters. In other words just because it
|
before the snake is visibly that many characters. In other words just because it
|
||||||
says SIZE 29 doesn’t mean it will instantly be 29 characters on the screen.</p>
|
says SIZE 29 doesn’t mean it will instantly be 29 characters on the screen.</p>
|
||||||
<h2 id="grow-sheds-growth-shedding-sizes"><a name="growth" href="#toc">GROW / SHEDS : Growth / Shedding sizes</a></h2>
|
<div id="growth">
|
||||||
|
<h2 id="grow-sheds-growth-shedding-sizes"><a href="#toc">GROW / SHEDS : Growth / Shedding sizes</a></h2>
|
||||||
|
</div>
|
||||||
<p>Similar to the initial size. Notice that the above point on size applies here:
|
<p>Similar to the initial size. Notice that the above point on size applies here:
|
||||||
it will take the number of movements before it is ‘its full size’.</p>
|
it will take the number of movements before it is ‘its full size’.</p>
|
||||||
<h1 id="conclusion-and-inspirational-words-for-everyone">7. <a name="conclusions" href="#toc">Conclusion (and inspirational words for everyone)</a></h1>
|
<div id="conclusions">
|
||||||
|
<h1 id="conclusion-and-inspirational-words-for-everyone">7. <a href="#toc">Conclusion (and inspirational words for everyone)</a></h1>
|
||||||
|
</div>
|
||||||
<p>I believe that this file has given more than enough information for anyone to
|
<p>I believe that this file has given more than enough information for anyone to
|
||||||
get an idea of what is possible with my implementation of Snake. I realise also
|
get an idea of what is possible with my implementation of Snake. I realise also
|
||||||
that most people won’t have read this far and that’s quite all right; I’m very
|
that most people won’t have read this far and that’s quite all right; I’m very
|
||||||
|
|||||||
+113
-58
@@ -3,8 +3,7 @@ have included much more than just the input keys and a few printouts of the
|
|||||||
game. For normal play you probably don't even need this file at all unless it be
|
game. For normal play you probably don't even need this file at all unless it be
|
||||||
for the input keys.
|
for the input keys.
|
||||||
|
|
||||||
<a name="toc"></a>
|
<div id="toc">
|
||||||
|
|
||||||
1. [Testing terminal environment/capabilities](#support)
|
1. [Testing terminal environment/capabilities](#support)
|
||||||
|
|
||||||
2. [Input keys](#input)
|
2. [Input keys](#input)
|
||||||
@@ -46,20 +45,25 @@ for the input keys.
|
|||||||
|
|
||||||
|
|
||||||
7. [Conclusion (and inspirational words for everyone)](#conclusions)
|
7. [Conclusion (and inspirational words for everyone)](#conclusions)
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
# 1. <a name="support" href="#toc">Testing terminal environment/capabilities</a>
|
<div id="support">
|
||||||
|
# 1. <a href="#toc">Testing terminal environment/capabilities</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
Most people probably won't have any issue at all but for those who have any
|
Most people probably won't have any issue at all but for those who have any
|
||||||
problems with the terminal see the [terminals.html][] ([terminals.md][] on
|
problems with the terminal see the [terminals.html][]
|
||||||
GitHub) file for more information on the terminal capabilities testing utility I
|
file for more information on the terminal capabilities testing utility I
|
||||||
include.
|
include.
|
||||||
|
|
||||||
For troubleshooting other problems see [troubleshooting.html][]
|
For troubleshooting other problems see [troubleshooting.html][]
|
||||||
([troubleshooting.md][] on GitHub) and [bugs.html][] ([bugs.md][] on GitHub).
|
and [bugs.html][].
|
||||||
|
|
||||||
|
|
||||||
# 2. <a name="input" href="#toc">Input keys</a>
|
<div id="input">
|
||||||
|
# 2. <a href="#toc">Input keys</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
- Left, right, up and down **arrow keys**: move that direction.
|
- Left, right, up and down **arrow keys**: move that direction.
|
||||||
- `q` (and `Q`): quit the game.
|
- `q` (and `Q`): quit the game.
|
||||||
@@ -68,7 +72,10 @@ For troubleshooting other problems see [troubleshooting.html][]
|
|||||||
that `getch()` picks up on and the game is not paused then it will be as if
|
that `getch()` picks up on and the game is not paused then it will be as if
|
||||||
you pressed the current direction key (assuming you already moved the snake).
|
you pressed the current direction key (assuming you already moved the snake).
|
||||||
|
|
||||||
# 3. <a name="gameplay" href="#toc">Gameplay</a>
|
|
||||||
|
<div id="gameplay">
|
||||||
|
# 3. <a href="#toc">Gameplay</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
Here I will show the initial screen as well as what a few things look like. If
|
Here I will show the initial screen as well as what a few things look like. If
|
||||||
you don't feel you need this but you want to configure colours jump to [colour
|
you don't feel you need this but you want to configure colours jump to [colour
|
||||||
@@ -79,7 +86,9 @@ The bug colour by default is white; the snake head colour is red and the snake
|
|||||||
body colour is green. The walls are cyan.
|
body colour is green. The walls are cyan.
|
||||||
|
|
||||||
|
|
||||||
## <a name="initial" href="#toc">Gameplay: The initial screen</a>
|
<div id="initial">
|
||||||
|
## <a href="#toc">Gameplay: The initial screen</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
When you load the game you will see a screen that looks something like the
|
When you load the game you will see a screen that looks something like the
|
||||||
below. Note that the top line is the score/status line: the top wall is at line
|
below. Note that the top line is the score/status line: the top wall is at line
|
||||||
@@ -128,7 +137,9 @@ to the number in the diagram:
|
|||||||
- The number of bugs eaten so far is 0.
|
- The number of bugs eaten so far is 0.
|
||||||
|
|
||||||
|
|
||||||
## <a name="playing" href="#toc">Gameplay: Playing the game</a>
|
<div id="playing">
|
||||||
|
## <a href="#toc">Gameplay: Playing the game</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -202,7 +213,9 @@ 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.
|
three and then up one and could slither on to the bug.
|
||||||
|
|
||||||
|
|
||||||
# <a name="walls" href="#toc">Gameplay: Walls</a>
|
<div id="walls">
|
||||||
|
# <a href="#toc">Gameplay: Walls</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
By default walls are passable (**WALLS=1**). Let's get to full size and go
|
By default walls are passable (**WALLS=1**). Let's get to full size and go
|
||||||
through the top wall:
|
through the top wall:
|
||||||
@@ -286,8 +299,9 @@ X:20/49 Y:1/16 S:150/658 B:0
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
<div id="cannibalism">
|
||||||
# <a name="cannibalism" href="#toc">Gameplay: Cannibalism</a>
|
# <a href="#toc">Gameplay: Cannibalism</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
By default cannibalism is disabled (**CANNIBAL=0**) so if you run into yourself it might look
|
By default cannibalism is disabled (**CANNIBAL=0**) so if you run into yourself it might look
|
||||||
something like:
|
something like:
|
||||||
@@ -395,19 +409,24 @@ snake) turn (so that you go perpendicular) and then watch as the snake starts
|
|||||||
unwinding at one place and then suddenly unwinds another direction.
|
unwinding at one place and then suddenly unwinds another direction.
|
||||||
|
|
||||||
An example of extreme cannibalism is in the [cannibalism.log.html][]
|
An example of extreme cannibalism is in the [cannibalism.log.html][]
|
||||||
([cannibalism.log.md][] on GitHub) file. It explains information about the file
|
file. It explains information about the file
|
||||||
including how to find the bug, head and tail of the snake, at least where it was
|
including how to find the bug, head and tail of the snake, at least where it was
|
||||||
documented. The first run has several dumps. The final example has the snake
|
documented. The first run has several dumps. The final example has the snake
|
||||||
inside itself.
|
inside itself.
|
||||||
|
|
||||||
# <a name="shedding" href="#toc">Gameplay: Shedding (stretching)</a>
|
|
||||||
|
<div id="shedding">
|
||||||
|
# <a href="#toc">Gameplay: Shedding (stretching)</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
This feature will make you grow by the value of **SHEDS** for every **SHED**
|
This feature will make you grow by the value of **SHEDS** for every **SHED**
|
||||||
movements (the counter isn't incremented when you eat a bug). Basically growing
|
movements (the counter isn't incremented when you eat a bug). Basically growing
|
||||||
without eating a bug (stretching would be better name here).
|
without eating a bug (stretching would be better name here).
|
||||||
|
|
||||||
|
|
||||||
# <a name="winning" href="#toc">Gameplay: Winning</a>
|
<div id="winning">
|
||||||
|
# <a href="#toc">Gameplay: Winning</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
If you ever get to the **MAXSIZE** the game is won. You can force a win by
|
If you ever get to the **MAXSIZE** the game is won. You can force a win by
|
||||||
setting the max size to a smaller value than the size you specify (or the
|
setting the max size to a smaller value than the size you specify (or the
|
||||||
@@ -445,7 +464,9 @@ the default starting size and growth size of 5 the number of bugs needed before
|
|||||||
the game is won is 199 - also a prime!
|
the game is won is 199 - also a prime!
|
||||||
|
|
||||||
|
|
||||||
# <a name="quitting" href="#toc">Gameplay: Quitting</a>
|
<div id="quitting">
|
||||||
|
# <a href="#toc">Gameplay: Quitting</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
If you wish to quit you can hit 'q' (case-insensitive). For example:
|
If you wish to quit you can hit 'q' (case-insensitive). For example:
|
||||||
|
|
||||||
@@ -454,10 +475,12 @@ If you wish to quit you can hit 'q' (case-insensitive). For example:
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
# 4. <a name="modes" href="#toc">Gameplay modes</a>
|
<div id="modes">
|
||||||
|
# 4. <a href="#toc">Gameplay modes</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
Here I list a number of different modes of play. In the [bugs.html][]
|
Here I list a number of different modes of play. In the [bugs.html][]
|
||||||
([bugs.md][] on GitHub) file I even show how there's a built-in test unit for some
|
file I even show how there's a built-in test unit for some
|
||||||
modes! There are certainly other modes that could be imagined: the modes below
|
modes! There are certainly other modes that could be imagined: the modes below
|
||||||
happened over time and some were simply an accidental discovery or something I
|
happened over time and some were simply an accidental discovery or something I
|
||||||
thought of by a chance; others were thought out from the beginning but were
|
thought of by a chance; others were thought out from the beginning but were
|
||||||
@@ -467,7 +490,9 @@ The [play.sh][] script sets up some of these automatically; I describe it after
|
|||||||
the modes below.
|
the modes below.
|
||||||
|
|
||||||
|
|
||||||
## <a name="warning" href="#toc">Photosensitive epilepsy/Stimulation overload trigger warnings</a>
|
<div id="warning">
|
||||||
|
## <a href="#toc">Photosensitive epilepsy/Stimulation overload trigger warnings</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
If you have **photosensitive epilepsy please be careful** especially with low values
|
If you have **photosensitive epilepsy please be careful** especially with low values
|
||||||
for both **WAIT** and **EVADE**. It appears that the [number of hertz (flashes)
|
for both **WAIT** and **EVADE**. It appears that the [number of hertz (flashes)
|
||||||
@@ -481,7 +506,10 @@ stimulation for some people.**
|
|||||||
**Please be careful of these if these types of things have ever affected you or if
|
**Please be careful of these if these types of things have ever affected you or if
|
||||||
you have any form of epilepsy. Thank you.**
|
you have any form of epilepsy. Thank you.**
|
||||||
|
|
||||||
## <a name="drawing" href="#toc">Gameplay mode: Drawing / Practice mode</a>
|
|
||||||
|
<div id="drawing">
|
||||||
|
## <a href="#toc">Gameplay mode: Drawing / Practice mode</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
If you want to draw the snake wherever you like on the screen you can do this by
|
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
|
modifying the wait time (for input) to -1 (or any value < 0): then the snake
|
||||||
@@ -542,8 +570,9 @@ for. But you can consider this mode drawing or practice mode.
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
<div id="auto">
|
||||||
## <a name="auto" href="#toc">Gameplay mode: Computer playing / Automatic mode (Photosensitive epilepsy/Stimulation overload trigger)</a>
|
## <a href="#toc">Gameplay mode: Computer playing / Automatic mode (Photosensitive epilepsy/Stimulation overload trigger)</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
**Photosensitive epilepsy/stimulation overload trigger warning:**
|
**Photosensitive epilepsy/stimulation overload trigger warning:**
|
||||||
For those who have epilepsy or are susceptible to stimulation overload from
|
For those who have epilepsy or are susceptible to stimulation overload from
|
||||||
@@ -578,7 +607,10 @@ seems to take longer for it to get a bug as it gets longer. I believe these
|
|||||||
happen because the bug has to find a X and Y coordinate that's not occupied and
|
happen because the bug has to find a X and Y coordinate that's not occupied and
|
||||||
so with fewer available it has a harder time finding a place in that one line.
|
so with fewer available it has a harder time finding a place in that one line.
|
||||||
|
|
||||||
### <a name="auto-variations" href="#toc">Computer player variations</a>
|
|
||||||
|
<div id="auto-variations">
|
||||||
|
### <a href="#toc">Computer player variations</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
Here's how to make the bug move every time the snake moves:
|
Here's how to make the bug move every time the snake moves:
|
||||||
|
|
||||||
@@ -650,7 +682,10 @@ horizontally the snake ran into itself at:
|
|||||||
What if you set the size to a high value? The lowest? There are bound to be
|
What if you set the size to a high value? The lowest? There are bound to be
|
||||||
other games to play with this feature!
|
other games to play with this feature!
|
||||||
|
|
||||||
## <a name="grow-shrink" href="#toc">Gameplay mode: Grow-Shrink mode (Positive and Negative Winning)</a>
|
|
||||||
|
<div id="grow-shrink">
|
||||||
|
## <a href="#toc">Gameplay mode: Grow-Shrink mode (Positive and Negative Winning)</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
In this mode you're simultaneously growing and shrinking but because the max
|
In this mode you're simultaneously growing and shrinking but because the max
|
||||||
size is unsigned you can win both by shrinking to the point of losing your body
|
size is unsigned you can win both by shrinking to the point of losing your body
|
||||||
@@ -676,7 +711,7 @@ The parameters above were chosen after playing with the mode a bit to find a
|
|||||||
value that wouldn't take that much time but still would pose a challenge. One
|
value that wouldn't take that much time but still would pose a challenge. One
|
||||||
could reverse it so that one shrinks more than growing.
|
could reverse it so that one shrinks more than growing.
|
||||||
|
|
||||||
The [crazy.log.html][] ([crazy.log.md][] on GitHub) file has several screen
|
The [crazy.log.html][] file has several screen
|
||||||
dumps with this idea.
|
dumps with this idea.
|
||||||
|
|
||||||
You could also have it so that eating a bug makes you shrink and moving so many
|
You could also have it so that eating a bug makes you shrink and moving so many
|
||||||
@@ -692,7 +727,9 @@ of them (the above is option 5; others are 4, 15 and 16 but only options 4 and 5
|
|||||||
are called Grow / Shrink).
|
are called Grow / Shrink).
|
||||||
|
|
||||||
|
|
||||||
## <a name="hypnotic" href="#toc">Hypnotic / Sleepy mode (**Photosensitive epilepsy/Stimulation overload trigger**)</a>
|
<div id="hypnotic">
|
||||||
|
## <a href="#toc">Hypnotic / Sleepy mode (**Photosensitive epilepsy/Stimulation overload trigger**)</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
**Photosensitive epilepsy/stimulation overload trigger warning:**
|
**Photosensitive epilepsy/stimulation overload trigger warning:**
|
||||||
For those who have epilepsy or are susceptible to stimulation overload from
|
For those who have epilepsy or are susceptible to stimulation overload from
|
||||||
@@ -713,7 +750,9 @@ And just moving the snake about not trying to catch any bugs - just let whatever
|
|||||||
happens happen.
|
happens happen.
|
||||||
|
|
||||||
|
|
||||||
## <a name="stim" href="#toc">Gameplay mode: Stimulation / Calming mode</a>
|
<div id="stim">
|
||||||
|
## <a href="#toc">Gameplay mode: Stimulation / Calming mode</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
If you just need something to stimulate your mind to keep you calm or simply you
|
If you just need something to stimulate your mind to keep you calm or simply you
|
||||||
want to play a game without having to worry about winning or losing you can set
|
want to play a game without having to worry about winning or losing you can set
|
||||||
@@ -726,7 +765,9 @@ worry about even running into yourself and losing:
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## <a name="expansibility" href="#toc">Gameplay mode: Expansibility</a>
|
<div id="expansibility">
|
||||||
|
## <a href="#toc">Gameplay mode: Expansibility</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
As I was writing this document and the game modes I have thought of other game
|
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.
|
modes (they were added) and I have come back to this document to add more modes.
|
||||||
@@ -743,35 +784,43 @@ are therefore disregarded if even heard. I have played this game a lot for this
|
|||||||
reason as well as I simply enjoy it and thinking up new modes.
|
reason as well as I simply enjoy it and thinking up new modes.
|
||||||
|
|
||||||
|
|
||||||
# 5. <a name="scripts" href="#toc">Scripts</a>
|
<div id="scripts">
|
||||||
|
# 5. <a href="#toc">Scripts</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
The following scripts are provided to simplify and automate some of the things
|
The following scripts are provided to simplify and automate some of the things
|
||||||
this file discusses as well as allowing to easily change the colours.
|
this file discusses as well as allowing to easily change the colours.
|
||||||
|
|
||||||
## <a name="colours" href="#toc">Colours selection: snake-colours</a>
|
|
||||||
|
|
||||||
To do this use the [snake-colours][] script like so:
|
<div id="colours">
|
||||||
|
## <a href="#toc">Colours selection: snake-colours</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
To do this use the [snake-colours.sh][] script like so:
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
./snake-colours
|
./snake-colours.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want to pass in specific variables you can do that too e.g.:
|
If you want to pass in specific variables you can do that too e.g.:
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
CANNIBAL=1 ./snake-colours
|
CANNIBAL=1 ./snake-colours.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
The script will prompt you for the colour of the walls, snake head, body and the
|
The script will prompt you for the colour of the walls, snake head, body and the
|
||||||
bug.
|
bug.
|
||||||
|
|
||||||
## <a name="preset" href="#toc">Automate the above gameplay modes</a>
|
|
||||||
|
<div id="preset">
|
||||||
|
## <a href="#toc">Automate the above gameplay modes</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
The [play.sh][] script has the gameplay modes described in this file and is menu
|
The [play.sh][] script has the gameplay modes described in this file and is menu
|
||||||
based (there might be differences and some of the modes I include a variation).
|
based (there might be differences and some of the modes I include a variation).
|
||||||
The script tests the terminal (allowing you to continue even if problems are
|
The script tests the terminal (allowing you to continue even if problems are
|
||||||
detected), prompts you if you want to select colours (like those in
|
detected), prompts you if you want to select colours (like those in
|
||||||
snake-colours above) and then gives you a list of game modes to play. You can
|
snake-colours.sh 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
|
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.
|
you choose uses then the script will override what you pass in.
|
||||||
|
|
||||||
@@ -788,19 +837,26 @@ Or to make it so walls are an obstacle:
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
# 6. <a name="variables" href="#toc">Notes about some of the game variables</a>
|
<div id="variables">
|
||||||
|
# 6. <a href="#toc">Notes about some of the game variables</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
The game variables can be used for a variety of things including different
|
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.
|
gameplay modes (as shown above) but here are some general notes about a few of them.
|
||||||
|
|
||||||
## <a name="wait" href="#toc">WAIT: Snake speed</a>
|
|
||||||
|
<div id="wait">
|
||||||
|
## <a href="#toc">WAIT: Snake speed</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
Besides the different game modes, if you find it too fast/slow you can change it
|
Besides the different game modes, if you find it too fast/slow you can change it
|
||||||
to a value that's better for you. Remember it's a wait time so if you want the
|
to a value that's better for you. Remember it's a wait time so if you want the
|
||||||
snake to move slower you have to increase the wait time!
|
snake to move slower you have to increase the wait time!
|
||||||
|
|
||||||
|
|
||||||
## <a name="evade" href="#toc">EVADE: Bug evasion frequency</a>
|
<div id="evade">
|
||||||
|
## <a href="#toc">EVADE: Bug evasion frequency</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
For every **EVADE** snake movements the bug will try and find a new place to
|
For every **EVADE** snake movements the bug will try and find a new place to
|
||||||
occupy. It might be very close to it and I do not ensure it's a new place at
|
occupy. It might be very close to it and I do not ensure it's a new place at
|
||||||
@@ -812,7 +868,9 @@ bug or not reaching it in time. Default 300 moves.
|
|||||||
This can help you get out of a trap but it can also sometimes make it harder.
|
This can help you get out of a trap but it can also sometimes make it harder.
|
||||||
|
|
||||||
|
|
||||||
## <a name="sizes" href="#toc">SIZE / MAXSIZE: Initial / Max snake sizes</a>
|
<div id="sizes">
|
||||||
|
## <a href="#toc">SIZE / MAXSIZE: Initial / Max snake sizes</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
997 might be a bit high for many people. Or maybe you don't have enough time. Or
|
997 might be a bit high for many people. Or maybe you don't have enough time. Or
|
||||||
you're not in the mood to lose. Or you want to get close to a size you were last
|
you're not in the mood to lose. Or you want to get close to a size you were last
|
||||||
@@ -825,14 +883,17 @@ before the snake is visibly that many characters. In other words just because it
|
|||||||
says SIZE 29 doesn't mean it will instantly be 29 characters on the screen.
|
says SIZE 29 doesn't mean it will instantly be 29 characters on the screen.
|
||||||
|
|
||||||
|
|
||||||
## <a name="growth" href="#toc">GROW / SHEDS : Growth / Shedding sizes</a>
|
<div id="growth">
|
||||||
|
## <a href="#toc">GROW / SHEDS : Growth / Shedding sizes</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
Similar to the initial size. Notice that the above point on size applies here:
|
Similar to the initial size. Notice that the above point on size applies here:
|
||||||
it will take the number of movements before it is 'its full size'.
|
it will take the number of movements before it is 'its full size'.
|
||||||
|
|
||||||
|
|
||||||
|
<div id="conclusions">
|
||||||
# 7. <a name="conclusions" href="#toc">Conclusion (and inspirational words for everyone)</a>
|
# 7. <a href="#toc">Conclusion (and inspirational words for everyone)</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
I believe that this file has given more than enough information for anyone to
|
I believe that this file has given more than enough information for anyone to
|
||||||
get an idea of what is possible with my implementation of Snake. I realise also
|
get an idea of what is possible with my implementation of Snake. I realise also
|
||||||
@@ -849,22 +910,16 @@ the imagination and creativity almost anything is possible.** This is something
|
|||||||
they believe in themselves!** I would have never thought this the case for me
|
they believe in themselves!** I would have never thought this the case for me
|
||||||
years ago but I know it's true now. **Believe in yourself. Always.**
|
years ago but I know it's true now. **Believe in yourself. Always.**
|
||||||
|
|
||||||
[terminals.md]: terminals.md
|
[terminals.html]: %%REPO_URL%%/2020/ferguson1/terminals.html
|
||||||
[terminals.html]: terminals.html
|
[troubleshooting.html]: %%REPO_URL%%/2020/ferguson1/troubleshooting.html
|
||||||
[troubleshooting.md]: troubleshooting.md
|
[bugs.html]: %%REPO_URL%%/2020/ferguson1/bugs.html
|
||||||
[troubleshooting.html]: troubleshooting.html
|
[spoilers.html]: %%REPO_URL%%/2020/ferguson1/spoilers.html
|
||||||
[bugs.md]: bugs.md
|
[snake-colours.sh]: %%REPO_URL%%/2020/ferguson1/snake-colours.sh
|
||||||
[bugs.html]: bugs.html
|
|
||||||
[spoilers.md]: spoilers.md
|
|
||||||
[spoilers.html]: spoilers.html
|
|
||||||
[snake-colours]: snake-colours
|
|
||||||
[number of hertz (flashes) per second triggering seizures]: https://www.epilepsysociety.org.uk/photosensitive-epilepsy#.Xjgpwi2ZOgQ
|
[number of hertz (flashes) per second triggering seizures]: https://www.epilepsysociety.org.uk/photosensitive-epilepsy#.Xjgpwi2ZOgQ
|
||||||
[termcaps.c]: termcaps.c
|
[termcaps.c]: %%REPO_URL%%/2020/ferguson1/termcaps.c
|
||||||
[cannibalism.log.md]: cannibalism.log.md
|
[cannibalism.log.html]: %%REPO_URL%%/2020/ferguson1/cannibalism.log.html
|
||||||
[cannibalism.log.html]: cannibalism.log.html
|
[crazy.log.html]: %%REPO_URL%%/2020/ferguson1/crazy.log.html
|
||||||
[crazy.log.md]: crazy.log.md
|
[play.sh]: %%REPO_URL%%/2020/ferguson1/play.sh
|
||||||
[crazy.log.html]: crazy.log.html
|
|
||||||
[play.sh]: play.sh
|
|
||||||
|
|
||||||
|
|
||||||
<hr style="width:10%;text-align:left;margin-left:0">
|
<hr style="width:10%;text-align:left;margin-left:0">
|
||||||
|
|||||||
@@ -135,7 +135,7 @@
|
|||||||
|
|
||||||
<!-- BEFORE: 1st line of markdown file: 2020/ferguson1/spoilers.md -->
|
<!-- BEFORE: 1st line of markdown file: 2020/ferguson1/spoilers.md -->
|
||||||
<h1 id="introduction-spoiler-alert">Introduction (SPOILER ALERT)</h1>
|
<h1 id="introduction-spoiler-alert">Introduction (SPOILER ALERT)</h1>
|
||||||
<p>In the <a href="gameplay.html">gameplay.html</a> (<a href="gameplay.md">gameplay.md</a> on GitHub) file I have given enough
|
<p>In the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/gameplay.html">gameplay.html</a> file I have given enough
|
||||||
information to know how the game looks, how to move the snake, how to pause etc.
|
information to know how the game looks, how to move the snake, how to pause etc.
|
||||||
In this file I am including (some) information on how the game actually works:
|
In this file I am including (some) information on how the game actually works:
|
||||||
the technical details as it were, obfuscation techniques and also some of the
|
the technical details as it were, obfuscation techniques and also some of the
|
||||||
@@ -145,7 +145,7 @@ everything will be answered here.</p>
|
|||||||
<p>If you’re still interested in this file (i.e. you’re a judge or someone who
|
<p>If you’re still interested in this file (i.e. you’re a judge or someone who
|
||||||
wants to know more about it) read on. Yes I write a lot. But you probably
|
wants to know more about it) read on. Yes I write a lot. But you probably
|
||||||
already knew that so no harm there, hey?</p>
|
already knew that so no harm there, hey?</p>
|
||||||
<p><a name="toc"></a></p>
|
<div id="toc">
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#works">How does it work?</a></li>
|
<li><a href="#works">How does it work?</a></li>
|
||||||
<li><a href="#movement">How does the snake movement work?</a></li>
|
<li><a href="#movement">How does the snake movement work?</a></li>
|
||||||
@@ -159,7 +159,10 @@ already knew that so no harm there, hey?</p>
|
|||||||
<li><a href="#skinning">Skinning the snake (i.e. decreasing the iocccsize)</a></li>
|
<li><a href="#skinning">Skinning the snake (i.e. decreasing the iocccsize)</a></li>
|
||||||
<li><a href="#size">A few more interesting size optimisations</a></li>
|
<li><a href="#size">A few more interesting size optimisations</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h1 id="how-does-it-work"><a name="works" href="#toc">How does it work?</a></h1>
|
</div>
|
||||||
|
<div id="works">
|
||||||
|
<h1 id="how-does-it-work"><a href="#toc">How does it work?</a></h1>
|
||||||
|
</div>
|
||||||
<p>The gameplay I have already described but this explains the way things are
|
<p>The gameplay I have already described but this explains the way things are
|
||||||
actually done in more detail.</p>
|
actually done in more detail.</p>
|
||||||
<p>First I initialise curses; if this fails I print an error message (<code>curses error</code>) and return 1. Next the screen size is determined and I subtract 1 from
|
<p>First I initialise curses; if this fails I print an error message (<code>curses error</code>) and return 1. Next the screen size is determined and I subtract 1 from
|
||||||
@@ -220,7 +223,9 @@ location is updated and redrawn.</p>
|
|||||||
<p>There’s also the processing of any shedding at this point. If the snake eats a
|
<p>There’s also the processing of any shedding at this point. If the snake eats a
|
||||||
bug the snake will not shed; if it sheds the snake will not move in the same
|
bug the snake will not shed; if it sheds the snake will not move in the same
|
||||||
manner as if it simply moved. Growth/movement can in some ways be conflated.</p>
|
manner as if it simply moved. Growth/movement can in some ways be conflated.</p>
|
||||||
<h1 id="how-does-the-snake-movement-work"><a name="movement" href="#toc">How does the snake movement work?</a></h1>
|
<div id="movement">
|
||||||
|
<h1 id="how-does-the-snake-movement-work"><a href="#toc">How does the snake movement work?</a></h1>
|
||||||
|
</div>
|
||||||
<p>The way the snake looks to move is that every time the snake moves the last
|
<p>The way the snake looks to move is that every time the snake moves the last
|
||||||
position (the tail) is replaced with a space (<code>' '</code>). If the snake eats a bug
|
position (the tail) is replaced with a space (<code>' '</code>). If the snake eats a bug
|
||||||
then the snake will get bigger in the next <code>N</code> movements. Note that if the snake
|
then the snake will get bigger in the next <code>N</code> movements. Note that if the snake
|
||||||
@@ -229,14 +234,18 @@ moving at the tail end; I have discussed this more than enough elsewhere.</p>
|
|||||||
<p>There are two arrays that store the last Y/X coordinates of the snake’s
|
<p>There are two arrays that store the last Y/X coordinates of the snake’s
|
||||||
positions that are shifted forward as the snake moves about the field looking
|
positions that are shifted forward as the snake moves about the field looking
|
||||||
for bugs.</p>
|
for bugs.</p>
|
||||||
<h1 id="drawing-manual-and-computer-playing-automatic-modes"><a name="manual-automatic" href="#toc">Drawing (manual) and computer playing (automatic) modes</a></h1>
|
<div id="manual-automatic">
|
||||||
|
<h1 id="drawing-manual-and-computer-playing-automatic-modes"><a href="#toc">Drawing (manual) and computer playing (automatic) modes</a></h1>
|
||||||
|
</div>
|
||||||
<p>How do these modes work? The <code>timeout()</code> function takes a signed int: if it’s <code>< 0</code> it waits indefinitely; if it’s <code>0</code> it returns immediately even if there’s no
|
<p>How do these modes work? The <code>timeout()</code> function takes a signed int: if it’s <code>< 0</code> it waits indefinitely; if it’s <code>0</code> it returns immediately even if there’s no
|
||||||
input waiting (if input is there then it’s used instead); and if it’s <code>> 0</code> it
|
input waiting (if input is there then it’s used instead); and if it’s <code>> 0</code> it
|
||||||
waits that many milliseconds. Thus a negative value allows for complete control
|
waits that many milliseconds. Thus a negative value allows for complete control
|
||||||
over the snake’s movement (speed and otherwise), a value of <code>0</code> means the snake
|
over the snake’s movement (speed and otherwise), a value of <code>0</code> means the snake
|
||||||
will move as long as it’s not paused etc. and otherwise it waits up to that many
|
will move as long as it’s not paused etc. and otherwise it waits up to that many
|
||||||
milliseconds (which is how the <code>0</code> value comes into play).</p>
|
milliseconds (which is how the <code>0</code> value comes into play).</p>
|
||||||
<h1 id="collision-detection"><a name="collision" href="#toc">Collision detection</a></h1>
|
<div id="collision">
|
||||||
|
<h1 id="collision-detection"><a href="#toc">Collision detection</a></h1>
|
||||||
|
</div>
|
||||||
<p>This was an interesting thing to work out. Because the snake could occupy more
|
<p>This was an interesting thing to work out. Because the snake could occupy more
|
||||||
than one row and more than one column at a time the two arrays approach seemed
|
than one row and more than one column at a time the two arrays approach seemed
|
||||||
good to me.</p>
|
good to me.</p>
|
||||||
@@ -247,7 +256,9 @@ or the bug.</p>
|
|||||||
<p>The bug does its best to avoid landing where the snake is but given that snakes
|
<p>The bug does its best to avoid landing where the snake is but given that snakes
|
||||||
are very flexible and cunning who can tell what might happen? As I noted <em>these
|
are very flexible and cunning who can tell what might happen? As I noted <em>these
|
||||||
bugs are not bugs! :)</em></p>
|
bugs are not bugs! :)</em></p>
|
||||||
<h2 id="cannibal-collision-detection"><a name="cannibalcollision" href="#toc">Cannibal collision detection</a></h2>
|
<div id="cannibalcollision">
|
||||||
|
<h2 id="cannibal-collision-detection"><a href="#toc">Cannibal collision detection</a></h2>
|
||||||
|
</div>
|
||||||
<p>How does cannibalism change collision detection? The fact that each time the
|
<p>How does cannibalism change collision detection? The fact that each time the
|
||||||
snake function is called there is a space printed at the tail end was a problem
|
snake function is called there is a space printed at the tail end was a problem
|
||||||
to resolve: what happened is if the snake went through itself then at some point
|
to resolve: what happened is if the snake went through itself then at some point
|
||||||
@@ -271,7 +282,9 @@ mode exists for a different kind of play means it should look unnatural: for it
|
|||||||
<p>The second is you can look at it as if two more snakes are having fun with each
|
<p>The second is you can look at it as if two more snakes are having fun with each
|
||||||
other. This can also appear to defy physics!</p>
|
other. This can also appear to defy physics!</p>
|
||||||
<p>Choose your poison. Or rather your venom.</p>
|
<p>Choose your poison. Or rather your venom.</p>
|
||||||
<h2 id="collision-detection-when-resizing-the-window-of-the-game"><a name="resizing" href="#toc">Collision detection when resizing the window of the game</a></h2>
|
<div id="resizing">
|
||||||
|
<h2 id="collision-detection-when-resizing-the-window-of-the-game"><a href="#toc">Collision detection when resizing the window of the game</a></h2>
|
||||||
|
</div>
|
||||||
<p>What happens if the window is resized during the game? If the size is increased
|
<p>What happens if the window is resized during the game? If the size is increased
|
||||||
then the border can (and will) stay the same; but if the window is shrunk then
|
then the border can (and will) stay the same; but if the window is shrunk then
|
||||||
what? It would be very difficult if not impossible to redraw the snake: where
|
what? It would be very difficult if not impossible to redraw the snake: where
|
||||||
@@ -285,7 +298,7 @@ remain the same. This GREATLY simplified things.</p>
|
|||||||
<p>There was another problem at some point where the snake would quickly grow if it
|
<p>There was another problem at some point where the snake would quickly grow if it
|
||||||
was increased in size but I believe that’s resolved. Anyway what kind of field
|
was increased in size but I believe that’s resolved. Anyway what kind of field
|
||||||
in real life increases in size like that so suddenly? :)</p>
|
in real life increases in size like that so suddenly? :)</p>
|
||||||
<h1 id="obfuscation"><a name="obfuscation" href="#toc">Obfuscation</a></h1>
|
<h1 id="obfuscation"><a href="#toc">Obfuscation</a></h1>
|
||||||
<ul>
|
<ul>
|
||||||
<li><p>I make use of the C token pasting operator. Although this is well known it’s
|
<li><p>I make use of the C token pasting operator. Although this is well known it’s
|
||||||
probably less known and either way it’s not as simple as just having the code
|
probably less known and either way it’s not as simple as just having the code
|
||||||
@@ -454,11 +467,11 @@ refer to a <code>x</code> is possibly confusing even without the negative offset
|
|||||||
<p>Of course I don’t have to use negative offsets at all! I could use positive
|
<p>Of course I don’t have to use negative offsets at all! I could use positive
|
||||||
offsets for every time I use negative offsets. But where’s the fun in that? :)</p>
|
offsets for every time I use negative offsets. But where’s the fun in that? :)</p>
|
||||||
<p>BTW: Some of these are not in the table of expressions in the
|
<p>BTW: Some of these are not in the table of expressions in the
|
||||||
<a href="HACKING.html">HACKING.html</a> (<a href="HACKING.md">HACKING.md</a> on GitHub) file. Also there might be some
|
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/HACKING.html">HACKING.html</a> file. Also there might be some
|
||||||
code in there that is no longer correct (it was before I started
|
code in there that is no longer correct (it was before I started
|
||||||
obfuscation) though it might be able to give an idea. Spoilers abound in
|
obfuscation) though it might be able to give an idea. Spoilers abound in
|
||||||
that file (in addition to this file) but the <a href="HACKING.html">HACKING.html</a> (<a href="HACKING.md">HACKING.md</a>
|
that file (in addition to this file) but the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/HACKING.html">HACKING.html</a>
|
||||||
on GitHub) file states things that are no longer true: a way of obfuscation
|
file states things that are no longer true: a way of obfuscation
|
||||||
itself! Instead of misleading comments it’s misleading statements in the
|
itself! Instead of misleading comments it’s misleading statements in the
|
||||||
file that explains what some of the things are for!</p></li>
|
file that explains what some of the things are for!</p></li>
|
||||||
<li><p>Misleading variable names for coordinates. In other words the <code>Y</code> coordinate is
|
<li><p>Misleading variable names for coordinates. In other words the <code>Y</code> coordinate is
|
||||||
@@ -746,7 +759,9 @@ goal; I think I did it but maybe I missed one here and/or there):</p>
|
|||||||
the file based on the 120 columns total. I believe I have succeeded in that
|
the file based on the 120 columns total. I believe I have succeeded in that
|
||||||
though again maybe I have an off by one or two here and/or there.</p>
|
though again maybe I have an off by one or two here and/or there.</p>
|
||||||
<p>Most of the primes above were intentional.</p>
|
<p>Most of the primes above were intentional.</p>
|
||||||
<h1 id="skinning-the-snake-i.e.-decreasing-the-iocccsize"><a name="skinning" href="#toc">Skinning the snake (i.e. decreasing the iocccsize)</a></h1>
|
<div id="skinning">
|
||||||
|
<h1 id="skinning-the-snake-i.e.-decreasing-the-iocccsize"><a href="#toc">Skinning the snake (i.e. decreasing the iocccsize)</a></h1>
|
||||||
|
</div>
|
||||||
<p>This happened in a number of ways and I have already documented some in other
|
<p>This happened in a number of ways and I have already documented some in other
|
||||||
parts. Now there are a number of reasons to do this: amongst them to make it
|
parts. Now there are a number of reasons to do this: amongst them to make it
|
||||||
possible to obfuscate (plus a more unique layout) but also to add more features.</p>
|
possible to obfuscate (plus a more unique layout) but also to add more features.</p>
|
||||||
@@ -784,7 +799,9 @@ for <code>A > 1</code> but I could refer to just <code>I</code> instead of <c
|
|||||||
add additional features and also to add proper error reporting (when <code>calloc()</code>
|
add additional features and also to add proper error reporting (when <code>calloc()</code>
|
||||||
failed I called <code>abort()</code> and before that if initialising ncurses failed I also
|
failed I called <code>abort()</code> and before that if initialising ncurses failed I also
|
||||||
called <code>abort()</code> and did not report any errors in either event but I do now).</p>
|
called <code>abort()</code> and did not report any errors in either event but I do now).</p>
|
||||||
<h1 id="a-few-more-interesting-size-optimisations"><a name="size" href="#toc">A few more interesting size optimisations</a></h1>
|
<div id="size">
|
||||||
|
<h1 id="a-few-more-interesting-size-optimisations"><a href="#toc">A few more interesting size optimisations</a></h1>
|
||||||
|
</div>
|
||||||
<p>As I was getting to the end of obfuscation (wrt size available - and it was
|
<p>As I was getting to the end of obfuscation (wrt size available - and it was
|
||||||
getting pretty obfuscated too - the majority of the techniques were already in
|
getting pretty obfuscated too - the majority of the techniques were already in
|
||||||
place at this point) I was looking at the code to see if I could figure out how
|
place at this point) I was looking at the code to see if I could figure out how
|
||||||
@@ -844,8 +861,8 @@ 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
|
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>
|
all spaces anyway. Thus I could save another three bytes by changing it to:</p>
|
||||||
<pre><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
|
<p>Technically it would be a <code>" "</code> (see <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/HACKING.html">HACKING.html</a>
|
||||||
<a href="HACKING.md">HACKING.md</a>) else for N (not referring to the variable though it might very
|
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.
|
well matter here too) movements (i.e. due to sizes) you will at times (e.g.
|
||||||
after eating a bug) see the snake body char at 0,0. I’m not bothered about that
|
after eating a bug) see the snake body char at 0,0. I’m not bothered about that
|
||||||
though because the score line is meant to display something, it squeezes a few
|
though because the score line is meant to display something, it squeezes a few
|
||||||
|
|||||||
+39
-21
@@ -1,6 +1,6 @@
|
|||||||
# Introduction (SPOILER ALERT)
|
# Introduction (SPOILER ALERT)
|
||||||
|
|
||||||
In the [gameplay.html][] ([gameplay.md][] on GitHub) file I have given enough
|
In the [gameplay.html][] file I have given enough
|
||||||
information to know how the game looks, how to move the snake, how to pause etc.
|
information to know how the game looks, how to move the snake, how to pause etc.
|
||||||
In this file I am including (some) information on how the game actually works:
|
In this file I am including (some) information on how the game actually works:
|
||||||
the technical details as it were, obfuscation techniques and also some of the
|
the technical details as it were, obfuscation techniques and also some of the
|
||||||
@@ -12,8 +12,7 @@ If you're still interested in this file (i.e. you're a judge or someone who
|
|||||||
wants to know more about it) read on. Yes I write a lot. But you probably
|
wants to know more about it) read on. Yes I write a lot. But you probably
|
||||||
already knew that so no harm there, hey?
|
already knew that so no harm there, hey?
|
||||||
|
|
||||||
<a name="toc"></a>
|
<div id="toc">
|
||||||
|
|
||||||
- [How does it work?](#works)
|
- [How does it work?](#works)
|
||||||
- [How does the snake movement work?](#movement)
|
- [How does the snake movement work?](#movement)
|
||||||
- [Drawing (manual) and computer playing (automatic) modes](#manual-automatic)
|
- [Drawing (manual) and computer playing (automatic) modes](#manual-automatic)
|
||||||
@@ -23,9 +22,12 @@ already knew that so no harm there, hey?
|
|||||||
- [Obfuscation](#obfuscation)
|
- [Obfuscation](#obfuscation)
|
||||||
- [Skinning the snake (i.e. decreasing the iocccsize)](#skinning)
|
- [Skinning the snake (i.e. decreasing the iocccsize)](#skinning)
|
||||||
- [A few more interesting size optimisations](#size)
|
- [A few more interesting size optimisations](#size)
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
# <a name="works" href="#toc">How does it work?</a>
|
<div id="works">
|
||||||
|
# <a href="#toc">How does it work?</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
The gameplay I have already described but this explains the way things are
|
The gameplay I have already described but this explains the way things are
|
||||||
actually done in more detail.
|
actually done in more detail.
|
||||||
@@ -105,7 +107,9 @@ bug the snake will not shed; if it sheds the snake will not move in the same
|
|||||||
manner as if it simply moved. Growth/movement can in some ways be conflated.
|
manner as if it simply moved. Growth/movement can in some ways be conflated.
|
||||||
|
|
||||||
|
|
||||||
# <a name="movement" href="#toc">How does the snake movement work?</a>
|
<div id="movement">
|
||||||
|
# <a href="#toc">How does the snake movement work?</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
The way the snake looks to move is that every time the snake moves the last
|
The way the snake looks to move is that every time the snake moves the last
|
||||||
position (the tail) is replaced with a space (`' '`). If the snake eats a bug
|
position (the tail) is replaced with a space (`' '`). If the snake eats a bug
|
||||||
@@ -118,7 +122,9 @@ positions that are shifted forward as the snake moves about the field looking
|
|||||||
for bugs.
|
for bugs.
|
||||||
|
|
||||||
|
|
||||||
# <a name="manual-automatic" href="#toc">Drawing (manual) and computer playing (automatic) modes</a>
|
<div id="manual-automatic">
|
||||||
|
# <a href="#toc">Drawing (manual) and computer playing (automatic) modes</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
How do these modes work? The `timeout()` function takes a signed int: if it's `<
|
How do these modes work? The `timeout()` function takes a signed int: if it's `<
|
||||||
0` it waits indefinitely; if it's `0` it returns immediately even if there's no
|
0` it waits indefinitely; if it's `0` it returns immediately even if there's no
|
||||||
@@ -129,7 +135,9 @@ will move as long as it's not paused etc. and otherwise it waits up to that many
|
|||||||
milliseconds (which is how the `0` value comes into play).
|
milliseconds (which is how the `0` value comes into play).
|
||||||
|
|
||||||
|
|
||||||
# <a name="collision" href="#toc">Collision detection</a>
|
<div id="collision">
|
||||||
|
# <a href="#toc">Collision detection</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
This was an interesting thing to work out. Because the snake could occupy more
|
This was an interesting thing to work out. Because the snake could occupy more
|
||||||
than one row and more than one column at a time the two arrays approach seemed
|
than one row and more than one column at a time the two arrays approach seemed
|
||||||
@@ -145,7 +153,9 @@ are very flexible and cunning who can tell what might happen? As I noted _these
|
|||||||
bugs are not bugs! :)_
|
bugs are not bugs! :)_
|
||||||
|
|
||||||
|
|
||||||
## <a name="cannibalcollision" href="#toc">Cannibal collision detection</a>
|
<div id="cannibalcollision">
|
||||||
|
## <a href="#toc">Cannibal collision detection</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
How does cannibalism change collision detection? The fact that each time the
|
How does cannibalism change collision detection? The fact that each time the
|
||||||
snake function is called there is a space printed at the tail end was a problem
|
snake function is called there is a space printed at the tail end was a problem
|
||||||
@@ -177,7 +187,9 @@ other. This can also appear to defy physics!
|
|||||||
Choose your poison. Or rather your venom.
|
Choose your poison. Or rather your venom.
|
||||||
|
|
||||||
|
|
||||||
## <a name="resizing" href="#toc">Collision detection when resizing the window of the game</a>
|
<div id="resizing">
|
||||||
|
## <a href="#toc">Collision detection when resizing the window of the game</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
What happens if the window is resized during the game? If the size is increased
|
What happens if the window is resized during the game? If the size is increased
|
||||||
then the border can (and will) stay the same; but if the window is shrunk then
|
then the border can (and will) stay the same; but if the window is shrunk then
|
||||||
@@ -196,7 +208,9 @@ was increased in size but I believe that's resolved. Anyway what kind of field
|
|||||||
in real life increases in size like that so suddenly? :)
|
in real life increases in size like that so suddenly? :)
|
||||||
|
|
||||||
|
|
||||||
# <a name="obfuscation" href="#toc">Obfuscation</a>
|
<div id="obfuscation">
|
||||||
|
# <a href="#toc">Obfuscation</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
- I make use of the C token pasting operator. Although this is well known it's
|
- I make use of the C token pasting operator. Although this is well known it's
|
||||||
probably less known and either way it's not as simple as just having the code
|
probably less known and either way it's not as simple as just having the code
|
||||||
@@ -427,11 +441,11 @@ dimensions. Now in the first call in `main()` I have the code and tests followin
|
|||||||
offsets for every time I use negative offsets. But where's the fun in that? :)
|
offsets for every time I use negative offsets. But where's the fun in that? :)
|
||||||
|
|
||||||
BTW: Some of these are not in the table of expressions in the
|
BTW: Some of these are not in the table of expressions in the
|
||||||
[HACKING.html][] ([HACKING.md][] on GitHub) file. Also there might be some
|
[HACKING.html][] file. Also there might be some
|
||||||
code in there that is no longer correct (it was before I started
|
code in there that is no longer correct (it was before I started
|
||||||
obfuscation) though it might be able to give an idea. Spoilers abound in
|
obfuscation) though it might be able to give an idea. Spoilers abound in
|
||||||
that file (in addition to this file) but the [HACKING.html][] ([HACKING.md][]
|
that file (in addition to this file) but the [HACKING.html][]
|
||||||
on GitHub) file states things that are no longer true: a way of obfuscation
|
file states things that are no longer true: a way of obfuscation
|
||||||
itself! Instead of misleading comments it's misleading statements in the
|
itself! Instead of misleading comments it's misleading statements in the
|
||||||
file that explains what some of the things are for!
|
file that explains what some of the things are for!
|
||||||
|
|
||||||
@@ -783,7 +797,10 @@ though again maybe I have an off by one or two here and/or there.
|
|||||||
|
|
||||||
Most of the primes above were intentional.
|
Most of the primes above were intentional.
|
||||||
|
|
||||||
# <a name="skinning" href="#toc">Skinning the snake (i.e. decreasing the iocccsize)</a>
|
|
||||||
|
<div id="skinning">
|
||||||
|
# <a href="#toc">Skinning the snake (i.e. decreasing the iocccsize)</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
This happened in a number of ways and I have already documented some in other
|
This happened in a number of ways and I have already documented some in other
|
||||||
parts. Now there are a number of reasons to do this: amongst them to make it
|
parts. Now there are a number of reasons to do this: amongst them to make it
|
||||||
@@ -837,7 +854,10 @@ add additional features and also to add proper error reporting (when `calloc()`
|
|||||||
failed I called `abort()` and before that if initialising ncurses failed I also
|
failed I called `abort()` and before that if initialising ncurses failed I also
|
||||||
called `abort()` and did not report any errors in either event but I do now).
|
called `abort()` and did not report any errors in either event but I do now).
|
||||||
|
|
||||||
# <a name="size" href="#toc">A few more interesting size optimisations</a>
|
|
||||||
|
<div id="size">
|
||||||
|
# <a href="#toc">A few more interesting size optimisations</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
As I was getting to the end of obfuscation (wrt size available - and it was
|
As I was getting to the end of obfuscation (wrt size available - and it was
|
||||||
getting pretty obfuscated too - the majority of the techniques were already in
|
getting pretty obfuscated too - the majority of the techniques were already in
|
||||||
@@ -934,18 +954,16 @@ all spaces anyway. Thus I could save another three bytes by changing it to:
|
|||||||
!o && q *U,*V,' ');
|
!o && q *U,*V,' ');
|
||||||
```
|
```
|
||||||
|
|
||||||
Technically it would be a `" "` (see [HACKING.html][] or on GitHub
|
Technically it would be a `" "` (see [HACKING.html][]
|
||||||
[HACKING.md][]) else for N (not referring to the variable though it might very
|
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.
|
well matter here too) movements (i.e. due to sizes) you will at times (e.g.
|
||||||
after eating a bug) see the snake body char at 0,0. I'm not bothered about that
|
after eating a bug) see the snake body char at 0,0. I'm not bothered about that
|
||||||
though because the score line is meant to display something, it squeezes a few
|
though because the score line is meant to display something, it squeezes a few
|
||||||
more bytes and having a space is hardly an imposition on usage (and for that
|
more bytes and having a space is hardly an imposition on usage (and for that
|
||||||
matter having a 'o' at 0,0 isn't either).
|
matter having a 'o' at 0,0 isn't either).
|
||||||
|
|
||||||
[gameplay.md]: gameplay.md
|
[gameplay.html]: %%REPO_URL%%/2020/ferguson1/gameplay.html
|
||||||
[gameplay.html]: gameplay.html
|
[HACKING.html]: %%REPO_URL%%/2020/ferguson1/HACKING.html
|
||||||
[HACKING.md]: HACKING.md
|
|
||||||
[HACKING.html]: HACKING.html
|
|
||||||
|
|
||||||
|
|
||||||
<hr style="width:10%;text-align:left;margin-left:0">
|
<hr style="width:10%;text-align:left;margin-left:0">
|
||||||
|
|||||||
@@ -138,7 +138,7 @@
|
|||||||
<p>Terminals are very easy to mess up and for that reason they deserve their own
|
<p>Terminals are very easy to mess up and for that reason they deserve their own
|
||||||
file. I discuss terminal capabilities, dimensions (setting and how to restore
|
file. I discuss terminal capabilities, dimensions (setting and how to restore
|
||||||
sanity if it causes any problems) as well as colours (limitations etc.).</p>
|
sanity if it causes any problems) as well as colours (limitations etc.).</p>
|
||||||
<p><a name="toc"></a></p>
|
<div id="toc">
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#termcaps">Capabilities support testing program</a></li>
|
<li><a href="#termcaps">Capabilities support testing program</a></li>
|
||||||
<li><a href="#dimensions">Setting the game dimensions</a>
|
<li><a href="#dimensions">Setting the game dimensions</a>
|
||||||
@@ -157,14 +157,17 @@ sanity if it causes any problems) as well as colours (limitations etc.).</p>
|
|||||||
<li><a href="#disablecolour">Disabling colour</a></li>
|
<li><a href="#disablecolour">Disabling colour</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h1 id="capabilities-support-testing-program"><a name="termcaps" href="#toc">Capabilities support testing program</a></h1>
|
</div>
|
||||||
|
<div id="termcaps">
|
||||||
|
<h1 id="capabilities-support-testing-program"><a href="#toc">Capabilities support testing program</a></h1>
|
||||||
|
</div>
|
||||||
<p>Although it should be playable without the features I use (except that cursor
|
<p>Although it should be playable without the features I use (except that cursor
|
||||||
movement is required) I have provided a source file that can test your terminal
|
movement is required) I have provided a source file that can test your terminal
|
||||||
for the capabilities I use in the entry.</p>
|
for the capabilities I use in the entry.</p>
|
||||||
<p>It also tries to determine the minimum number of columns to play without the
|
<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>
|
status line overflowing - even with the dynamic length. Try:</p>
|
||||||
<pre><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>
|
<p>This compiles the program <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/termcaps.c">termcaps.c</a> and runs it; you should see something like:</p>
|
||||||
<pre><code> terminal supports cursor movement
|
<pre><code> terminal supports cursor movement
|
||||||
terminal supports making cursor invisible
|
terminal supports making cursor invisible
|
||||||
terminal supports bold
|
terminal supports bold
|
||||||
@@ -228,11 +231,15 @@ problems are if curses fails to initialise or if movement of cursor cannot be
|
|||||||
done (both seem unlikely to happen nowadays).</p>
|
done (both seem unlikely to happen nowadays).</p>
|
||||||
<p>Both scripts run this utility and prompt if there are any problems;
|
<p>Both scripts run this utility and prompt if there are any problems;
|
||||||
you can continue either way.</p>
|
you can continue either way.</p>
|
||||||
<h1 id="setting-the-game-dimensions"><a name="dimensions" href="#toc">Setting the game dimensions</a></h1>
|
<div id="dimensions">
|
||||||
|
<h1 id="setting-the-game-dimensions"><a href="#toc">Setting the game dimensions</a></h1>
|
||||||
|
</div>
|
||||||
<p>There are a number of ways to do this and only one will keep the terminal sane
|
<p>There are a number of ways to do this and only one will keep the terminal sane
|
||||||
all the time but that’s by running it under a terminal emulator that you can
|
all the time but that’s by running it under a terminal emulator that you can
|
||||||
resize the window with first. But what if you want exacts?</p>
|
resize the window with first. But what if you want exacts?</p>
|
||||||
<h2 id="the-lines-and-columns-environmental-variables"><a name="linescolumns" href="#toc">The LINES and COLUMNS environmental variables</a></h2>
|
<div id="linescolumns">
|
||||||
|
<h2 id="the-lines-and-columns-environmental-variables"><a href="#toc">The LINES and COLUMNS environmental variables</a></h2>
|
||||||
|
</div>
|
||||||
<p>To specify the lines/columns of curses program per instance use the <code>LINES</code> and
|
<p>To specify the lines/columns of curses program per instance use the <code>LINES</code> and
|
||||||
<code>COLUMNS</code> environmental variables.</p>
|
<code>COLUMNS</code> environmental variables.</p>
|
||||||
<p>For demonstration consider the following:</p>
|
<p>For demonstration consider the following:</p>
|
||||||
@@ -247,13 +254,17 @@ 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>
|
<pre><code> X:27/54 Y:20/41 S:5/997 B:0</code></pre>
|
||||||
<p>But problems can arise with messing with dimensions: in my tests this held only
|
<p>But problems can arise with messing with dimensions: in my tests this held only
|
||||||
to lines.</p>
|
to lines.</p>
|
||||||
<h2 id="terminal-insanity"><a name="insanity" href="#toc">Terminal insanity</a></h2>
|
<div id="insanity">
|
||||||
|
<h2 id="terminal-insanity"><a href="#toc">Terminal insanity</a></h2>
|
||||||
|
</div>
|
||||||
<p>Terminal sanity can be compromised and it can cause all sorts of output
|
<p>Terminal sanity can be compromised and it can cause all sorts of output
|
||||||
problems; it might not appear right away but it will show its ugly head
|
problems; it might not appear right away but it will show its ugly head
|
||||||
eventually if you use it. For example pager output might be screwy, echo might
|
eventually if you use it. For example pager output might be screwy, echo might
|
||||||
be turned off, output of commands might overwrite the input of those commands,
|
be turned off, output of commands might overwrite the input of those commands,
|
||||||
etc. For the game you might not see the final score.</p>
|
etc. For the game you might not see the final score.</p>
|
||||||
<h3 id="restoring-the-terminal"><a name="restore" href="#toc">Restoring the terminal</a></h3>
|
<div id="restore">
|
||||||
|
<h3 id="restoring-the-terminal"><a href="#toc">Restoring the terminal</a></h3>
|
||||||
|
</div>
|
||||||
<p>In my tests there is one thing that at least allows you to see the final score
|
<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
|
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>
|
prog.alt version does. You might run it as one of:</p>
|
||||||
@@ -277,7 +288,9 @@ 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
|
<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
|
||||||
console HOWTO</a> (specifically <a href="https://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-4.html">Linux keyboard and console HOWTO section 4</a>).
|
console HOWTO</a> (specifically <a href="https://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-4.html">Linux keyboard and console HOWTO section 4</a>).
|
||||||
Yes this works under macOS (at least it did for me).</p>
|
Yes this works under macOS (at least it did for me).</p>
|
||||||
<h3 id="terminal-size-abuse"><a name="abuse" href="#toc">Terminal size abuse</a></h3>
|
<div id="abuse">
|
||||||
|
<h3 id="terminal-size-abuse"><a href="#toc">Terminal size abuse</a></h3>
|
||||||
|
</div>
|
||||||
<p>So players 1, 2 and 3 are content with not meddling with the terminal sizes
|
<p>So players 1, 2 and 3 are content with not meddling with the terminal sizes
|
||||||
outside what’s actually possible with their screen. But then player 4 comes
|
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
|
along and thinks he/she will be clever and mess with the dimensions a bit. Let’s
|
||||||
@@ -291,30 +304,37 @@ number of lines will be 997. If they were to do:</p>
|
|||||||
to be funny.</p>
|
to be funny.</p>
|
||||||
<p>The game will try and be funny in return and you can expect it to not function
|
<p>The game will try and be funny in return and you can expect it to not function
|
||||||
properly. Because that’s what funny means in this context.</p>
|
properly. Because that’s what funny means in this context.</p>
|
||||||
<h1 id="terminal-limitations"><a name="termlimitations" href="#toc">Terminal limitations</a></h1>
|
<div id="termlimitations">
|
||||||
|
<h1 id="terminal-limitations"><a href="#toc">Terminal limitations</a></h1>
|
||||||
|
</div>
|
||||||
<p>It’d be nice if curses could detect hitting more than one arrow key at the
|
<p>It’d be nice if curses could detect hitting more than one arrow key at the
|
||||||
same time so that diagonal directions would be possible but unfortunately it’s
|
same time so that diagonal directions would be possible but unfortunately it’s
|
||||||
not (<code>cat -v</code> confirms this). Even if I were to define four extra keys what
|
not (<code>cat -v</code> confirms this). Even if I were to define four extra keys what
|
||||||
would they be? And what about the head character? The <a href="HACKING.html">HACKING.html</a>
|
would they be? And what about the head character? The <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/HACKING.html">HACKING.html</a>
|
||||||
(<a href="HACKING.md">HACKING</a> on GitHub) file has information on this.</p>
|
file has information on this.</p>
|
||||||
<p>I also limit the terminal size to 10 lines/columns but most likely it would
|
<p>I also limit the terminal size to 10 lines/columns but most likely it would
|
||||||
require the cheat modes to win and in any event allowing certain low values
|
require the cheat modes to win and in any event allowing certain low values
|
||||||
causes problems e.g. <strong>LINES=6 COLUMNS=6</strong> and <strong>LINES=3 COLUMNS=3</strong> caused some
|
causes problems e.g. <strong>LINES=6 COLUMNS=6</strong> and <strong>LINES=3 COLUMNS=3</strong> caused some
|
||||||
nasty issues.</p>
|
nasty issues.</p>
|
||||||
<h1 id="terminal-colours"><a name="colours" href="#toc">Terminal colours</a></h1>
|
<div id="colours">
|
||||||
|
<h1 id="terminal-colours"><a href="#toc">Terminal colours</a></h1>
|
||||||
|
</div>
|
||||||
<p>N.B.: If all you’re after is wanting to change the colours see the script
|
<p>N.B.: If all you’re after is wanting to change the colours see the script
|
||||||
<a href="snake-colours.sh">snake-colours.sh</a> instead. The rest of this file was mostly notes for the
|
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/snake-colours.sh">snake-colours.sh</a> instead. The rest of this file was mostly notes for the
|
||||||
judges; here I discuss the background, foreground as well as limitations (in
|
judges; here I discuss the background, foreground as well as limitations (in
|
||||||
particular runtime limitations).</p>
|
particular runtime limitations).</p>
|
||||||
<h2 id="curses-background"><a name="background" href="#toc">Curses background</a></h2>
|
<div id="background">
|
||||||
|
<h2 id="curses-background"><a href="#toc">Curses background</a></h2>
|
||||||
|
</div>
|
||||||
<p>The documentation I have seen says that the background will always be black and
|
<p>The documentation I have seen says that the background will always be black and
|
||||||
from a quick test this holds even with a terminal that has a white background.
|
from a quick test this holds even with a terminal that has a white background.
|
||||||
There is a way to force the background to remain white though that’s by way of
|
There is a way to force the background to remain white though that’s by way of
|
||||||
monochrome (so no colours); I discuss that and another related terminal specific
|
monochrome (so no colours); I discuss that and another related terminal specific
|
||||||
in the troubleshooting guide (there’s another way but it would take me over the
|
in the troubleshooting guide (there’s another way but it would take me over the
|
||||||
iocccsize; I talk about it in the <a href="HACKING.html">HACKING.html</a> (<a href="HACKING.md">HACKING</a> on
|
iocccsize; I talk about it in the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/HACKING.html">HACKING.html</a>.</p>
|
||||||
GitHub) file).</p>
|
<div id="monochrome">
|
||||||
<h2 id="monochrome-terminals"><a name="monochrome" href="#toc">Monochrome terminals</a></h2>
|
<h2 id="monochrome-terminals"><a href="#toc">Monochrome terminals</a></h2>
|
||||||
|
</div>
|
||||||
<p>According to my tests for monochrome terminals the screen has the white and
|
<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
|
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>
|
foreground that is the order it is too. You can try that like:</p>
|
||||||
@@ -324,7 +344,9 @@ 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
|
should you need colours to be disabled but I personally have not run into any
|
||||||
problems even with monochrome terminals. Later I say what to do to remove colour
|
problems even with monochrome terminals. Later I say what to do to remove colour
|
||||||
support in the source code itself.</p>
|
support in the source code itself.</p>
|
||||||
<h2 id="colour-limitations"><a name="colourlimitations" href="#toc">Colour limitations</a></h2>
|
<div id="colourlimitations">
|
||||||
|
<h2 id="colour-limitations"><a href="#toc">Colour limitations</a></h2>
|
||||||
|
</div>
|
||||||
<p>According to X/Open Curses, Issue 7 (pg. 57):</p>
|
<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
|
<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
|
from 0 to and including COLOR_PAIRS-1. (There may be an
|
||||||
@@ -385,7 +407,9 @@ instead:</p>
|
|||||||
won’t work for a colour-capable terminal but it doesn’t matter for monochrome
|
won’t work for a colour-capable terminal but it doesn’t matter for monochrome
|
||||||
terminals one way or another. And since I don’t go beyond the ranges (as I cited
|
terminals one way or another. And since I don’t go beyond the ranges (as I cited
|
||||||
earlier) there shouldn’t be any problem here.</p>
|
earlier) there shouldn’t be any problem here.</p>
|
||||||
<h2 id="disabling-colour"><a name="disablecolour" href="#toc">Disabling colour</a></h2>
|
<div id="disablecolour">
|
||||||
|
<h2 id="disabling-colour"><a href="#toc">Disabling colour</a></h2>
|
||||||
|
</div>
|
||||||
<p>Nevertheless if it is a problem and you don’t want to use a monochrome terminal
|
<p>Nevertheless if it is a problem and you don’t want to use a monochrome terminal
|
||||||
(or can’t):</p>
|
(or can’t):</p>
|
||||||
<p>First comment out the code that has <code>start_color();</code> and then add <code>return;</code> to the
|
<p>First comment out the code that has <code>start_color();</code> and then add <code>return;</code> to the
|
||||||
|
|||||||
+49
-21
@@ -5,8 +5,7 @@ file. I discuss terminal capabilities, dimensions (setting and how to restore
|
|||||||
sanity if it causes any problems) as well as colours (limitations etc.).
|
sanity if it causes any problems) as well as colours (limitations etc.).
|
||||||
|
|
||||||
|
|
||||||
<a name="toc"></a>
|
<div id="toc">
|
||||||
|
|
||||||
- [Capabilities support testing program](#termcaps)
|
- [Capabilities support testing program](#termcaps)
|
||||||
- [Setting the game dimensions](#dimensions)
|
- [Setting the game dimensions](#dimensions)
|
||||||
* [The LINES and COLUMNS environmental variables](#linescolumns)
|
* [The LINES and COLUMNS environmental variables](#linescolumns)
|
||||||
@@ -19,9 +18,12 @@ sanity if it causes any problems) as well as colours (limitations etc.).
|
|||||||
* [Monochrome terminals](#monochrome)
|
* [Monochrome terminals](#monochrome)
|
||||||
* [Colour limitations](#colourlimitations)
|
* [Colour limitations](#colourlimitations)
|
||||||
* [Disabling colour](#disablecolour)
|
* [Disabling colour](#disablecolour)
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
# <a name="termcaps" href="#toc">Capabilities support testing program</a>
|
<div id="termcaps">
|
||||||
|
# <a href="#toc">Capabilities support testing program</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
Although it should be playable without the features I use (except that cursor
|
Although it should be playable without the features I use (except that cursor
|
||||||
movement is required) I have provided a source file that can test your terminal
|
movement is required) I have provided a source file that can test your terminal
|
||||||
@@ -34,7 +36,7 @@ status line overflowing - even with the dynamic length. Try:
|
|||||||
$ make test
|
$ make test
|
||||||
```
|
```
|
||||||
|
|
||||||
This compiles the program [termcaps.c](termcaps.c) and runs it; you should see something like:
|
This compiles the program [termcaps.c](%%REPO_URL%%/2020/ferguson1/termcaps.c) and runs it; you should see something like:
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -115,14 +117,19 @@ done (both seem unlikely to happen nowadays).
|
|||||||
Both scripts run this utility and prompt if there are any problems;
|
Both scripts run this utility and prompt if there are any problems;
|
||||||
you can continue either way.
|
you can continue either way.
|
||||||
|
|
||||||
# <a name="dimensions" href="#toc">Setting the game dimensions</a>
|
|
||||||
|
<div id="dimensions">
|
||||||
|
# <a href="#toc">Setting the game dimensions</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
There are a number of ways to do this and only one will keep the terminal sane
|
There are a number of ways to do this and only one will keep the terminal sane
|
||||||
all the time but that's by running it under a terminal emulator that you can
|
all the time but that's by running it under a terminal emulator that you can
|
||||||
resize the window with first. But what if you want exacts?
|
resize the window with first. But what if you want exacts?
|
||||||
|
|
||||||
|
|
||||||
## <a name="linescolumns" href="#toc">The LINES and COLUMNS environmental variables</a>
|
<div id="linescolumns">
|
||||||
|
## <a href="#toc">The LINES and COLUMNS environmental variables</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
To specify the lines/columns of curses program per instance use the `LINES` and
|
To specify the lines/columns of curses program per instance use the `LINES` and
|
||||||
`COLUMNS` environmental variables.
|
`COLUMNS` environmental variables.
|
||||||
@@ -151,7 +158,10 @@ game dimensions) - to be 55; it might look like this instead:
|
|||||||
But problems can arise with messing with dimensions: in my tests this held only
|
But problems can arise with messing with dimensions: in my tests this held only
|
||||||
to lines.
|
to lines.
|
||||||
|
|
||||||
## <a name="insanity" href="#toc">Terminal insanity</a>
|
|
||||||
|
<div id="insanity">
|
||||||
|
## <a href="#toc">Terminal insanity</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
Terminal sanity can be compromised and it can cause all sorts of output
|
Terminal sanity can be compromised and it can cause all sorts of output
|
||||||
problems; it might not appear right away but it will show its ugly head
|
problems; it might not appear right away but it will show its ugly head
|
||||||
@@ -160,7 +170,9 @@ be turned off, output of commands might overwrite the input of those commands,
|
|||||||
etc. For the game you might not see the final score.
|
etc. For the game you might not see the final score.
|
||||||
|
|
||||||
|
|
||||||
### <a name="restore" href="#toc">Restoring the terminal</a>
|
<div id="restore">
|
||||||
|
### <a href="#toc">Restoring the terminal</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
In my tests there is one thing that at least allows you to see the final score
|
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
|
and that is by running `clear` before running the program. That's what the
|
||||||
@@ -201,7 +213,10 @@ For more information on this subject generally see the [Linux keyboard and
|
|||||||
console HOWTO][] (specifically [Linux keyboard and console HOWTO section 4][]).
|
console HOWTO][] (specifically [Linux keyboard and console HOWTO section 4][]).
|
||||||
Yes this works under macOS (at least it did for me).
|
Yes this works under macOS (at least it did for me).
|
||||||
|
|
||||||
### <a name="abuse" href="#toc">Terminal size abuse</a>
|
|
||||||
|
<div id="abuse">
|
||||||
|
### <a href="#toc">Terminal size abuse</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
So players 1, 2 and 3 are content with not meddling with the terminal sizes
|
So players 1, 2 and 3 are content with not meddling with the terminal sizes
|
||||||
outside what's actually possible with their screen. But then player 4 comes
|
outside what's actually possible with their screen. But then player 4 comes
|
||||||
@@ -227,13 +242,15 @@ The game will try and be funny in return and you can expect it to not function
|
|||||||
properly. Because that's what funny means in this context.
|
properly. Because that's what funny means in this context.
|
||||||
|
|
||||||
|
|
||||||
# <a name="termlimitations" href="#toc">Terminal limitations</a>
|
<div id="termlimitations">
|
||||||
|
# <a href="#toc">Terminal limitations</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
It'd be nice if curses could detect hitting more than one arrow key at the
|
It'd be nice if curses could detect hitting more than one arrow key at the
|
||||||
same time so that diagonal directions would be possible but unfortunately it's
|
same time so that diagonal directions would be possible but unfortunately it's
|
||||||
not (`cat -v` confirms this). Even if I were to define four extra keys what
|
not (`cat -v` confirms this). Even if I were to define four extra keys what
|
||||||
would they be? And what about the head character? The [HACKING.html][]
|
would they be? And what about the head character? The [HACKING.html][]
|
||||||
([HACKING](HACKING.md) on GitHub) file has information on this.
|
file has information on this.
|
||||||
|
|
||||||
I also limit the terminal size to 10 lines/columns but most likely it would
|
I also limit the terminal size to 10 lines/columns but most likely it would
|
||||||
require the cheat modes to win and in any event allowing certain low values
|
require the cheat modes to win and in any event allowing certain low values
|
||||||
@@ -241,25 +258,31 @@ causes problems e.g. **LINES=6 COLUMNS=6** and **LINES=3 COLUMNS=3** caused some
|
|||||||
nasty issues.
|
nasty issues.
|
||||||
|
|
||||||
|
|
||||||
# <a name="colours" href="#toc">Terminal colours</a>
|
<div id="colours">
|
||||||
|
# <a href="#toc">Terminal colours</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
N.B.: If all you're after is wanting to change the colours see the script
|
N.B.: If all you're after is wanting to change the colours see the script
|
||||||
[snake-colours.sh][] instead. The rest of this file was mostly notes for the
|
[snake-colours.sh][] instead. The rest of this file was mostly notes for the
|
||||||
judges; here I discuss the background, foreground as well as limitations (in
|
judges; here I discuss the background, foreground as well as limitations (in
|
||||||
particular runtime limitations).
|
particular runtime limitations).
|
||||||
|
|
||||||
## <a name="background" href="#toc">Curses background</a>
|
|
||||||
|
<div id="background">
|
||||||
|
## <a href="#toc">Curses background</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
The documentation I have seen says that the background will always be black and
|
The documentation I have seen says that the background will always be black and
|
||||||
from a quick test this holds even with a terminal that has a white background.
|
from a quick test this holds even with a terminal that has a white background.
|
||||||
There is a way to force the background to remain white though that's by way of
|
There is a way to force the background to remain white though that's by way of
|
||||||
monochrome (so no colours); I discuss that and another related terminal specific
|
monochrome (so no colours); I discuss that and another related terminal specific
|
||||||
in the troubleshooting guide (there's another way but it would take me over the
|
in the troubleshooting guide (there's another way but it would take me over the
|
||||||
iocccsize; I talk about it in the [HACKING.html][] ([HACKING](HACKING.md) on
|
iocccsize; I talk about it in the [HACKING.html][].
|
||||||
GitHub) file).
|
|
||||||
|
|
||||||
## <a name="monochrome" href="#toc">Monochrome terminals</a>
|
|
||||||
|
|
||||||
|
<div id="monochrome">
|
||||||
|
## <a href="#toc">Monochrome terminals</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
According to my tests for monochrome terminals the screen has the white and
|
According to my tests for monochrome terminals the screen has the white and
|
||||||
black background; if terminal is configured to be black background white
|
black background; if terminal is configured to be black background white
|
||||||
@@ -275,7 +298,10 @@ should you need colours to be disabled but I personally have not run into any
|
|||||||
problems even with monochrome terminals. Later I say what to do to remove colour
|
problems even with monochrome terminals. Later I say what to do to remove colour
|
||||||
support in the source code itself.
|
support in the source code itself.
|
||||||
|
|
||||||
## <a name="colourlimitations" href="#toc">Colour limitations</a>
|
|
||||||
|
<div id="colourlimitations">
|
||||||
|
## <a href="#toc">Colour limitations</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
According to X/Open Curses, Issue 7 (pg. 57):
|
According to X/Open Curses, Issue 7 (pg. 57):
|
||||||
|
|
||||||
@@ -369,7 +395,10 @@ won't work for a colour-capable terminal but it doesn't matter for monochrome
|
|||||||
terminals one way or another. And since I don't go beyond the ranges (as I cited
|
terminals one way or another. And since I don't go beyond the ranges (as I cited
|
||||||
earlier) there shouldn't be any problem here.
|
earlier) there shouldn't be any problem here.
|
||||||
|
|
||||||
## <a name="disablecolour" href="#toc">Disabling colour</a>
|
|
||||||
|
<div id="disablecolour">
|
||||||
|
## <a href="#toc">Disabling colour</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
Nevertheless if it is a problem and you don't want to use a monochrome terminal
|
Nevertheless if it is a problem and you don't want to use a monochrome terminal
|
||||||
(or can't):
|
(or can't):
|
||||||
@@ -381,11 +410,10 @@ 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
|
Perhaps you only need to add the `return;` to `C()`. My guess is that's the case
|
||||||
but I do not know for certain.
|
but I do not know for certain.
|
||||||
|
|
||||||
[HACKING.md]: HACKING.md
|
[HACKING.html]: %%REPO_URL%%/2020/ferguson1/HACKING.html
|
||||||
[HACKING.html]: HACKING.html
|
|
||||||
[Linux keyboard and console HOWTO]: https://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO.html
|
[Linux keyboard and console HOWTO]: https://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO.html
|
||||||
[Linux keyboard and console HOWTO section 4]: https://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-4.html
|
[Linux keyboard and console HOWTO section 4]: https://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-4.html
|
||||||
[snake-colours.sh]: snake-colours.sh
|
[snake-colours.sh]: %%REPO_URL%%/2020/ferguson1/snake-colours.sh
|
||||||
|
|
||||||
|
|
||||||
<hr style="width:10%;text-align:left;margin-left:0">
|
<hr style="width:10%;text-align:left;margin-left:0">
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ it as structured as possible/easiest to find.</p>
|
|||||||
<h2 id="the-top-wall-isnt-allsome-of-the-time-visible"><a name="topwall" href="#toc">The top wall isn’t (all/some of the time) visible!</a></h2>
|
<h2 id="the-top-wall-isnt-allsome-of-the-time-visible"><a name="topwall" href="#toc">The top wall isn’t (all/some of the time) visible!</a></h2>
|
||||||
<p>Because the score line is dynamic in length depending on the terminal size it
|
<p>Because the score line is dynamic in length depending on the terminal size it
|
||||||
can happen that the score/status wraps to the next line(s). This can be fixed by
|
can happen that the score/status wraps to the next line(s). This can be fixed by
|
||||||
modifying the status line (see <a href="HACKING.html">HACKING.html</a> or on GitHub <a href="HACKING.md">HACKING.md</a>) but
|
modifying the status line (see <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/HACKING.html">HACKING.html</a> but
|
||||||
you shouldn’t need it to be very wide.</p>
|
you shouldn’t need it to be very wide.</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><p>RESOLUTION #0: Use a bigger screen (it doesn’t take that many columns)</p>
|
<li><p>RESOLUTION #0: Use a bigger screen (it doesn’t take that many columns)</p>
|
||||||
@@ -166,12 +166,12 @@ needed. This won’t work right if you change the score line!</p>
|
|||||||
<p>Note that this utility is not perfect; I describe this elsewhere. Either way a
|
<p>Note that this utility is not perfect; I describe this elsewhere. Either way a
|
||||||
small screen will make it harder to play esp without the cheat modes enabled
|
small screen will make it harder to play esp without the cheat modes enabled
|
||||||
(but they can still be fun with large screens).</p></li>
|
(but they can still be fun with large screens).</p></li>
|
||||||
<li><p>RESOLUTION #1: Open the <a href="prog.c">prog.c</a> and change the line</p>
|
<li><p>RESOLUTION #1: Open the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/prog.c">prog.c</a> and change the line</p>
|
||||||
<pre><code> #define J Z(X:%d/%d Y:%d/%d S:%zu/%zu B:%zu\n),Y,y[-2],X, *y, A, g, c );</code></pre>
|
<pre><code> #define J Z(X:%d/%d Y:%d/%d S:%zu/%zu B:%zu\n),Y,y[-2],X, *y, A, g, c );</code></pre>
|
||||||
<p>To be something like:</p>
|
<p>To be something like:</p>
|
||||||
<pre><code> #define J Z(B:%zu\n), c);</code></pre>
|
<pre><code> #define J Z(B:%zu\n), c);</code></pre>
|
||||||
<p>Recompile and try again. That will then show only the number of bugs eaten.
|
<p>Recompile and try again. That will then show only the number of bugs eaten.
|
||||||
See the <a href="HACKING.html">HACKING.html</a> (<a href="HACKING.md">HACKING.md</a> on GitHub) file for other data you
|
See the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/HACKING.html">HACKING.html</a> file for other data you
|
||||||
can include (though there are some discrepancies here and there as you’ll
|
can include (though there are some discrepancies here and there as you’ll
|
||||||
see).</p></li>
|
see).</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -194,8 +194,8 @@ when it does move you’ll see it doesn’t move for long.</p>
|
|||||||
<p>Sometimes also it might appear that the movement is delayed but there are
|
<p>Sometimes also it might appear that the movement is delayed but there are
|
||||||
numerous causes for this some of which are a busy computer but ultimately
|
numerous causes for this some of which are a busy computer but ultimately
|
||||||
it’ll catch up; just give it the time it needs.</p></li>
|
it’ll catch up; just give it the time it needs.</p></li>
|
||||||
<li><p>BOTTOM LINE: If you want more information then see the <a href="bugs.html">bugs.html</a>
|
<li><p>BOTTOM LINE: If you want more information then see the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/bugs.html">bugs.html</a>
|
||||||
(<a href="bugs.md">bugs.md</a> on GitHub) file.</p></li>
|
file.</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h2 id="i-cant-see-the-snake-head-or-other-part-of-the-snake"><a name="invisiblehead" href="#toc">I can’t see the snake head (or other part of the snake)!</a></h2>
|
<h2 id="i-cant-see-the-snake-head-or-other-part-of-the-snake"><a name="invisiblehead" href="#toc">I can’t see the snake head (or other part of the snake)!</a></h2>
|
||||||
<p>Possibly this could happen with too long a score line which I already discussed.
|
<p>Possibly this could happen with too long a score line which I already discussed.
|
||||||
@@ -239,7 +239,7 @@ desperate copy and paste the entire file into a document and search for the bug
|
|||||||
char (if it’s an editor like vi/vim you will have to be sure to escape the char
|
char (if it’s an editor like vi/vim you will have to be sure to escape the char
|
||||||
since <code>*</code> is a regexp metacharacter). This has happened to me numerous times.</p></li>
|
since <code>*</code> is a regexp metacharacter). This has happened to me numerous times.</p></li>
|
||||||
<li><p>RESOLUTION #3: If the colour contrast is not good for your eyes use the
|
<li><p>RESOLUTION #3: If the colour contrast is not good for your eyes use the
|
||||||
<a href="snake-colours">snake-colours</a> script to select a different colour scheme.</p></li>
|
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/snake-colours.sh">snake-colours.sh</a> script to select a different colour scheme.</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h2 id="the-game-froze"><a name="froze" href="#toc">The game froze!</a></h2>
|
<h2 id="the-game-froze"><a name="froze" href="#toc">The game froze!</a></h2>
|
||||||
<p>This should not be possible either but without certain safety checks in place I
|
<p>This should not be possible either but without certain safety checks in place I
|
||||||
@@ -353,9 +353,9 @@ at least) it’s at <code>/usr/share/terminfo/6c/linux-m</code> (for macOS Ventu
|
|||||||
background white and the foreground black. This will of course mean you have
|
background white and the foreground black. This will of course mean you have
|
||||||
no colour but unfortunately changing the background colour of curses would
|
no colour but unfortunately changing the background colour of curses would
|
||||||
eat too many bytes in the entry (I cite the functions in the
|
eat too many bytes in the entry (I cite the functions in the
|
||||||
<a href="HACKING.html">HACKING.html</a> (<a href="HACKING.md">HACKING.md</a> on GitHub) file).</p>
|
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/HACKING.html">HACKING.html</a>.</p>
|
||||||
<p>I discuss colours and terminals in much more detail in
|
<p>I discuss colours and terminals in much more detail in
|
||||||
<a href="terminals.html">terminals.html</a> (<a href="terminals.md">terminals.md</a> on GitHub).</p></li>
|
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/terminals.html">terminals.html</a>.</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h2 id="the-text-is-hard-to-see-not-bright-enough"><a name="toodark" href="#toc">The text is hard to see (not bright enough)!</a></h2>
|
<h2 id="the-text-is-hard-to-see-not-bright-enough"><a name="toodark" href="#toc">The text is hard to see (not bright enough)!</a></h2>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -419,7 +419,7 @@ example:</p>
|
|||||||
<p>is invalid input because octal only has digits 0 - 7: the resulting size will be
|
<p>is invalid input because octal only has digits 0 - 7: the resulting size will be
|
||||||
0.</p>
|
0.</p>
|
||||||
<p>I discuss the signed/unsigned issue to do with curses and sizes in C being
|
<p>I discuss the signed/unsigned issue to do with curses and sizes in C being
|
||||||
unsigned in <a href="bugs.html">bugs.html</a> (<a href="bugs.md">bugs.md</a> on GitHub) but probably there isn’t
|
unsigned in <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/bugs.html">bugs.html</a> but probably there isn’t
|
||||||
anything more to say here.</p>
|
anything more to say here.</p>
|
||||||
<h2 id="errors-and-error-reporting"><a name="errors" href="#toc">Errors and error reporting</a></h2>
|
<h2 id="errors-and-error-reporting"><a name="errors" href="#toc">Errors and error reporting</a></h2>
|
||||||
<p>If curses fails to initialise you should get an error that says ‘curses error’
|
<p>If curses fails to initialise you should get an error that says ‘curses error’
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ it as structured as possible/easiest to find.
|
|||||||
|
|
||||||
Because the score line is dynamic in length depending on the terminal size it
|
Because the score line is dynamic in length depending on the terminal size it
|
||||||
can happen that the score/status wraps to the next line(s). This can be fixed by
|
can happen that the score/status wraps to the next line(s). This can be fixed by
|
||||||
modifying the status line (see [HACKING.html][] or on GitHub [HACKING.md][]) but
|
modifying the status line (see [HACKING.html][] but
|
||||||
you shouldn't need it to be very wide.
|
you shouldn't need it to be very wide.
|
||||||
|
|
||||||
* RESOLUTION #0: Use a bigger screen (it doesn't take that many columns)
|
* RESOLUTION #0: Use a bigger screen (it doesn't take that many columns)
|
||||||
@@ -48,7 +48,7 @@ you shouldn't need it to be very wide.
|
|||||||
#define J Z(B:%zu\n), c);
|
#define J Z(B:%zu\n), c);
|
||||||
|
|
||||||
Recompile and try again. That will then show only the number of bugs eaten.
|
Recompile and try again. That will then show only the number of bugs eaten.
|
||||||
See the [HACKING.html][] ([HACKING.md][] on GitHub) file for other data you
|
See the [HACKING.html][] file for other data you
|
||||||
can include (though there are some discrepancies here and there as you'll
|
can include (though there are some discrepancies here and there as you'll
|
||||||
see).
|
see).
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ e.g. when the snake is growing.
|
|||||||
it'll catch up; just give it the time it needs.
|
it'll catch up; just give it the time it needs.
|
||||||
|
|
||||||
* BOTTOM LINE: If you want more information then see the [bugs.html][]
|
* BOTTOM LINE: If you want more information then see the [bugs.html][]
|
||||||
([bugs.md][] on GitHub) file.
|
file.
|
||||||
|
|
||||||
|
|
||||||
## <a name="invisiblehead" href="#toc">I can't see the snake head (or other part of the snake)!</a>
|
## <a name="invisiblehead" href="#toc">I can't see the snake head (or other part of the snake)!</a>
|
||||||
@@ -136,7 +136,7 @@ char (if it's an editor like vi/vim you will have to be sure to escape the char
|
|||||||
since `*` is a regexp metacharacter). This has happened to me numerous times.
|
since `*` is a regexp metacharacter). This has happened to me numerous times.
|
||||||
|
|
||||||
* RESOLUTION #3: If the colour contrast is not good for your eyes use the
|
* RESOLUTION #3: If the colour contrast is not good for your eyes use the
|
||||||
[snake-colours][] script to select a different colour scheme.
|
[snake-colours.sh][] script to select a different colour scheme.
|
||||||
|
|
||||||
|
|
||||||
## <a name="froze" href="#toc">The game froze!</a>
|
## <a name="froze" href="#toc">The game froze!</a>
|
||||||
@@ -288,10 +288,10 @@ so that's probably why; in CentOS I did have to install it specially.
|
|||||||
background white and the foreground black. This will of course mean you have
|
background white and the foreground black. This will of course mean you have
|
||||||
no colour but unfortunately changing the background colour of curses would
|
no colour but unfortunately changing the background colour of curses would
|
||||||
eat too many bytes in the entry (I cite the functions in the
|
eat too many bytes in the entry (I cite the functions in the
|
||||||
[HACKING.html][] ([HACKING.md][] on GitHub) file).
|
[HACKING.html][].
|
||||||
|
|
||||||
I discuss colours and terminals in much more detail in
|
I discuss colours and terminals in much more detail in
|
||||||
[terminals.html][] ([terminals.md][] on GitHub).
|
[terminals.html][].
|
||||||
|
|
||||||
|
|
||||||
## <a name="toodark" href="#toc">The text is hard to see (not bright enough)!</a>
|
## <a name="toodark" href="#toc">The text is hard to see (not bright enough)!</a>
|
||||||
@@ -395,7 +395,7 @@ is invalid input because octal only has digits 0 - 7: the resulting size will be
|
|||||||
|
|
||||||
|
|
||||||
I discuss the signed/unsigned issue to do with curses and sizes in C being
|
I discuss the signed/unsigned issue to do with curses and sizes in C being
|
||||||
unsigned in [bugs.html][] ([bugs.md][] on GitHub) but probably there isn't
|
unsigned in [bugs.html][] but probably there isn't
|
||||||
anything more to say here.
|
anything more to say here.
|
||||||
|
|
||||||
## <a name="errors" href="#toc">Errors and error reporting</a>
|
## <a name="errors" href="#toc">Errors and error reporting</a>
|
||||||
@@ -438,14 +438,11 @@ 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.
|
is 0 and I limit the size to be no bigger than the max size.
|
||||||
|
|
||||||
|
|
||||||
[HACKING.md]: HACKING.md
|
[HACKING.html]: %%REPO_URL%%/2020/ferguson1/HACKING.html
|
||||||
[HACKING.html]: HACKING.html
|
[prog.c]: %%REPO_URL%%/2020/ferguson1/prog.c
|
||||||
[prog.c]: prog.c
|
[bugs.html]: %%REPO_URL%%/2020/ferguson1/bugs.html
|
||||||
[bugs.md]: bugs.md
|
[terminals.html]: %%REPO_URL%%/2020/ferguson1/terminals.html
|
||||||
[bugs.html]: bugs.html
|
[snake-colours.sh]: %%REPO_URL%%/2020/ferguson1/snake-colours.sh
|
||||||
[terminals.md]: terminals.md
|
|
||||||
[terminals.html]: terminals.html
|
|
||||||
[snake-colours]: snake-colours
|
|
||||||
[Snakey]: https://www.hp-lexicon.org/character/gaunt-family/morfin-gaunt/
|
[Snakey]: https://www.hp-lexicon.org/character/gaunt-family/morfin-gaunt/
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+52
-21
@@ -139,7 +139,7 @@
|
|||||||
explore my <a href="https://www.cryptomuseum.com/crypto/enigma/index.htm">Enigma machine</a>
|
explore my <a href="https://www.cryptomuseum.com/crypto/enigma/index.htm">Enigma machine</a>
|
||||||
<a href="prog.c">simulator</a>. I really encourage you to do this but of course you don’t
|
<a href="prog.c">simulator</a>. I really encourage you to do this but of course you don’t
|
||||||
have to if you don’t wish to.</p>
|
have to if you don’t wish to.</p>
|
||||||
<p><a name="toc"></a></p>
|
<div id="toc">
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#recode">What is recode and why is it recommended?</a></li>
|
<li><a href="#recode">What is recode and why is it recommended?</a></li>
|
||||||
<li><a href="#options">Options</a>
|
<li><a href="#options">Options</a>
|
||||||
@@ -160,9 +160,12 @@ have to if you don’t wish to.</p>
|
|||||||
<li><a href="#exampleuses">Example uses</a></li>
|
<li><a href="#exampleuses">Example uses</a></li>
|
||||||
<li><a href="#fun">A fun way to explore my Enigma machine, with a surprise</a></li>
|
<li><a href="#fun">A fun way to explore my Enigma machine, with a surprise</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h1 id="what-is-recode-and-why-is-it-recommended"><a name="recode" href="#toc">What is recode and why is it recommended?</a></h1>
|
</div>
|
||||||
<p>To demonstrate how to and why you should use the <a href="recode.c">recode</a> program with
|
<div id="recode">
|
||||||
the <a href="prog.c">Enigma machine simulator</a> I have included some examples here as
|
<h1 id="what-is-recode-and-why-is-it-recommended"><a href="#toc">What is recode and why is it recommended?</a></h1>
|
||||||
|
</div>
|
||||||
|
<p>To demonstrate how to and why you should use the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/recode.c">recode.c</a> program with
|
||||||
|
the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/prog.c">Enigma machine simulator</a> I have included some examples here as
|
||||||
well as brief (‘brief?!’ I am sure many would think but it’s brief for me)
|
well as brief (‘brief?!’ I am sure many would think but it’s brief for me)
|
||||||
commentary.</p>
|
commentary.</p>
|
||||||
<p>It would not be possible to do all that the recode program does in my entry
|
<p>It would not be possible to do all that the recode program does in my entry
|
||||||
@@ -181,7 +184,7 @@ with the Roman numeral, showing their actual orders etc.), the reflectors
|
|||||||
(labelling them with B, C and showing the actual strings) etc.</p>
|
(labelling them with B, C and showing the actual strings) etc.</p>
|
||||||
<p>In this file I will show an example of each feature and then get to the
|
<p>In this file I will show an example of each feature and then get to the
|
||||||
wonderful ‘challenge’ for everyone.</p>
|
wonderful ‘challenge’ for everyone.</p>
|
||||||
<h1 id="options"><a name="options" href="#toc">Options</a></h1>
|
<h1 id="options"><a href="#toc">Options</a></h1>
|
||||||
<pre><code> ./recode -h
|
<pre><code> ./recode -h
|
||||||
usage: ./recode [options]
|
usage: ./recode [options]
|
||||||
-v display selected settings
|
-v display selected settings
|
||||||
@@ -234,8 +237,10 @@ Again note that this does not validate input! Although it detects out of range
|
|||||||
for the arrays it doesn’t detect duplicates. This is because it wasn’t meant to
|
for the arrays it doesn’t detect duplicates. This is because it wasn’t meant to
|
||||||
be any given file or anything else other than the direct output of a previous
|
be any given file or anything else other than the direct output of a previous
|
||||||
run (thus validated). I’m not even guaranteeing that I got the array tests valid
|
run (thus validated). I’m not even guaranteeing that I got the array tests valid
|
||||||
in <a href="recode.c">recode.c</a> <code>-R</code> option!</p>
|
in <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/recode.c">recode.c</a> <code>-R</code> option!</p>
|
||||||
<h2 id="protecting-against-the-same-io-file"><a name="samefile" href="#toc">Protecting against the same I/O file</a></h2>
|
<div id="samefile">
|
||||||
|
<h2 id="protecting-against-the-same-io-file"><a href="#toc">Protecting against the same I/O file</a></h2>
|
||||||
|
</div>
|
||||||
<p>Because some file systems are case-insensitive I have implemented a
|
<p>Because some file systems are case-insensitive I have implemented a
|
||||||
case-insensitive <code>strcmp()</code>; if the input file name is the same as the output file
|
case-insensitive <code>strcmp()</code>; if the input file name is the same as the output file
|
||||||
name I won’t write to it. From a quick test this is important particularly if
|
name I won’t write to it. From a quick test this is important particularly if
|
||||||
@@ -245,17 +250,23 @@ This might be overprotective but I believe it better to prevent user error where
|
|||||||
possible. Of course if neither file exists it might be argued that it’s not
|
possible. Of course if neither file exists it might be argued that it’s not
|
||||||
necessary to worry since you can’t read from a file that doesn’t exist. But then
|
necessary to worry since you can’t read from a file that doesn’t exist. But then
|
||||||
what about if one exists but the other does not?</p>
|
what about if one exists but the other does not?</p>
|
||||||
<h2 id="file-options-parser-limitation"><a name="fileoptions" href="#toc">File options parser limitation</a></h2>
|
<div id="fileoptions">
|
||||||
|
<h2 id="file-options-parser-limitation"><a href="#toc">File options parser limitation</a></h2>
|
||||||
|
</div>
|
||||||
<p>Due to the way the parsing of options is done (no spaces between option char and
|
<p>Due to the way the parsing of options is done (no spaces between option char and
|
||||||
argument) shell expansion will not work right so for example doing:</p>
|
argument) shell expansion will not work right so for example doing:</p>
|
||||||
<pre><code> $ ./recode -R~/config</code></pre>
|
<pre><code> $ ./recode -R~/config</code></pre>
|
||||||
<p>will <em>not</em> read the file ‘config’ in the home directory. I show another way to
|
<p>will <em>not</em> read the file ‘config’ in the home directory. I show another way to
|
||||||
achieve this later.</p>
|
achieve this later.</p>
|
||||||
<p>This limitation also applies to the <code>-f</code> and <code>-o</code> options!</p>
|
<p>This limitation also applies to the <code>-f</code> and <code>-o</code> options!</p>
|
||||||
<h2 id="r-option-validation"><a name="validation" href="#toc">-R option validation?</a></h2>
|
<div id="validation">
|
||||||
|
<h2 id="r-option-validation"><a href="#toc">-R option validation?</a></h2>
|
||||||
|
</div>
|
||||||
<p>Again the <code>-R</code> option does not validate input. For validation you have to run
|
<p>Again the <code>-R</code> option does not validate input. For validation you have to run
|
||||||
the program interactively.</p>
|
the program interactively.</p>
|
||||||
<h1 id="piping-commands-to-recode"><a name="pipingtorecode" href="#toc">Piping commands to recode</a></h1>
|
<div id="pipingtorecode">
|
||||||
|
<h1 id="piping-commands-to-recode"><a href="#toc">Piping commands to recode</a></h1>
|
||||||
|
</div>
|
||||||
<p>If stdin is not a tty (<code>!isatty(0)</code>) and neither randomised mode nor reading in
|
<p>If stdin is not a tty (<code>!isatty(0)</code>) and neither randomised mode nor reading in
|
||||||
from a file is specified then you might just see something like:</p>
|
from a file is specified then you might just see something like:</p>
|
||||||
<pre><code> $ echo testing test tests | ./recode
|
<pre><code> $ echo testing test tests | ./recode
|
||||||
@@ -272,7 +283,9 @@ from a file is specified then you might just see something like:</p>
|
|||||||
<p>In other words just the defaults. This was to simplify the problems with
|
<p>In other words just the defaults. This was to simplify the problems with
|
||||||
prompting again for input if it’s invalid (though as you’ll see it does a good
|
prompting again for input if it’s invalid (though as you’ll see it does a good
|
||||||
job at this anyway).</p>
|
job at this anyway).</p>
|
||||||
<h1 id="piping-recode-to-the-enigma-simulator"><a name="pipingtoenigma" href="#toc">Piping recode to the Enigma simulator</a></h1>
|
<div id="pipingtoenigma">
|
||||||
|
<h1 id="piping-recode-to-the-enigma-simulator"><a href="#toc">Piping recode to the Enigma simulator</a></h1>
|
||||||
|
</div>
|
||||||
<p>If you’re using recode to recode the input so you don’t have to type in the
|
<p>If you’re using recode to recode the input so you don’t have to type in the
|
||||||
input manually (if you randomise or read in from previously saved file no input
|
input manually (if you randomise or read in from previously saved file no input
|
||||||
need be done at all) then make sure to redirect stderr to /dev/null. If you
|
need be done at all) then make sure to redirect stderr to /dev/null. If you
|
||||||
@@ -285,7 +298,9 @@ redirected to <code>/dev/null</code> it prints this out; at this point however i
|
|||||||
input. Why or how it shows the first prompt instead of later on I do not know.
|
input. Why or how it shows the first prompt instead of later on I do not know.
|
||||||
Anyway at this point the simulator is already expecting input to en/decipher.
|
Anyway at this point the simulator is already expecting input to en/decipher.
|
||||||
That’s why after I sent EOF it printed out the remaining strings to stderr.</p>
|
That’s why after I sent EOF it printed out the remaining strings to stderr.</p>
|
||||||
<h1 id="manually-test-the-recode-program-with-the-enigma-program"><a name="manuallytest" href="#toc">Manually test the recode program with the Enigma program</a></h1>
|
<div id="manuallytest">
|
||||||
|
<h1 id="manually-test-the-recode-program-with-the-enigma-program"><a href="#toc">Manually test the recode program with the Enigma program</a></h1>
|
||||||
|
</div>
|
||||||
<pre><code> $ cat input
|
<pre><code> $ cat input
|
||||||
IOCCC
|
IOCCC
|
||||||
|
|
||||||
@@ -347,7 +362,9 @@ the same output:</p>
|
|||||||
<p>Also if you flip the order of the letters in the pair e.g. the AB as BA instead:</p>
|
<p>Also if you flip the order of the letters in the pair e.g. the AB as BA instead:</p>
|
||||||
<pre><code> $ echo 1AA2AA3AA2BA..CDEFGHIJKLMNOPQRIOCCC|./prog - 2>/dev/null
|
<pre><code> $ echo 1AA2AA3AA2BA..CDEFGHIJKLMNOPQRIOCCC|./prog - 2>/dev/null
|
||||||
HQNVO</code></pre>
|
HQNVO</code></pre>
|
||||||
<h1 id="only-write-config-file"><a name="onlyconfig" href="#toc">Only write config file</a></h1>
|
<div id="onlyconfig">
|
||||||
|
<h1 id="only-write-config-file"><a href="#toc">Only write config file</a></h1>
|
||||||
|
</div>
|
||||||
<pre><code> $ ./recode -v -oconfig -finput >/dev/null
|
<pre><code> $ ./recode -v -oconfig -finput >/dev/null
|
||||||
Rotors:
|
Rotors:
|
||||||
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
|
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
|
||||||
@@ -425,7 +442,9 @@ first one will print a newline with the echo but that won’t matter):</p>
|
|||||||
the buffer remains <code>NULL</code> and so I don’t print it but still do print the settings
|
the buffer remains <code>NULL</code> and so I don’t print it but still do print the settings
|
||||||
file. (Actually even if <code>getdelim()</code> fails you’re supposed to free the buffer so I
|
file. (Actually even if <code>getdelim()</code> fails you’re supposed to free the buffer so I
|
||||||
set another variable to indicate if it should be printed.)</p>
|
set another variable to indicate if it should be printed.)</p>
|
||||||
<h1 id="reusing-a-configuration"><a name="reuseconfig" href="#toc">Reusing a configuration</a></h1>
|
<div id="reuseconfig">
|
||||||
|
<h1 id="reusing-a-configuration"><a href="#toc">Reusing a configuration</a></h1>
|
||||||
|
</div>
|
||||||
<pre><code> $ echo -n|./recode -r -oconfig
|
<pre><code> $ echo -n|./recode -r -oconfig
|
||||||
4UH5II1RJ1SPIFEJLYGZWRTBHVCAMN$
|
4UH5II1RJ1SPIFEJLYGZWRTBHVCAMN$
|
||||||
|
|
||||||
@@ -450,7 +469,9 @@ set another variable to indicate if it should be printed.)</p>
|
|||||||
<pre><code> $ ./recode -finput.txt -Rconfig | ./prog - 2>/dev/null > output2
|
<pre><code> $ ./recode -finput.txt -Rconfig | ./prog - 2>/dev/null > output2
|
||||||
$ diff output output2
|
$ diff output output2
|
||||||
$</code></pre>
|
$</code></pre>
|
||||||
<h1 id="write-config-file-read-data-file-and-pass-to-enigma-simulator"><a name="passtoenigma" href="#toc">Write config file, read data file and pass to Enigma simulator</a></h1>
|
<div id="passtoenigma">
|
||||||
|
<h1 id="write-config-file-read-data-file-and-pass-to-enigma-simulator"><a href="#toc">Write config file, read data file and pass to Enigma simulator</a></h1>
|
||||||
|
</div>
|
||||||
<pre><code> $ ./recode -finput.txt -oconfig | ./prog - 2>/dev/null > output
|
<pre><code> $ ./recode -finput.txt -oconfig | ./prog - 2>/dev/null > output
|
||||||
Rotors:
|
Rotors:
|
||||||
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
|
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
|
||||||
@@ -501,7 +522,9 @@ does is the output:</p>
|
|||||||
This is a sentence.
|
This is a sentence.
|
||||||
|
|
||||||
This is another sentence.</code></pre>
|
This is another sentence.</code></pre>
|
||||||
<h1 id="piping-directly-to-the-enigma-code-once-with-randomised-settings-saved"><a name="directlytoenigma" href="#toc">Piping directly to the Enigma code once (with randomised settings, saved)</a></h1>
|
<div id="directlytoenigma">
|
||||||
|
<h1 id="piping-directly-to-the-enigma-code-once-with-randomised-settings-saved"><a href="#toc">Piping directly to the Enigma code once (with randomised settings, saved)</a></h1>
|
||||||
|
</div>
|
||||||
<p>This is like the above only randomised:</p>
|
<p>This is like the above only randomised:</p>
|
||||||
<pre><code> $ ./recode -r -oconfig|./prog - 2>/dev/null
|
<pre><code> $ ./recode -r -oconfig|./prog - 2>/dev/null
|
||||||
IOCCC
|
IOCCC
|
||||||
@@ -519,17 +542,23 @@ okay:</p>
|
|||||||
actual pasting to demonstrate:</p>
|
actual pasting to demonstrate:</p>
|
||||||
<pre><code> $ echo IOCCC | ./recode -R$(cat config) | ./prog - 2>/dev/null | ./recode -R2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ | ./prog - 2>/dev/null
|
<pre><code> $ echo IOCCC | ./recode -R$(cat config) | ./prog - 2>/dev/null | ./recode -R2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ | ./prog - 2>/dev/null
|
||||||
IOCCC</code></pre>
|
IOCCC</code></pre>
|
||||||
<h1 id="usage-conclusion"><a name="conclusion" href="#toc">Usage conclusion</a></h1>
|
<div id="conclusion">
|
||||||
|
<h1 id="usage-conclusion"><a href="#toc">Usage conclusion</a></h1>
|
||||||
|
</div>
|
||||||
<p>That should give you an idea of how to use the <code>recode</code> program. I leave it as
|
<p>That should give you an idea of how to use the <code>recode</code> program. I leave it as
|
||||||
an exercise to the reader to implement additional features but here are some
|
an exercise to the reader to implement additional features but here are some
|
||||||
ideas of what could be done and how this entry might be used (including that
|
ideas of what could be done and how this entry might be used (including that
|
||||||
delicious challenge).</p>
|
delicious challenge).</p>
|
||||||
<h1 id="example-additions"><a name="additions" href="#toc">Example additions</a></h1>
|
<div id="additions">
|
||||||
|
<h1 id="example-additions"><a href="#toc">Example additions</a></h1>
|
||||||
|
</div>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Add code (to <a href="prog.c">prog.c</a>) that tries to determine possible decipherments based on
|
<li>Add code (to <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/prog.c">prog.c</a>) that tries to determine possible decipherments based on
|
||||||
a given crib (or set of cribs).</li>
|
a given crib (or set of cribs).</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h1 id="example-uses"><a name="exampleuses" href="#toc">Example uses</a></h1>
|
<div id="exampleuses">
|
||||||
|
<h1 id="example-uses"><a href="#toc">Example uses</a></h1>
|
||||||
|
</div>
|
||||||
<ul>
|
<ul>
|
||||||
<li><p>Take an actual key sheet and message for that day and try and decipher the
|
<li><p>Take an actual key sheet and message for that day and try and decipher the
|
||||||
message (might help if you know German!). I haven’t actually done this for
|
message (might help if you know German!). I haven’t actually done this for
|
||||||
@@ -545,7 +574,9 @@ watching dry paint stay dry on a wall but why not poke fun at politicians
|
|||||||
anyway?</p></li>
|
anyway?</p></li>
|
||||||
<li><p>Best idea: try the below experiment!</p></li>
|
<li><p>Best idea: try the below experiment!</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h1 id="a-fun-way-to-explore-my-enigma-machine-with-a-surprise"><a name="fun" href="#toc">A fun way to explore my Enigma machine, with a surprise</a></h1>
|
<div id="fun">
|
||||||
|
<h1 id="a-fun-way-to-explore-my-enigma-machine-with-a-surprise"><a href="#toc">A fun way to explore my Enigma machine, with a surprise</a></h1>
|
||||||
|
</div>
|
||||||
<p>As I was making the above silly list something occurred to me. My <a href="https://www.ioccc.org/2020/ferguson1/index.html">other
|
<p>As I was making the above silly list something occurred to me. My <a href="https://www.ioccc.org/2020/ferguson1/index.html">other
|
||||||
entry</a> this year includes a
|
entry</a> this year includes a
|
||||||
<a href="https://www.ioccc.org/2020/ferguson1/chocolate-cake.html">recipe for a wonderful double-layered chocolate fudge
|
<a href="https://www.ioccc.org/2020/ferguson1/chocolate-cake.html">recipe for a wonderful double-layered chocolate fudge
|
||||||
|
|||||||
+59
-23
@@ -6,8 +6,7 @@ explore my [Enigma machine](https://www.cryptomuseum.com/crypto/enigma/index.htm
|
|||||||
have to if you don't wish to.
|
have to if you don't wish to.
|
||||||
|
|
||||||
|
|
||||||
<a name="toc"></a>
|
<div id="toc">
|
||||||
|
|
||||||
- [What is recode and why is it recommended?](#recode)
|
- [What is recode and why is it recommended?](#recode)
|
||||||
- [Options](#options)
|
- [Options](#options)
|
||||||
* [Protecting against the same I/O file](#samefile)
|
* [Protecting against the same I/O file](#samefile)
|
||||||
@@ -24,12 +23,15 @@ have to if you don't wish to.
|
|||||||
- [Example additions](#additions)
|
- [Example additions](#additions)
|
||||||
- [Example uses](#exampleuses)
|
- [Example uses](#exampleuses)
|
||||||
- [A fun way to explore my Enigma machine, with a surprise](#fun)
|
- [A fun way to explore my Enigma machine, with a surprise](#fun)
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
# <a name="recode" href="#toc">What is recode and why is it recommended?</a>
|
<div id="recode">
|
||||||
|
# <a href="#toc">What is recode and why is it recommended?</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
To demonstrate how to and why you should use the [recode](recode.c) program with
|
To demonstrate how to and why you should use the [recode.c](%%REPO_URL%%/2020/ferguson1/recode.c) program with
|
||||||
the [Enigma machine simulator](prog.c) I have included some examples here as
|
the [Enigma machine simulator](%%REPO_URL%%/2020/ferguson1/prog.c) I have included some examples here as
|
||||||
well as brief ('brief?!' I am sure many would think but it's brief for me)
|
well as brief ('brief?!' I am sure many would think but it's brief for me)
|
||||||
commentary.
|
commentary.
|
||||||
|
|
||||||
@@ -53,7 +55,10 @@ with the Roman numeral, showing their actual orders etc.), the reflectors
|
|||||||
In this file I will show an example of each feature and then get to the
|
In this file I will show an example of each feature and then get to the
|
||||||
wonderful 'challenge' for everyone.
|
wonderful 'challenge' for everyone.
|
||||||
|
|
||||||
# <a name="options" href="#toc">Options</a>
|
|
||||||
|
<div id="options">
|
||||||
|
# <a href="#toc">Options</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
./recode -h
|
./recode -h
|
||||||
@@ -123,10 +128,12 @@ Again note that this does not validate input! Although it detects out of range
|
|||||||
for the arrays it doesn't detect duplicates. This is because it wasn't meant to
|
for the arrays it doesn't detect duplicates. This is because it wasn't meant to
|
||||||
be any given file or anything else other than the direct output of a previous
|
be any given file or anything else other than the direct output of a previous
|
||||||
run (thus validated). I'm not even guaranteeing that I got the array tests valid
|
run (thus validated). I'm not even guaranteeing that I got the array tests valid
|
||||||
in [recode.c](recode.c) `-R` option!
|
in [recode.c](%%REPO_URL%%/2020/ferguson1/recode.c) `-R` option!
|
||||||
|
|
||||||
|
|
||||||
## <a name="samefile" href="#toc">Protecting against the same I/O file</a>
|
<div id="samefile">
|
||||||
|
## <a href="#toc">Protecting against the same I/O file</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
Because some file systems are case-insensitive I have implemented a
|
Because some file systems are case-insensitive I have implemented a
|
||||||
case-insensitive `strcmp()`; if the input file name is the same as the output file
|
case-insensitive `strcmp()`; if the input file name is the same as the output file
|
||||||
@@ -138,7 +145,10 @@ possible. Of course if neither file exists it might be argued that it's not
|
|||||||
necessary to worry since you can't read from a file that doesn't exist. But then
|
necessary to worry since you can't read from a file that doesn't exist. But then
|
||||||
what about if one exists but the other does not?
|
what about if one exists but the other does not?
|
||||||
|
|
||||||
## <a name="fileoptions" href="#toc">File options parser limitation</a>
|
|
||||||
|
<div id="fileoptions">
|
||||||
|
## <a href="#toc">File options parser limitation</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
Due to the way the parsing of options is done (no spaces between option char and
|
Due to the way the parsing of options is done (no spaces between option char and
|
||||||
argument) shell expansion will not work right so for example doing:
|
argument) shell expansion will not work right so for example doing:
|
||||||
@@ -153,12 +163,17 @@ achieve this later.
|
|||||||
This limitation also applies to the `-f` and `-o` options!
|
This limitation also applies to the `-f` and `-o` options!
|
||||||
|
|
||||||
|
|
||||||
## <a name="validation" href="#toc">-R option validation?</a>
|
<div id="validation">
|
||||||
|
## <a href="#toc">-R option validation?</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
Again the `-R` option does not validate input. For validation you have to run
|
Again the `-R` option does not validate input. For validation you have to run
|
||||||
the program interactively.
|
the program interactively.
|
||||||
|
|
||||||
# <a name="pipingtorecode" href="#toc">Piping commands to recode</a>
|
|
||||||
|
<div id="pipingtorecode">
|
||||||
|
# <a href="#toc">Piping commands to recode</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
If stdin is not a tty (`!isatty(0)`) and neither randomised mode nor reading in
|
If stdin is not a tty (`!isatty(0)`) and neither randomised mode nor reading in
|
||||||
from a file is specified then you might just see something like:
|
from a file is specified then you might just see something like:
|
||||||
@@ -182,7 +197,9 @@ prompting again for input if it's invalid (though as you'll see it does a good
|
|||||||
job at this anyway).
|
job at this anyway).
|
||||||
|
|
||||||
|
|
||||||
# <a name="pipingtoenigma" href="#toc">Piping recode to the Enigma simulator</a>
|
<div id="pipingtoenigma">
|
||||||
|
# <a href="#toc">Piping recode to the Enigma simulator</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
If you're using recode to recode the input so you don't have to type in the
|
If you're using recode to recode the input so you don't have to type in the
|
||||||
input manually (if you randomise or read in from previously saved file no input
|
input manually (if you randomise or read in from previously saved file no input
|
||||||
@@ -202,8 +219,9 @@ Anyway at this point the simulator is already expecting input to en/decipher.
|
|||||||
That's why after I sent EOF it printed out the remaining strings to stderr.
|
That's why after I sent EOF it printed out the remaining strings to stderr.
|
||||||
|
|
||||||
|
|
||||||
|
<div id="manuallytest">
|
||||||
# <a name="manuallytest" href="#toc">Manually test the recode program with the Enigma program</a>
|
# <a href="#toc">Manually test the recode program with the Enigma program</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
$ cat input
|
$ cat input
|
||||||
@@ -285,7 +303,9 @@ Also if you flip the order of the letters in the pair e.g. the AB as BA instead:
|
|||||||
HQNVO
|
HQNVO
|
||||||
```
|
```
|
||||||
|
|
||||||
# <a name="onlyconfig" href="#toc">Only write config file</a>
|
<div id="onlyconfig">
|
||||||
|
# <a href="#toc">Only write config file</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
$ ./recode -v -oconfig -finput >/dev/null
|
$ ./recode -v -oconfig -finput >/dev/null
|
||||||
@@ -378,7 +398,9 @@ the buffer remains `NULL` and so I don't print it but still do print the setting
|
|||||||
file. (Actually even if `getdelim()` fails you're supposed to free the buffer so I
|
file. (Actually even if `getdelim()` fails you're supposed to free the buffer so I
|
||||||
set another variable to indicate if it should be printed.)
|
set another variable to indicate if it should be printed.)
|
||||||
|
|
||||||
# <a name="reuseconfig" href="#toc">Reusing a configuration</a>
|
<div id="reuseconfig">
|
||||||
|
# <a href="#toc">Reusing a configuration</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
$ echo -n|./recode -r -oconfig
|
$ echo -n|./recode -r -oconfig
|
||||||
@@ -412,7 +434,9 @@ Alternatively you can just use the `-R` and `-f` options:
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
# <a name="passtoenigma" href="#toc">Write config file, read data file and pass to Enigma simulator</a>
|
<div id="passtoenigma">
|
||||||
|
# <a href="#toc">Write config file, read data file and pass to Enigma simulator</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
```
|
```
|
||||||
$ ./recode -finput.txt -oconfig | ./prog - 2>/dev/null > output
|
$ ./recode -finput.txt -oconfig | ./prog - 2>/dev/null > output
|
||||||
@@ -473,7 +497,9 @@ does is the output:
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
# <a name="directlytoenigma" href="#toc">Piping directly to the Enigma code once (with randomised settings, saved)</a>
|
<div id="directlytoenigma">
|
||||||
|
# <a href="#toc">Piping directly to the Enigma code once (with randomised settings, saved)</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
This is like the above only randomised:
|
This is like the above only randomised:
|
||||||
|
|
||||||
@@ -510,19 +536,27 @@ actual pasting to demonstrate:
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
# <a name="conclusion" href="#toc">Usage conclusion</a>
|
<div id="conclusion">
|
||||||
|
# <a href="#toc">Usage conclusion</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
That should give you an idea of how to use the `recode` program. I leave it as
|
That should give you an idea of how to use the `recode` program. I leave it as
|
||||||
an exercise to the reader to implement additional features but here are some
|
an exercise to the reader to implement additional features but here are some
|
||||||
ideas of what could be done and how this entry might be used (including that
|
ideas of what could be done and how this entry might be used (including that
|
||||||
delicious challenge).
|
delicious challenge).
|
||||||
|
|
||||||
# <a name="additions" href="#toc">Example additions</a>
|
|
||||||
|
|
||||||
* Add code (to [prog.c](prog.c)) that tries to determine possible decipherments based on
|
<div id="additions">
|
||||||
|
# <a href="#toc">Example additions</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
* Add code (to [prog.c](%%REPO_URL%%/2020/ferguson1/prog.c)) that tries to determine possible decipherments based on
|
||||||
a given crib (or set of cribs).
|
a given crib (or set of cribs).
|
||||||
|
|
||||||
# <a name="exampleuses" href="#toc">Example uses</a>
|
|
||||||
|
<div id="exampleuses">
|
||||||
|
# <a href="#toc">Example uses</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
* Take an actual key sheet and message for that day and try and decipher the
|
* Take an actual key sheet and message for that day and try and decipher the
|
||||||
message (might help if you know German!). I haven't actually done this for
|
message (might help if you know German!). I haven't actually done this for
|
||||||
@@ -541,7 +575,9 @@ anyway?
|
|||||||
* Best idea: try the below experiment!
|
* Best idea: try the below experiment!
|
||||||
|
|
||||||
|
|
||||||
# <a name="fun" href="#toc">A fun way to explore my Enigma machine, with a surprise</a>
|
<div id="fun">
|
||||||
|
# <a href="#toc">A fun way to explore my Enigma machine, with a surprise</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
As I was making the above silly list something occurred to me. My [other
|
As I was making the above silly list something occurred to me. My [other
|
||||||
entry](https://www.ioccc.org/2020/ferguson1/index.html) this year includes a
|
entry](https://www.ioccc.org/2020/ferguson1/index.html) this year includes a
|
||||||
|
|||||||
Reference in new issue
Block a user