build missing HTML files for entries

Setup a simple topnav for missing HTML files for entries.

Added `bin/gen-other-html.sh` to build entry HTML files from
markdown other than README.md to index.html HTML files.

Fixed duplicate link text in `2020/ferguson1/gameplay.md`.

Improved `inc/md2html.cfg` to support building the missing HTML
files for entries.

Added `make gen_other_html` to top level Makefile.
Added `make gen_other_html` to `make quick_www` and `make www`.

Fixed inventory links for year level index.html files.
Changed `bin/output-year-index.sh` VERSION from "1.0.1 2024-02-23"
to "1.1 2024-02-27".

Added missing lines in `manifest.numbers`.  Update the affected
`.entry.json` files.

The manifest (in both `manifest.numbers` and the collection of
manifests from of all entry `.entry.json` files) now match.  Errors
from `make verify_entry_files` will now abort both `make quick_www`
and `make www` rules in the top level `Makefile`.

Changed markdown files in manifest to have an _inventory_order_ of
_2000000000_ so that the `index.html` file will usually appear at
the start of the _Secondary files_ set for the "#inventory" section
of an entry's `index.html` file.

Changed compressed tar files (files that end in _.tar.bz2_) in
manifest to have an _inventory_order_ of _100000_ so that these
files will usually appear at the end of the _Primary files_ set for
the "#inventory" section of an entry's `index.html` file.

Added 'Jump to top` link above the _Primary files_ section.
Changed `bin/output-index-inventory.sh` VERSION from "1.1.1 2024-02-23"
to "1.2 2024-02-27".

Updated HTML files to perform the above via `make www`.
This commit is contained in:
Landon Curt Noll committed 2024-02-27 22:36:20 -08:00
1 parent 7babf792e4
commit 9d3438fb88
718 files changed
+17515 -4084

No files matched your search

+8 -8
View File
@@ -9,14 +9,6 @@
{ "author_handle" : "Dave_Burton" }
],
"manifest" : [
{
"file_path" : "index.html",
"inventory_order" : 10,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : "prog.c",
"inventory_order" : 20,
@@ -81,6 +73,14 @@
"display_via_github" : false,
"entry_text" : "download entry source"
},
{
"file_path" : "index.html",
"inventory_order" : 2000000000,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : ".entry.json",
"inventory_order" : 4294967295,
+2 -1
View File
@@ -206,9 +206,9 @@ https://creativecommons.org/licenses/by-sa/4.0/</p>
<h1 id="inventory-for-2020burton"><a name="inventory"></a>Inventory for
2020/burton</h1>
<p><a href="#top">Jump to top</a></p>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/burton/prog.c">prog.c</a>
- entry source</li>
@@ -235,6 +235,7 @@ entry source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/burton/.entry.json">.entry.json</a>
- description of entry in JSON</li>
+8 -8
View File
@@ -9,14 +9,6 @@
{ "author_handle" : "Nicholas_Carlini" }
],
"manifest" : [
{
"file_path" : "index.html",
"inventory_order" : 10,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : "prog.c",
"inventory_order" : 20,
@@ -57,6 +49,14 @@
"display_via_github" : false,
"entry_text" : "download entry source"
},
{
"file_path" : "index.html",
"inventory_order" : 2000000000,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : ".entry.json",
"inventory_order" : 4294967295,
+2 -1
View File
@@ -359,9 +359,9 @@ https://creativecommons.org/licenses/by-sa/4.0/</p>
<h1 id="inventory-for-2020carlini"><a name="inventory"></a>Inventory for
2020/carlini</h1>
<p><a href="#top">Jump to top</a></p>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/carlini/prog.c">prog.c</a>
- entry source</li>
@@ -379,6 +379,7 @@ entry source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/carlini/.entry.json">.entry.json</a>
- description of entry in JSON</li>
+8 -8
View File
@@ -9,14 +9,6 @@
{ "author_handle" : "Yusuke_Endoh" }
],
"manifest" : [
{
"file_path" : "index.html",
"inventory_order" : 10,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : "prog.c",
"inventory_order" : 20,
@@ -113,6 +105,14 @@
"display_via_github" : false,
"entry_text" : "download entry source"
},
{
"file_path" : "index.html",
"inventory_order" : 2000000000,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : ".entry.json",
"inventory_order" : 4294967295,
+2 -1
View File
@@ -292,9 +292,9 @@ https://creativecommons.org/licenses/by-sa/4.0/</p>
<h1 id="inventory-for-2020endoh1"><a name="inventory"></a>Inventory for
2020/endoh1</h1>
<p><a href="#top">Jump to top</a></p>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh1/prog.c">prog.c</a>
- entry source</li>
@@ -333,6 +333,7 @@ entry source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh1/.entry.json">.entry.json</a>
- description of entry in JSON</li>
+19 -11
View File
@@ -9,14 +9,6 @@
{ "author_handle" : "Yusuke_Endoh" }
],
"manifest" : [
{
"file_path" : "index.html",
"inventory_order" : 10,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : "prog.c",
"inventory_order" : 20,
@@ -106,11 +98,11 @@
"entry_text" : "SPOILER WARNING - generated source"
},
{
"file_path" : "spoiler/spoiler.md",
"file_path" : "spoiler/spoiler.html",
"inventory_order" : 200,
"OK_to_edit" : true,
"display_as" : "markdown",
"display_via_github" : true,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "SPOILER WARNING - about the spoiler"
},
{
@@ -129,6 +121,14 @@
"display_via_github" : false,
"entry_text" : "download entry source"
},
{
"file_path" : "index.html",
"inventory_order" : 2000000000,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : ".entry.json",
"inventory_order" : 4294967295,
@@ -160,6 +160,14 @@
"display_as" : "markdown",
"display_via_github" : true,
"entry_text" : "markdown source for index.html"
},
{
"file_path" : "spoiler/spoiler.md",
"inventory_order" : 4294967295,
"OK_to_edit" : true,
"display_as" : "markdown",
"display_via_github" : true,
"entry_text" : "markdown source for spoiler/spoiler.html"
}
]
}
+7 -4
View File
@@ -168,9 +168,9 @@ https://creativecommons.org/licenses/by-sa/4.0/</p>
<h1 id="inventory-for-2020endoh2"><a name="inventory"></a>Inventory for
2020/endoh2</h1>
<p><a href="#top">Jump to top</a></p>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/prog.c">prog.c</a>
- entry source</li>
@@ -204,9 +204,8 @@ href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/spoil
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/spoiler/prog.c">spoiler/prog.c</a>
- SPOILER WARNING - generated source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/spoiler/spoiler.md">spoiler/spoiler.md</a>
- SPOILER WARNING - about the spoiler</li>
<li><a href="spoiler/spoiler.html">spoiler/spoiler.html</a> - SPOILER
WARNING - about the spoiler</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/spoiler/tmpl.txt">spoiler/tmpl.txt</a>
- SPOILER WARNING - template for the program</li>
@@ -215,6 +214,7 @@ entry source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/.entry.json">.entry.json</a>
- description of entry in JSON</li>
@@ -225,6 +225,9 @@ href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/.giti
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/README.md">README.md</a>
- markdown source for index.html</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/spoiler/spoiler.md">spoiler/spoiler.md</a>
- markdown source for spoiler/spoiler.html</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
+160
View File
@@ -0,0 +1,160 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- -->
<!-- The original markdown content was formed by the tool: bin/gen-other-html.sh -->
<!-- The HTML was converted from markdown by the tool: bin/md2html.sh -->
<!-- -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../../ioccc.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>The International Obfuscated C Code Contest</title>
<meta name="description" content="spoiler.md for 2020/endoh2">
<meta name="keywords" content="IOCCC, 2020/endoh2, spoiler.md">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<img src="../../../png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
<h1>The International Obfuscated C Code Contest</h1>
<h2>spoiler.md for 2020/endoh2</h2>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.up2index.html -->
<div class="topnav">
<a class="Left" href="../index.html">&uarr; jump to index.html &uarr;</a>
</div>
<!-- END: this line ends content from: inc/topnav.up2index.html -->
<!-- START: this line starts content from: inc/begin-row.default.html -->
<div class="row">
<!-- END: this line ends content from: inc/begin-row.default.html -->
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
<div class="leftcolumn">
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/sidenav.default.html -->
<div class="sidenav">
<a href="#content">Jump to contents</a>
</div>
<hr>
<div class="sidenav">
<a href="../../../index.html">IOCCC Home</a>
<a href="../../../years.html">Winning Entries</a>
<a href="../../../authors.html">People who have won</a>
</div>
<hr>
<div class="sidenav">
<a href="../../../news.html">IOCCC News</a>
<a href="../../../faq.html#submit">How to enter the IOCCC</a>
<a href="../../../faq.html">FAQ</a>
</div>
<hr>
<div class="sidenav">
<a href="../../../bugs.html">Bugs &amp; (mis)features</a>
<a href="../../../faq.html#fix_an_entry">Fixing IOCCC entries</a>
<a href="../../../faq.html#fix_web_site">Fixing the web site</a>
<a href="../../../faq.html#fix_author">Fixing author info</a>
<a href="../../../thanks-for-help.html">Thanks for the help</a>
</div>
<hr>
<div class="sidenav">
<a href="../../../judges.html">The IOCCC Judges</a>
<a href="../../../contact.html">Contacting the IOCCC</a>
</div>
<hr>
<div class="sidenav">
<a href="#top">Jump to top</a>
</div>
<!-- END: this line ends content from: inc/sidenav.default.html -->
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
<div class="rightcolumn">
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<a name="content"></a>
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h1 id="opening-crawl-rot13-decoder">Opening crawl ROT13 decoder</h1>
<p>The program contains dedicated font data for all uppercase alphabet
letters.</p>
<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>
<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 for font data and something.</p>
<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 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>
<p><a href="tmpl.txt">tmpl.txt</a> is a template for the program. <a
href="gen.rb">gen.rb</a> composes the all items and generates <a
href="prog.c">prog.c</a>.</p>
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/end-row.default.html -->
</div>
<!-- END: this line ends content from: inc/end-row.default.html -->
<!-- START: this line starts content from: inc/footer.default.html -->
<div class="footer">
<hr>
<h2>Coda</h2>
<p><a href="https://validator.w3.org/nu/?doc=#">Nu HTML check this web page</a></p>
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
</div>
<!-- END: this line ends content from: inc/footer.default.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->
+8 -8
View File
@@ -9,14 +9,6 @@
{ "author_handle" : "Yusuke_Endoh" }
],
"manifest" : [
{
"file_path" : "index.html",
"inventory_order" : 10,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : "prog.c",
"inventory_order" : 20,
@@ -73,6 +65,14 @@
"display_via_github" : false,
"entry_text" : "download entry source"
},
{
"file_path" : "index.html",
"inventory_order" : 2000000000,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : ".entry.json",
"inventory_order" : 4294967295,
+2 -1
View File
@@ -172,9 +172,9 @@ https://creativecommons.org/licenses/by-sa/4.0/</p>
<h1 id="inventory-for-2020endoh3"><a name="inventory"></a>Inventory for
2020/endoh3</h1>
<p><a href="#top">Jump to top</a></p>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh3/prog.c">prog.c</a>
- entry source</li>
@@ -198,6 +198,7 @@ entry source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh3/.entry.json">.entry.json</a>
- description of entry in JSON</li>
+59 -11
View File
@@ -9,14 +9,6 @@
{ "author_handle" : "Cody_Boone_Ferguson" }
],
"manifest" : [
{
"file_path" : "index.html",
"inventory_order" : 10,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : "prog.c",
"inventory_order" : 20,
@@ -65,6 +57,14 @@
"display_via_github" : false,
"entry_text" : "information for herpetologist hackers"
},
{
"file_path" : "bugs.html",
"inventory_order" : 100,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "current bugs and things that look like bugs but are not"
},
{
"file_path" : "cannibalism.log.html",
"inventory_order" : 100,
@@ -73,6 +73,14 @@
"display_via_github" : false,
"entry_text" : "about the snake game"
},
{
"file_path" : "chocolate-cake.html",
"inventory_order" : 100,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "double-layered chocolate fudge cake recipe"
},
{
"file_path" : "crazy.log.html",
"inventory_order" : 100,
@@ -81,6 +89,14 @@
"display_via_github" : false,
"entry_text" : "about some screen dumps"
},
{
"file_path" : "gameplay.html",
"inventory_order" : 100,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "how to play the game"
},
{
"file_path" : "play.sh",
"inventory_order" : 100,
@@ -97,6 +113,30 @@
"display_via_github" : true,
"entry_text" : "script to reset - preset colors"
},
{
"file_path" : "spoilers.html",
"inventory_order" : 100,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "SPOILER ALERT - about the code"
},
{
"file_path" : "terminals.html",
"inventory_order" : 100,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "terminal capabilities and dimensions and colors"
},
{
"file_path" : "troubleshooting.html",
"inventory_order" : 100,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "troubleshooting the game"
},
{
"file_path" : "prog.2.c",
"inventory_order" : 150,
@@ -145,6 +185,14 @@
"display_via_github" : false,
"entry_text" : "download entry source"
},
{
"file_path" : "index.html",
"inventory_order" : 2000000000,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : ".entry.json",
"inventory_order" : 4294967295,
@@ -175,7 +223,7 @@
"OK_to_edit" : true,
"display_as" : "markdown",
"display_via_github" : true,
"entry_text" : "markdown source for crazy.log.html"
"entry_text" : "markdown source for COMPILING.html"
},
{
"file_path" : "HACKING.md",
@@ -215,7 +263,7 @@
"OK_to_edit" : true,
"display_as" : "markdown",
"display_via_github" : true,
"entry_text" : "markdown source for chocolate-cake.html"
"entry_text" : "markdown source for cannibalism.log.html"
},
{
"file_path" : "chocolate-cake.md",
@@ -231,7 +279,7 @@
"OK_to_edit" : true,
"display_as" : "markdown",
"display_via_github" : true,
"entry_text" : "markdown source for deckmyn.html"
"entry_text" : "markdown source for crazy.log.html"
},
{
"file_path" : "gameplay.md",
+215
View File
@@ -0,0 +1,215 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- -->
<!-- The original markdown content was formed by the tool: bin/gen-other-html.sh -->
<!-- The HTML was converted from markdown by the tool: bin/md2html.sh -->
<!-- -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>The International Obfuscated C Code Contest</title>
<meta name="description" content="COMPILING.md for 2020/ferguson1">
<meta name="keywords" content="IOCCC, 2020/ferguson1, COMPILING.md">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<img src="../../png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
<h1>The International Obfuscated C Code Contest</h1>
<h2>COMPILING.md for 2020/ferguson1</h2>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.up2index.html -->
<div class="topnav">
<a class="Left" href="index.html">&uarr; jump to index.html &uarr;</a>
</div>
<!-- END: this line ends content from: inc/topnav.up2index.html -->
<!-- START: this line starts content from: inc/begin-row.default.html -->
<div class="row">
<!-- END: this line ends content from: inc/begin-row.default.html -->
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
<div class="leftcolumn">
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/sidenav.default.html -->
<div class="sidenav">
<a href="#content">Jump to contents</a>
</div>
<hr>
<div class="sidenav">
<a href="../../index.html">IOCCC Home</a>
<a href="../../years.html">Winning Entries</a>
<a href="../../authors.html">People who have won</a>
</div>
<hr>
<div class="sidenav">
<a href="../../news.html">IOCCC News</a>
<a href="../../faq.html#submit">How to enter the IOCCC</a>
<a href="../../faq.html">FAQ</a>
</div>
<hr>
<div class="sidenav">
<a href="../../bugs.html">Bugs &amp; (mis)features</a>
<a href="../../faq.html#fix_an_entry">Fixing IOCCC entries</a>
<a href="../../faq.html#fix_web_site">Fixing the web site</a>
<a href="../../faq.html#fix_author">Fixing author info</a>
<a href="../../thanks-for-help.html">Thanks for the help</a>
</div>
<hr>
<div class="sidenav">
<a href="../../judges.html">The IOCCC Judges</a>
<a href="../../contact.html">Contacting the IOCCC</a>
</div>
<hr>
<div class="sidenav">
<a href="#top">Jump to top</a>
</div>
<!-- END: this line ends content from: inc/sidenav.default.html -->
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
<div class="rightcolumn">
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<a name="content"></a>
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<p>In order to successfully compile this you will need a C compiler that
supports 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 that has the header files etc. If you use the
Makefile obviously you need <code>make</code> too.</p>
<p>In <a href="gameplay.md">gameplay.md</a> I show how to easily
customise the colours, set up different gameplay modes and various other
things. The troubleshooting.md and terminals.md as well as bugs.md
include a variety of information should you run into trouble.</p>
<p>–</p>
<h1 id="portability">Portability</h1>
<p>I have tested this under macOS Catalina, macOS Ventura (and probably
between the two), Fedora (29 and also 31 - no that’s not a typo, I
upgraded from 29 to 31 as I had delayed upgrading to 30 due to a number
of issues and being busy) and CentOS 7.7.1908. It should work under any
modern linux system and maybe other Unices as well as macOS (as
noted).</p>
<p>It obviously requires ncurses but other than that nothing extra
should be needed. Note that the testing of Fedora 29 was earlier in the
development however (but then 29 is also EOL).</p>
<p>Furthermore I do not believe - but I cannot confirm either - that
endianness matters; I only have Intel CPUs and arm64 (MacBook Pro
M1).</p>
<p>I imagine that it works for 32-bit systems but I do not know for
sure.</p>
<h1 id="portability-macos">Portability: macOS</h1>
<p>You should be able to get the compiler with:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> xcode-select <span class="at">--install</span></span></code></pre></div>
<p>You don’t need Xcode itself and it appears that the command line
tools (as above should install) already has ncurses so there shouldn’t
be anything else that needs to be done. But I’m not actually sure of
this - I’m seeing conflicting information and it’s been too long; anyway
there’s always <a href="https://www.macports.org">MacPorts</a> and also
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 so that you don’t need sudo because … Well
never mind.</p>
<h1 id="portability-fedora">Portability: Fedora</h1>
<p>You’ll need the packages <code>gcc</code>, <code>ncurses</code> and
<code>ncurses-devel</code> (plus <code>make</code> if you want to use
the Makefile) to compile and link this entry. With Fedora more recent
versions there’s the <code>dnf</code> package manager but I cannot help
with any of the GUI installers since I don’t use them. Something
like:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> dnf install ncurses-devel ncurses make gcc</span></code></pre></div>
<p>or</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># dnf install ncurses-devel ncurses make gcc</span></span></code></pre></div>
<h1 id="portability-centos">Portability: CentOS</h1>
<p>Just like Fedora you will need <code>gcc</code>,
<code>ncurses</code>, <code>ncurses-devel</code> (and if you want to use
the Makefile <code>make</code>). CentOS uses <code>yum</code> and CentOS
8 uses <code>dnf</code>. So:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> yum install ncurses-devel ncurses make gcc</span></code></pre></div>
<p>or</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="co"># yum install ncurses-devel ncurses make gcc</span></span></code></pre></div>
<p>or</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> dnf install ncurses-devel ncurses make gcc</span></code></pre></div>
<p>or</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="co"># dnf install ncurses-devel ncurses make gcc</span></span></code></pre></div>
<p>You can also use clang to compile (which is what gcc actually is
under macOS).</p>
<h1 id="compilation-notes">Compilation notes</h1>
<p>As long as you have the dependencies above the only thing that comes
to mind is integer width problems.</p>
<p>If <code>size_t</code> does not equate to unsigned long: In this case
if say it’s an unsigned long long then theoretically you should be able
to change the <code>strtoul()</code> to be <code>strtoull()</code>
(after updating the typedef for unsigned long to be unsigned long long
maybe?). It appears to work from a quick test at least.</p>
<p>If it’s an unsigned int I believe you will have to opt for an
unsigned long (so <code>strtoul()</code> cast to an unsigned int).</p>
<p>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).</p>
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/end-row.default.html -->
</div>
<!-- END: this line ends content from: inc/end-row.default.html -->
<!-- START: this line starts content from: inc/footer.default.html -->
<div class="footer">
<hr>
<h2>Coda</h2>
<p><a href="https://validator.w3.org/nu/?doc=#">Nu HTML check this web page</a></p>
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
</div>
<!-- END: this line ends content from: inc/footer.default.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->
+561
View File
@@ -0,0 +1,561 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- -->
<!-- The original markdown content was formed by the tool: bin/gen-other-html.sh -->
<!-- The HTML was converted from markdown by the tool: bin/md2html.sh -->
<!-- -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>The International Obfuscated C Code Contest</title>
<meta name="description" content="HACKING.md for 2020/ferguson1">
<meta name="keywords" content="IOCCC, 2020/ferguson1, HACKING.md">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<img src="../../png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
<h1>The International Obfuscated C Code Contest</h1>
<h2>HACKING.md for 2020/ferguson1</h2>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.up2index.html -->
<div class="topnav">
<a class="Left" href="index.html">&uarr; jump to index.html &uarr;</a>
</div>
<!-- END: this line ends content from: inc/topnav.up2index.html -->
<!-- START: this line starts content from: inc/begin-row.default.html -->
<div class="row">
<!-- END: this line ends content from: inc/begin-row.default.html -->
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
<div class="leftcolumn">
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/sidenav.default.html -->
<div class="sidenav">
<a href="#content">Jump to contents</a>
</div>
<hr>
<div class="sidenav">
<a href="../../index.html">IOCCC Home</a>
<a href="../../years.html">Winning Entries</a>
<a href="../../authors.html">People who have won</a>
</div>
<hr>
<div class="sidenav">
<a href="../../news.html">IOCCC News</a>
<a href="../../faq.html#submit">How to enter the IOCCC</a>
<a href="../../faq.html">FAQ</a>
</div>
<hr>
<div class="sidenav">
<a href="../../bugs.html">Bugs &amp; (mis)features</a>
<a href="../../faq.html#fix_an_entry">Fixing IOCCC entries</a>
<a href="../../faq.html#fix_web_site">Fixing the web site</a>
<a href="../../faq.html#fix_author">Fixing author info</a>
<a href="../../thanks-for-help.html">Thanks for the help</a>
</div>
<hr>
<div class="sidenav">
<a href="../../judges.html">The IOCCC Judges</a>
<a href="../../contact.html">Contacting the IOCCC</a>
</div>
<hr>
<div class="sidenav">
<a href="#top">Jump to top</a>
</div>
<!-- END: this line ends content from: inc/sidenav.default.html -->
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
<div class="rightcolumn">
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<a name="content"></a>
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h1 id="about-this-document">About this document</h1>
<p>In this document I provide information to the herpetologist hackers
to help them modify certain things and add features for their studying
of snakes. Or if you prefer you can be the snake studying the
herpetologist. Whichever character you prefer to play doesn’t really
matter.</p>
<h1 id="warning-caveat-about-this-document">Warning / caveat about this
document</h1>
<p>WARNING: There are some things cited in this document that are no
longer correct, might be misleading or otherwise not clear. This is both
intentional and unintentional. This is especially true for claims that
something means something specific. Put another way just because the
table says something doesn’t mean it’s the whole truth: no misleading
comments but misleading document that talks about some parts of the
code!</p>
<p>Please do not assume that just because something is in this file
means that it’s complete or will work without any changes (see above).
As I have changed the game over development stages some features have
been dramatically changed and some of these ideas could be incompatible
now or otherwise impractical. Also you might find in fact that some of
these leave more questions than answers (e.g. some require making
decisions for specific problems one might encounter)!</p>
<p>With that said here’s the C sibilancy (the herpetologist programmer’s
and snake’s syllabary) for all snake and herpetologist programmers
alike.</p>
<h1 id="modifying-and-adding-additional-features-to-the-code">Modifying
and adding additional features to the code</h1>
<ul>
<li><p>Modifications</p>
<ul>
<li><p>Modifying the colours</p></li>
<li><p>Background colour</p></li>
<li><p>Modifying the characters for the wall, bug and snake</p></li>
<li><p>Modifying input keys</p></li>
<li><p>Modifying the status/score line</p></li>
<li><p>Make it so the snake starts at a random location</p></li>
</ul></li>
<li><p>Additions</p>
<ul>
<li><p>Health (and/or Lives)</p></li>
<li><p>Saving the game</p></li>
<li><p>Different types of walls</p></li>
<li><p>Blockades</p></li>
<li><p>Diagonal movement</p></li>
<li><p>Special abilities</p></li>
<li><p>Obstacles</p></li>
<li><p>More than one bug</p></li>
<li><p>Power-ups</p></li>
<li><p>Snakeskin shedding (becoming an obstacle)</p></li>
<li><p>Snake moves faster over time</p></li>
<li><p>Max times the bug evades before game over</p></li>
</ul></li>
</ul>
<h1 id="modifications">Modifications</h1>
<p>Here I include information on modifying the game in various ways
depending on the preference of the herpetologist (or if you prefer you
can be the snake studying the herpetologist).</p>
<h2 id="modifying-the-colours">Modifying the colours</h2>
<p>As I already said I provided a script that prompts you for colours
and then compiles the game with those colours (default if invalid
input).</p>
<p>The parts of the game that are coloured are the WALL(s), the snake
HEAD and snake BODY. In the published alternate version (prog.alt.c) the
bug is also colourable. This means that there are a total of four
configurable colour pairs. It only supports the eight standard colours.
Each colour is a pair: foreground and background.</p>
<p>To change the colours use the snake-colours.sh or play.sh scripts.
Hit enter for defaults if you don’t want to change the colour.</p>
<h2 id="background-colour-of-the-game-field">Background colour of the
game field</h2>
<p>I prefer black backgrounds but this is the basic idea behind changing
it. You initialise a pair (make it 5 so as to not interfere with the
script customisability) and then you use the bkgd() function with the
colour pair. Something like this:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>init_pair<span class="op">(</span><span class="dv">5</span><span class="op">,</span> COLOR_BLACK<span class="op">,</span> COLOR_WHITE<span class="op">);</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>bkgd<span class="op">(</span>COLOR_PAIR<span class="op">(</span><span class="dv">5</span><span class="op">));</span></span></code></pre></div>
<p>I played with this after winning and I came across some problems with
colours but that changes the background of the program anyway.</p>
<p>The standard colour identifiers are:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>COLOR_BLACK</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>COLOR_RED</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>COLOR_GREEN</span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>COLOR_YELLOW</span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a>COLOR_BLUE</span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a>COLOR_MAGENTA</span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a>COLOR_CYAN</span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a>COLOR_WHITE</span></code></pre></div>
<p>See Linux Journal for more information article <a
href="https://www.linuxjournal.com/content/programming-color-ncurses"
class="uri">https://www.linuxjournal.com/content/programming-color-ncurses</a>
for more details.</p>
<h2 id="modifying-the-characters-for-the-wall-bug-and-snake">Modifying
the characters for the wall, bug and snake</h2>
<p>For the wall, bug and snake body characters you can replace the
following in the source code (<strong>include the single
quotes!</strong>) respectively:</p>
<pre><code>&#39;#&#39;
&#39;*&#39;
&#39;o&#39;</code></pre>
<h2 id="modifying-input-keys">Modifying input keys</h2>
<p>Let’s say you don’t want to use arrow keys or you don’t have arrow
keys. Instead you might want the keys <code>l</code>, <code>r</code>,
<code>u</code> and <code>d</code> for the directions. Find the case
statements:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="cf">case</span> KEY_LEFT<span class="op">:</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="cf">case</span> KEY_RIGHT<span class="op">:</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="cf">case</span> KEY_UP<span class="op">:</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="cf">case</span> KEY_DOWN<span class="op">:</span></span></code></pre></div>
<p>Replace <code>KEY_LEFT</code> with:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ch">&#39;l&#39;</span></span></code></pre></div>
<p>and do the same thing for the other directions too. If you want more
than one key e.g. the arrow keys and the letters just add another case
statement e.g. for left it might be:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="cf">case</span> KEY_LEFT<span class="op">:</span> <span class="cf">case</span> <span class="ch">&#39;l&#39;</span><span class="op">:</span></span></code></pre></div>
<p>Yes the single quotes matter. You can do similar for the other input
keys. Please note that modifier keys like ctrl aren’t detectable or at
least I’m unaware of how to do so.</p>
<h2
id="modifying-the-statusscore-line-table-of-variablesstats-below">Modifying
the status/score line (table of variables/stats below)</h2>
<h3 id="spoiler-warning">SPOILER WARNING</h3>
<p>Below I give a table of some variables/expressions along with the
data types and their respective format specifiers of the data.
Originally it was a lot more detailed but as I started obfuscating
things variables started to disappear and I decided to remove those
variables from the table outright. Again also remember that it’s
outdated.</p>
<p>Please note that this set of information is the same that will be
seen at the end of the game; I leave that as an exercise to the reader
to implement two different sets. Please also be aware that if you don’t
want any information you must set it to the below at the very least;
defining it without a value is not enough (it amounts to the parameters
to a printf call):</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#define J </span><span class="st">&quot; &quot;</span><span class="pp"> </span><span class="op">);</span></span></code></pre></div>
<p>If you don’t care about brief displays of ‘o’ at 0,0 you can just
have:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#define J </span><span class="st">&quot;&quot;</span><span class="op">);</span></span></code></pre></div>
<p>That’s the bare minimum. Notice also that it’s been a long while
since I’ve tested this part but I think this is right.</p>
<p>Anyway as I said the score line has basic statistics that’s
relatively easy to change if you want more or less or different
information e.g. the location of the bug.</p>
<p>Initially there was no display of where the (head of the) snake was
at nor the maximum size (that is the size calculated by ncurses) -
though the astute hacker would notice that the maximum dimensions size
is not what the status line says: this has to do with the walls and the
status line - coordinates.</p>
<p>At that point the only time the top stats were updated is when the
snake got a bug. This however was something I didn’t quite like: I like
having the coordinates of where the snake is plus the other things that
are there (a number of which were added over time). Obviously this would
take many bug sized bytes (bites) even once let alone twice! Thus I made
it into a define:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#define J Z</span><span class="op">(</span><span class="pp">X</span><span class="op">:%</span><span class="pp">d</span><span class="op">/%</span><span class="pp">d Y</span><span class="op">:%</span><span class="pp">d</span><span class="op">/%</span><span class="pp">d S</span><span class="op">:%</span><span class="pp">zu</span><span class="op">/%</span><span class="pp">zu B</span><span class="op">:%</span><span class="pp">zu\n</span><span class="op">),</span><span class="pp"> Y</span><span class="op">,</span><span class="pp"> y</span><span class="op">[-</span><span class="dv">2</span><span class="op">],</span><span class="pp"> X</span><span class="op">,*</span><span class="pp">y</span><span class="op">,</span><span class="pp">A</span><span class="op">,</span><span class="pp">g</span><span class="op">,</span><span class="pp"> c</span><span class="op">);</span></span></code></pre></div>
<p>With the table below you can show a variety of other
variables/statistics.</p>
<p>There’s another reason for changing this line though: depending on
the terminal width the line could cover the top wall; this can even
happen only part of the game because the line length is not constant:
most of the variables change throughout the game play and as these are
displayed the length of the line changes. Use <code>make test</code> to
get an estimate (it’s not perfect).</p>
<p>This is not the fault of my entry but rather how text wraps. But this
is another reason it’s easy to change: if the terminal size is too short
then you can update it; but if you want additional or different
information you can also update it. Remember that if you modify the
score data the termcaps algorithm might not remain as correct!</p>
<p>But the game needs to have the walls drawn and the score line is also
important; well it’s important in that the row number of the top wall is
in fact used and so if this line wasn’t there it would require changes
to make it work right.</p>
<p>For an example this would only include the size of the snake and the
number of bugs eaten (I think I have this correct; I’ve made many
changes to the point of not wanting to mess with anything that’s
unnecessary):</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#define J Z</span><span class="op">(</span><span class="pp">SIZE</span><span class="op">:</span><span class="pp"> </span><span class="op">%</span><span class="pp">zu BUGS</span><span class="op">:</span><span class="pp"> </span><span class="op">%</span><span class="pp">zu\n</span><span class="op">),</span><span class="pp"> A</span><span class="op">,</span><span class="pp"> c</span><span class="op">);</span></span></code></pre></div>
<p>More generally the following expressions and data types (with format
specifiers) come to mind as information that might be of interest.</p>
<pre><code> DESCRIPTION EXPRESSION TYPE FORMAT SPECIFIER
Snake size A size_t %zu
Y coordinate Y int %d
of snake head
X coordinate X int %d
of snake head
Max snake size g size_t %zu
Bugs eaten c size_t %zu
Bug line (Y) *U int %d
Bug column (X) *V int %d
Snake size A size_t %zu
Growth size (per N size_t %zu
bug) </code></pre>
<h2 id="make-it-so-the-snake-starts-at-a-random-location">Make it so the
snake starts at a random location</h2>
<p>Quite simply change:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a>X <span class="op">=</span> H <span class="op">/</span> <span class="dv">2</span><span class="op">;</span> Y <span class="op">=</span> <span class="op">*</span>x <span class="op">/</span> <span class="dv">2</span><span class="op">;</span></span></code></pre></div>
<p>To be something like:</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a>X <span class="op">=</span> R<span class="op">(</span><span class="dv">1</span><span class="op">,</span>H<span class="op">-</span><span class="dv">1</span><span class="op">);</span></span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a>Y <span class="op">=</span> R<span class="op">(</span><span class="dv">2</span><span class="op">,*</span>x<span class="op">-</span><span class="dv">1</span><span class="op">);</span></span></code></pre></div>
<p>Or whatever you might want it to be… (question to answer: will this
work at all? You decide!)</p>
<h1 id="additions">Additions (+)</h1>
<p>Here are some things you could add (including a bit of code).</p>
<h2 id="health-andor-lives">Health (and/or Lives)</h2>
<p>This was something I thought of a number of times but I opted for
other features instead. Here are some ideas on how one might choose to
implement something like this. Or maybe it’s more like what sorts of
things do you have to consider and answer?</p>
<ol start="0" type="1">
<li><p>If the snake runs back into itself - thus dying - the snake would
actually be slithering inside itself (a rather creepy thought - though
they sort of do when they shed their skin). How then would the lives be
of any value? If that would constitute as running into itself wouldn’t
it very quickly lose all lives?</p>
<p>I can think of a number of ways to answer this question: by defining
specific rules (as in what would be allowed and what wouldn’t be) and
also by when to decrement the lives.</p></li>
<li><p>If the snake hits a wall and it’s not allowed to where would the
snake be placed? This is similar to (1) but maybe not as many things to
consider.</p></li>
<li><p>Should the snake lose its size? WHAT does having another life
even MEAN?</p></li>
<li><p>Do you want (you do not necessarily need) a new variable that
says how many lives you want? Either way probably be good that it can be
specified by the player.</p></li>
</ol>
<p>The simplest rules I can think of off the top of my head is that the
snake loses its size but it keeps the bugs count. So if the lives are
three and the snake has three lives, has eaten 15 bugs and then runs
into itself it will start out again at the original size (remember
there’s a fair bit more than just changing the size of the snake to do
in order for it to be of use!) but it then the next bug it eats will be
the 16th bug.</p>
<p>Of course you could also say that the first time the snake eats a bug
(on the next life) it grows to the size it once was. This would actually
be one way to deal with some issues that I sort of alluded to above. Of
course it also has some other complications.</p>
<p>You could do similar for health only maybe the size of the snake
decreases or you use the variable you would have used for lives to be
health instead.</p>
<p>Vital issue to resolve: where is the snake? And if the snake size is
decreased will you be careful enough that you don’t run into the snake
where it actually isn’t?</p>
<h2 id="saving-the-game">Saving the game</h2>
<p>A few things would have to be done to do this. Maybe more than a few:
some decisions and some code.</p>
<p>First obviously is you would need a hook to save the game: that is
what if you don’t want to save? You could save every time the snake
moves so that you keep the highest size (though this could theoretically
slow the game down more as the snake gets bigger and bigger). Or you
could say that hitting the key ‘s’ saves the game by calling a save
function.</p>
<p>Second is you need a save function. You would need to save the
dimensions of the game, all the coordinates the snake is currently at
(from head to tail), where the bug is, decide whether or not to save the
direction (if it’s 0 the snake isn’t moving which would mean the player
could decide when to resume) and the number of bugs eaten so far.
Alternatively you could have the bug simply be placed somewhere where
the snake isn’t after replacing (can you replace something with itself?)
the snake.</p>
<p>Question: do you have to save the WALLS and other environmental
variables? You wouldn’t have to but you could: if you didn’t it would
mean that the player could change the growth size on another run for
example, or they could disable or enable a feature.</p>
<p>Of course you would also need a restore routine. This would mean you
would want to parse the command line so as to know which file should be
read in (easiest way would be if the first arg is some value then it
tries to load in whatever you decided to name the save file). How would
this work?</p>
<p>You would have to make sure that the dimensions of the terminal are
valid for what was saved and you would have to compensate that maybe the
dimensions have to be slightly adjusted for the screen (I have given
more than enough information on this elsewhere as to why this is).
Obviously you have to initialise ncurses, allocate the arrays, draw the
walls, snake, bug etc. You wouldn’t initialise ncurses or its features
more than once (i.e. keep track of whether or not you have initialised
these things due to a file being read or starting anew). Clearly you
would have to come up with a file format and have error detection too. I
can think of an easier way to make sure you don’t initialise the ncurses
twice however. It would do the same things only with a bit less code and
maybe simpler logic.</p>
<p>It might seem like a difficult task but it’s actually not that
difficult. It didn’t take much time for me to do something like this: as
far as saving and loading the values and even setting up ncurses: I just
didn’t go beyond that.</p>
<p>Tip: <strong>DON’T TRY</strong>
<code>scr_dump()</code>/<code>scr_restore()</code>/<code>scr_init()</code>/<code>scr_set()</code>.
After a quick test in the way I have things set up it seems to cause
some problems (also <code>scr_dump()</code> quits the program).</p>
<p>You would have to instead identify that restoring is requested, then
read in the file (including the coordinates) and then populate the snake
arrays, drawing it on screen.</p>
<h2 id="different-types-of-walls">Different types of walls</h2>
<p>The game has two modes with walls: if you run into it the game is
over (you die) OR you go through it and come out on the opposite side.
There certainly are other possibilities though. Here I give some ideas
that could be implemented (and one I have some code for).</p>
<h3 id="different-types-of-walls-blockades">Different types of walls:
Blockades</h3>
<p>I did this once before as an experiment so it can work fine: let’s
say instead of the snake either dying or going through and out on the
other side what if it’s just that the snake is momentarily dazed and
unable to move again until it comes round sort of like what happens with
some people who pay more attention to their ruddy phone instead of where
they’re walking (even when crossing a busy street!).</p>
<p>If you look at the walls code you will see a ternary operator for
both <code>X</code> and <code>Y</code> coordinates. This of course is
very different now but the idea remains the same:</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> <span class="op">(</span>p <span class="op">&amp;&amp;</span> <span class="op">!(*</span>O<span class="op">&gt;=</span>O<span class="op">[</span><span class="dv">1</span><span class="op">]||</span>H<span class="op">&gt;=</span>M<span class="op">(</span><span class="dv">1</span><span class="op">)))</span></span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>X<span class="op">&lt;</span><span class="dv">1</span><span class="op">||</span>X<span class="op">&gt;=</span>H<span class="op">)</span></span>
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a> X <span class="op">=</span> X<span class="op">&lt;</span><span class="dv">1</span><span class="op">?</span>H<span class="op">-</span><span class="dv">1</span><span class="op">:</span><span class="dv">1</span><span class="op">;</span></span>
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>Y<span class="op">&lt;</span><span class="dv">2</span><span class="op">||</span>Y<span class="op">&gt;=*</span>O<span class="op">)</span></span>
<span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a> Y <span class="op">=</span> Y<span class="op">&lt;</span><span class="dv">2</span><span class="op">?*</span>O<span class="op">-</span><span class="dv">1</span><span class="op">:</span><span class="dv">2</span><span class="op">;</span></span>
<span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<p>You can ignore the first if if you like; I’m not going to explain
that part. The inner if statements however are testing if the new snake
coordinates are beyond the walls (off screen). Depending on where the
snake is it will set the coordinates to the correct new location.</p>
<p>If however you wanted the walls to act as a barrier you could do
something like this instead (omitting the inner if statements here):</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a>X<span class="op">=</span>X<span class="op">&lt;</span><span class="dv">1</span><span class="op">?</span><span class="dv">1</span><span class="op">:*</span>H<span class="op">-</span><span class="dv">1</span><span class="op">;</span></span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a>Y<span class="op">=</span>Y<span class="op">&lt;</span><span class="dv">2</span><span class="op">?</span><span class="dv">2</span><span class="op">:*</span>O<span class="op">-</span><span class="dv">1</span><span class="op">;</span></span></code></pre></div>
<p>Again though that’s just the idea; the code is dramatically
different. The above incidentally is not even complete.</p>
<p>You could also have it so depending on the WALLS value have it go
through walls, end game or act as a blockade. If you really wanted you
could have some walls you can go through and some you can’t (maybe
different colours would be needed?).</p>
<p>Oh and yes you might find it can look a bit funny this way. For
instance if you’re slithering left along top wall and you hit up the
snake will still be horizontal (after the thing I warned about is
resolved of course! - And that’s a very important one unless you want
negative coordinates - and you don’t!) since it’ll have stopped. If you
were to then hit the direction you had been going you will see that it
continues going that way in a straight horizontal line. In other words
the snake will just appear to be not moving as if the game had been
paused.</p>
<h2 id="diagonal-movement">Diagonal movement</h2>
<p>I said this is impractical so how could it be done? Well you have to
decide which keys would take you up and right, up and left, down and
right or down and left. The trouble is ncurses can’t detect both right
and up at the same time. Besides that though it would only be a matter
of updating both <code>Y</code> and <code>X</code> coordinates rather
than just one or the other. That’s easy enough to do. The only
impractical part of this is deciding the keys and unfortunately rule 2b
(and probably 2b) would have been broken and so have no chance of
winning (now that I won it’s too much effort and I’ve forgotten most of
the stuff too to say nothing of getting the format right).</p>
<p>Anyway it’s just a matter of updating both <code>X</code> and
<code>Y</code>. But what about going through walls mode? Does it matter?
I’ll let you figure it out!</p>
<p>Looking back at the missing features, this is the feature I wanted
more than any other.</p>
<h2 id="special-abilities">Special abilities</h2>
<p>Could the snake jump over itself if it wanted to? How would this be
implemented? The head would simply be moved one beyond but then you
would have to keep track of where the part that was jumped over is and
what part of the snake has to do the same thing. I can think of a much
easier way though. This very paragraph actually includes it! Then it
would only be a matter of deciding what key does what.</p>
<h2 id="obstacles">Obstacles</h2>
<p>Similar to walls only that it’s inside the field. You would have to
consider the behaviour of running into the obstacles: should the snake
die? Should it lose health/lives (if implemented)? Can it go through
them? And also: the bug placement would have to be updated too. You
would also need to figure out what character to use for the obstacles: I
personally would just reuse the wall character. Also to make it simpler
if the walls are passable then so too would be the obstacles; else you
would die (or if you had health/lives then those would apply).</p>
<h2 id="more-than-one-bug">More than one bug</h2>
<p>The main thing to consider would be the test if the snake has eaten a
bug would have to check an array (and: how big? Where does the size come
from?) as well as the placement routine (though I guess you could have a
value for each array meaning that if you run into a bug spot that has
more than one bug you would eat that many bugs).</p>
<h2 id="power-ups">Power-ups</h2>
<p>You would need to decide what power-ups exist, what they do, how many
can there be (and how many can the snake have at one time), what makes
them show up plus you would have to add code to handle the
power-ups.</p>
<h2 id="snakeskin-shedding-becoming-an-obstacle">Snakeskin shedding
(becoming an obstacle)</h2>
<p>I.e. at some point the snake would split back to some (arbitrary)
size but then the snakeskin left would act as the snake in the sense
that if the snake runs into it it’s the same as running into the snake.
More realistically the snakeskin would be the same size the snake was
and the snake would grow as it slithered out. But that would fill the
screen very quickly of course. Maybe the snakeskin has some other
purpose?</p>
<h2 id="snake-moves-faster-over-time">Snake moves faster over time</h2>
<p>In the game
[Surround](https://en.wikipedia.org/wiki/Surround_(video_game) you have
no control over the speed. I believe there are five different speed
levels but the player has no control over it except the drawing mode. It
would be possible to make it so the snake moves faster over time. How
often and by what amount would probably vary but importantly it would
need to not go so fast there’s no controlling - or go below 0 which puts
it in blocking mode. Probably it would be that it gets faster up to a
certain per cent of the original speed so that it doesn’t get too fast.
But even that would have to be customisable.</p>
<h2 id="max-times-the-bug-evades-before-game-over">Max times the bug
evades before game over</h2>
<p>Basically so that the player is on a time schedule of sorts. The same
could be done for maximum number of movements before game over. These
would both be rather easy to implement but personally I would only
consider the max number of evasions (I just don’t have many more bytes
left!) - unless maybe that there is no default limit on max moves.</p>
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/end-row.default.html -->
</div>
<!-- END: this line ends content from: inc/end-row.default.html -->
<!-- START: this line starts content from: inc/footer.default.html -->
<div class="footer">
<hr>
<h2>Coda</h2>
<p><a href="https://validator.w3.org/nu/?doc=#">Nu HTML check this web page</a></p>
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
</div>
<!-- END: this line ends content from: inc/footer.default.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->
+430
View File
@@ -0,0 +1,430 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- -->
<!-- The original markdown content was formed by the tool: bin/gen-other-html.sh -->
<!-- The HTML was converted from markdown by the tool: bin/md2html.sh -->
<!-- -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>The International Obfuscated C Code Contest</title>
<meta name="description" content="bugs.md for 2020/ferguson1">
<meta name="keywords" content="IOCCC, 2020/ferguson1, bugs.md">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<img src="../../png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
<h1>The International Obfuscated C Code Contest</h1>
<h2>bugs.md for 2020/ferguson1</h2>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.up2index.html -->
<div class="topnav">
<a class="Left" href="index.html">&uarr; jump to index.html &uarr;</a>
</div>
<!-- END: this line ends content from: inc/topnav.up2index.html -->
<!-- START: this line starts content from: inc/begin-row.default.html -->
<div class="row">
<!-- END: this line ends content from: inc/begin-row.default.html -->
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
<div class="leftcolumn">
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/sidenav.default.html -->
<div class="sidenav">
<a href="#content">Jump to contents</a>
</div>
<hr>
<div class="sidenav">
<a href="../../index.html">IOCCC Home</a>
<a href="../../years.html">Winning Entries</a>
<a href="../../authors.html">People who have won</a>
</div>
<hr>
<div class="sidenav">
<a href="../../news.html">IOCCC News</a>
<a href="../../faq.html#submit">How to enter the IOCCC</a>
<a href="../../faq.html">FAQ</a>
</div>
<hr>
<div class="sidenav">
<a href="../../bugs.html">Bugs &amp; (mis)features</a>
<a href="../../faq.html#fix_an_entry">Fixing IOCCC entries</a>
<a href="../../faq.html#fix_web_site">Fixing the web site</a>
<a href="../../faq.html#fix_author">Fixing author info</a>
<a href="../../thanks-for-help.html">Thanks for the help</a>
</div>
<hr>
<div class="sidenav">
<a href="../../judges.html">The IOCCC Judges</a>
<a href="../../contact.html">Contacting the IOCCC</a>
</div>
<hr>
<div class="sidenav">
<a href="#top">Jump to top</a>
</div>
<!-- END: this line ends content from: inc/sidenav.default.html -->
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
<div class="rightcolumn">
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<a name="content"></a>
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<p>Current bugs and things that look like bugs but are not, as of 12
September 2020.</p>
<p><a name="toc"></a></p>
<ul>
<li><p><a href="#builtin-test-unit">Built-in test unit for some
features!</a></p></li>
<li><p><a href="#stillsnake">The snake doesn’t seem to be
moving</a></p></li>
<li><p><a href="#getch">getch() also accepts input from some input
hardware other than keyboards</a></p></li>
<li><p><a href="#size">SIZE=0 is the same as SIZE=1 and other
oddities</a></p></li>
<li><p><a href="#bitetail">‘I was a few places behind my tail and I ran
into it!’</a></p></li>
<li><p><a href="#middleofsnake">With negative growth the snake drops
from the middle of the body</a></p></li>
<li><p><a href="#buginsnake">It looks like the bug is in the
snake</a></p></li>
<li><p><a href="#bugplacement">On the safety of the bug placement
loop</a></p></li>
<li><p><a href="#verticalsnake">Vertical snake has more space between
snake char than horizontal</a></p></li>
</ul>
<h1
id="built-in-test-unit-for-some-features"><a name="builtin-test-unit" href="#toc">Built-in
test unit for some features!</a></h1>
<p>Fun fact: There’s something of a built-in test unit for some
features; much like some of the other features this was not
intentionally designed but is simply a fun consequence of the features I
did implement.</p>
<p>Let’s say you want to verify that the evade mode is at the right
count. How can you verify it without modifying the code? Try:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>0 <span class="va">SHED</span><span class="op">=</span>1 <span class="va">SHEDS</span><span class="op">=</span>1 <span class="va">EVADE</span><span class="op">=</span>10 <span class="ex">./prog</span></span></code></pre></div>
<p>Since you start out at size 0 and you shed every movement then when
you’re size 10 (as long as you don’t eat a bug of course!) the bug
should evade.</p>
<p>If you set it to <code>SIZE=10</code> there would be a difference of
10. Now every move you will see the size the snake is. But then…Why is
it that it doesn’t seem to move until the snake is of size 20? Because
you start out at size 10 of course (but in fact if you observe the snake
won’t appear to be of size 20 yet).</p>
<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>
<h1
id="the-snake-doesnt-seem-to-be-moving"><a name="stillsnake" href="#toc">The
snake doesn’t seem to be moving</a></h1>
<p>One way to show this is in full is to set the initial size and growth
size to a high value; then try each one individually. For example:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>100 <span class="ex">./prog</span></span></code></pre></div>
<p>In this case after you make the first move the snake will keep
growing and so the snake tail stays in the same spot until after it’s
the ‘full size’. When it has reached the full size then the entire body
of the snake will 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 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 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 be a moment of lingering where it appears the snake moves for
a few places before it then stops moving and just grows until it’s the
full size.</p>
<p>It can also appear to be not moving when the snake is extraordinarily
long and more so when the snake has just eaten: which of course is when
it would grow (just like when shedding). Even so sometimes it takes a
moment for the snake tail to catch up with the body (so to speak) so
that it could for a few moments be difficult to know if where you’re
going is going to be occupied or not.</p>
<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 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>
<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 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>
<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 intentional; a snake size of 0 is pointless
but why should it not be playable anyway?</p>
<p>If <code>SIZE &lt; 0</code> you’ll likely win straight away since
it’s unsigned and it’ll wrap back to the maximum so you will win
automatically (this is the same as the second mode the judges suggested
with <code>SIZE=-1 ./prog</code>).</p>
<p>As for the growth sizes (including shedding) if it’s &lt; 0: the
snake will still lose its length and display will still be odd: because
the snake size is decreased any element beyond the reduced size isn’t
touched so the snake characters will remain on the screen; only the
moving snake is what matters. But it’s likely the game will be won
fairly quickly because once it’s -1 in size it’ll be at the maximum
size.</p>
<p>For example if I say <code>SIZE=3 GROW=-2</code> at two bugs the game
is won.</p>
<p>As for growing: anything &gt; 0 it will grow that many; 0 it will not
grow (which I show as a gameplay mode); and &lt; 0 it will ‘shrink’ as I
explained above. You could say that it’s defying physics by growing and
shrinking simultaneously but either way negative size will force a
win.</p>
<p>Here’s a fun output:</p>
<pre><code>&lt; &lt;&lt;&lt;+</code></pre>
<p>That’s from:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="va">SHED</span><span class="op">=</span>1 <span class="va">SHEDS</span><span class="op">=</span>-1 <span class="ex">./prog</span></span></code></pre></div>
<p>And right after that you would see:</p>
<pre><code>YOU WIN!
X:72/156 Y:20/41 S:997/997 B:0</code></pre>
<p>Try this though:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="va">SHEDS</span><span class="op">=</span>-1 <span class="va">SHED</span><span class="op">=</span>25 <span class="ex">./prog</span></span></code></pre></div>
<p>And you’ll see that you start to be the normal size but then you
leave your head several places until you end up getting to the max size
(by way of it being unsigned). This isn’t a bug even if it might seem
like one. In fact this is the basis of the grow/shrink mode of play that
I talk about in the <a href="gameplay.html">gameplay.html</a> (<a
href="gameplay.md">gameplay.md</a> on GitHub) file.</p>
<p>Here’s another thing to be aware of. Let’s say you do:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>1 <span class="va">GROW</span><span class="op">=</span>-1 <span class="ex">./prog</span></span></code></pre></div>
<p>How many bugs will it take before you win? In fact it’s two: you
would see the head twice: the second time once you ‘shrink’ down to size
0; it would then be that if you get another bug you will be at the ‘max
size’:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">YOU</span> WIN!</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="ex">X:81/156</span> Y:35/41 S:997/997 B:2</span></code></pre></div>
<h1
id="i-was-a-few-places-behind-my-tail-and-i-ran-into-it"><a name="bitetail" href="#toc">‘I
was a few places behind my tail and I ran into it!’</a></h1>
<p>I.e. what happens if you’re growing - for example after just eating a
bug - and you’re racing towards your tail? If you’re behind it should be
fine since you’re going the same speed as the snake is, right? Not
quite. Because you’re growing 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 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>
<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>
<p>For instance it might look like this (the first line is as it
happens, the second pointing to where it happens and the third being
what’s left after the rest of the snake has gone through). Doing
<code>SHED=100 SHEDS=-1</code>:</p>
<pre><code>ooooooooo&gt;ooo&gt;
^
&gt;</code></pre>
<p>The <code>^</code> points to the part that’s split from the snake and
which will be there on its own after the snake passes through it. Here’s
an example with it being <code>SHEDS=-3</code>:</p>
<pre><code>&lt;ooo&lt;ooooo
^^^
&lt;oo</code></pre>
<p>If you go through the part that has split (which for some might be
difficult to see whilst the snake has not fully left its skin) you won’t
run into yourself; if you run into another part though you do. This
might be a bit confusing I know but what kind of animal shrinks in size
by leaving its head behind only to sprout up a new head? Actually…on
second thought, I won’t go there! :)</p>
<p>Anyway it’s an odd idea for the snake to shrink by leaving part of
its skin: 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 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>
<p>I show a different example in the <a
href="crazy.log.md">crazy.log.md</a> file but what defines a coordinate
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 the snake decreases in size by 3 then the three respective
characters you can go through safely. But this also means that a bug can
go there! So you might see something like:</p>
<pre><code>&lt;*oooooooo</code></pre>
<p>This is because the snake is no longer there: in fact in this run the
snake was quite a bit lower on the screen and 25 in length.</p>
<h1
id="on-the-safety-of-the-bug-placement-loop"><a name="bugplacement" href="#toc">On
the safety of the bug placement loop</a></h1>
<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 understand the concern and it’s something I played
with a lot to be sure that it doesn’t happen. This is how it works.</p>
<p>To explain it I will go back to the make test program
<code>termcaps</code> (which is imperfect for the recommended terminal
size but the max snake size is exactly how it’s done in Snake and works
well). The minimum terminal size I require in the game is 10 x 10. This
includes the walls and score line.</p>
<p>Now the default max snake size is 997 but when the terminal is too
small it adjusts the max snake size. For 10 lines and 10 columns you
would see:</p>
<div class="sourceCode" id="cb12"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> make test</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> supports cursor movement</span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> supports making cursor invisible</span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> supports bold</span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> supports colours</span>
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> rows 10 <span class="er">(</span><span class="ex">7</span> playable<span class="kw">)</span></span>
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> cols 10 <span class="er">(</span><span class="ex">8</span> playable<span class="kw">)</span></span>
<span id="cb12-9"><a href="#cb12-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-10"><a href="#cb12-10" aria-hidden="true" tabindex="-1"></a><span class="ex">snake</span> size: 49 <span class="er">(</span><span class="ex">max</span> size: 49<span class="kw">)</span></span>
<span id="cb12-11"><a href="#cb12-11" aria-hidden="true" tabindex="-1"></a> <span class="ex">bugs:</span> 9 <span class="er">(</span><span class="ex">max</span> size: 9<span class="kw">)</span></span>
<span id="cb12-12"><a href="#cb12-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-13"><a href="#cb12-13" aria-hidden="true" tabindex="-1"></a><span class="ex">at</span> least 28 columns recommended for snake size 49 <span class="er">(</span><span class="ex">is</span> 10<span class="kw">)</span></span>
<span id="cb12-14"><a href="#cb12-14" aria-hidden="true" tabindex="-1"></a><span class="ex">at</span> least 28 columns recommended for snake size 49 <span class="er">(</span><span class="ex">is</span> 10<span class="kw">)</span></span>
<span id="cb12-15"><a href="#cb12-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-16"><a href="#cb12-16" aria-hidden="true" tabindex="-1"></a><span class="ex">1</span> problem detected <span class="er">(</span><span class="ex">0</span> fatal<span class="kw">)</span><span class="bu">.</span></span>
<span id="cb12-17"><a href="#cb12-17" aria-hidden="true" tabindex="-1"></a><span class="ex">make:</span> <span class="pp">***</span> <span class="pp">[</span><span class="ss">test</span><span class="pp">]</span> Error 1</span></code></pre></div>
<p>First: what’s the problem? It’s just a warning that for the snake
size of 49 the recommended size of columns is 28. However this is just
for the score text; with only 10 columns it will overflow and wrap to
the next line(s). But if you observe that 49 is the max snake size. How
is this derived and why?</p>
<p>With 10 rows and columns it’s calculated as <code>7 * 7</code>
(i.e. it’s <code>(cols-3)*(rows-3)</code>. However the number of
playable locations is in this case 56
(<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 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>
<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 think it will be a problem and I have given
resolutions. In any event without cannibal mode it’s even less likely
that you’ll ever run into this problem.</p>
<p>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 a bug and I prefer putting in restrictions to try and
make it very unlikely.</p>
<h1
id="vertical-snake-has-more-space-between-snake-char-than-horizontal-snake"><a name="verticalsnake" href="#toc">Vertical
snake has more space between snake char than horizontal snake</a></h1>
<p>Ilya Kurdyukov also pointed out that depending on orientation of the
snake there are different amount of spaces between the snake char ‘o’.
This is what he had to say on it:</p>
<blockquote>
<p>Yes, it is the problem, space in character terminal is not isotropic
from a viewer (gamer) perspective so one step up look like two steps
right.</p>
<p>MATE Terminal 1.20.0, and font “Ubuntu Mono Regular 13”</p>
<p>But, as I said, there is no terminal problem itself, it’s because
character tiles are not square (except for Japanese/Chinese, Japanese
even have so called full-width English characters in their encoding,
presented in UTF too).</p>
<p><a
href="https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms">https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms</a></p>
<p>So the typical fonts are Half-width or close to it.</p>
<p><img src="halfwidth_vs_fullwidth.png"></p>
</blockquote>
<p>However the function <code>mvaddch()</code> takes a
<code>chtype</code> which amounts to a C char with additional
information and so the full width <code>O</code>is too big for the
function call. He reminded me of the old DOS box chars but even if this
was easily duplicable (and it might be and I don’t remember) the logic
would have to be changed for drawing the snake and in such a way that
would change the source code layout too much - to say nothing else of
the fact I have also forgotten some of what I did obfuscation wise (and
the <a href="spoilers.markdown">spoilers</a> aren’t enough here!).</p>
<p>That being said the font and font size does seem to have somewhat of
an effect on it since his screenshots have wider gaps than mine.</p>
<p>Once again thank you mate for bringing this to my attention and also
playing with it and providing the resources! Much appreciated! (And
although you suggested it is bugging me I once again here say it’s not
at all bugging me but it is very much appreciated and it means a great
deal to me. Cheers.)</p>
<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<tbody>
<tr class="odd">
<td>(c) Copyright 1984-2020, [Leo Broukhis, Simon Cooper, Landon Curt
Noll][judges] - All rights reserved This work is licensed under a
[Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].</td>
</tr>
<tr class="even">
<td>[judges]: https://www.ioccc.org/judges.html [cc]:
http://creativecommons.org/licenses/by-sa/3.0/</td>
</tr>
</tbody>
</table>
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/end-row.default.html -->
</div>
<!-- END: this line ends content from: inc/end-row.default.html -->
<!-- START: this line starts content from: inc/footer.default.html -->
<div class="footer">
<hr>
<h2>Coda</h2>
<p><a href="https://validator.w3.org/nu/?doc=#">Nu HTML check this web page</a></p>
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
</div>
<!-- END: this line ends content from: inc/footer.default.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->
+330
View File
@@ -0,0 +1,330 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- -->
<!-- The original markdown content was formed by the tool: bin/gen-other-html.sh -->
<!-- The HTML was converted from markdown by the tool: bin/md2html.sh -->
<!-- -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>The International Obfuscated C Code Contest</title>
<meta name="description" content="cannibalism.log.md for 2020/ferguson1">
<meta name="keywords" content="IOCCC, 2020/ferguson1, cannibalism.log.md">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<img src="../../png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
<h1>The International Obfuscated C Code Contest</h1>
<h2>cannibalism.log.md for 2020/ferguson1</h2>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.up2index.html -->
<div class="topnav">
<a class="Left" href="index.html">&uarr; jump to index.html &uarr;</a>
</div>
<!-- END: this line ends content from: inc/topnav.up2index.html -->
<!-- START: this line starts content from: inc/begin-row.default.html -->
<div class="row">
<!-- END: this line ends content from: inc/begin-row.default.html -->
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
<div class="leftcolumn">
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/sidenav.default.html -->
<div class="sidenav">
<a href="#content">Jump to contents</a>
</div>
<hr>
<div class="sidenav">
<a href="../../index.html">IOCCC Home</a>
<a href="../../years.html">Winning Entries</a>
<a href="../../authors.html">People who have won</a>
</div>
<hr>
<div class="sidenav">
<a href="../../news.html">IOCCC News</a>
<a href="../../faq.html#submit">How to enter the IOCCC</a>
<a href="../../faq.html">FAQ</a>
</div>
<hr>
<div class="sidenav">
<a href="../../bugs.html">Bugs &amp; (mis)features</a>
<a href="../../faq.html#fix_an_entry">Fixing IOCCC entries</a>
<a href="../../faq.html#fix_web_site">Fixing the web site</a>
<a href="../../faq.html#fix_author">Fixing author info</a>
<a href="../../thanks-for-help.html">Thanks for the help</a>
</div>
<hr>
<div class="sidenav">
<a href="../../judges.html">The IOCCC Judges</a>
<a href="../../contact.html">Contacting the IOCCC</a>
</div>
<hr>
<div class="sidenav">
<a href="#top">Jump to top</a>
</div>
<!-- END: this line ends content from: inc/sidenav.default.html -->
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
<div class="rightcolumn">
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<a name="content"></a>
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<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>
<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 get with a long snake. I made a few changes,
described below, to make it easier to distinguish what is what.</p>
<h1 id="examples">Examples</h1>
<p>In the below game dumps I have replaced the bug with
<strong><code>B</code></strong>, the head with
<strong><code>H</code></strong> and where it is known, the tail with
<strong><code>T</code></strong>, in order to help distinguish where they
are. Since the head is replaced with <strong><code>H</code></strong> I
have noted the direction it was moving above each dump as well as at the
right of the line; each line with a bug, the head or tail is marked with
upper case text at the right to make it easier to find.</p>
<p>The first run I include several dumps but there isn’t much
information about most of them.</p>
<h2 id="example-0-snake-moving-right">Example 0: snake moving right</h2>
<pre><code>X:45/89 Y:22/25 S:1675/2001 B:35
##########################################################################################
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
# o o o o o oooo o #
# oooooooooo o o o o ooo ooooooooo oooo #
# o ooooooooooooooooooooooooo o o o o o #
# o ooooooooooo ooooooooooooooooooooooo oooooooooooooooo o o o #
#oooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o o oo#
# o o ooooooooooooooooooooooooooooooooooooooo o o oBo o oooo o # &lt;- *BUG*
# o o o ooooooooooooooooooooooooooooooooooooooo o o o o o o #
# o o o o o ooo o o oo oooooooooooooooooooooooo o #
# o ooooooooooooooooo oooooooo o o oooooooooooo ooooooooooooooooooooooooo o #
# o o o o oooooo o o o o o oooooooooooooooooooooooo o o o o o #
#oooooooooooooooooo o o o o oo o o o o o oo oo o oo o o oooooooooooooooooooo#
# o oooooooooooooooooooooooooooooooooooooooooooooooooooo oo o o oo o o o #
# o o ooooooooooooooooooooooooooooooooooooooooooooooooo o oo o o o #
#oooooooooo oooo o o o o o o o o oo o oooooooooooooooooo ooooooooooooooooo#
# oooooooooooooooo o o o ooooooooo o oo o o o o o o ooooooooooooo #
# ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o #
#oooooo o oooooo o o o o o o o ooooooooooooooooooooooooo o ooooooo#
# o o o o o o oooo ooooooooooooooooo o o o o o #
# o o oo o o o oooooH o oooooooo ooooo o # &lt;- *HEAD, RIGHT*
#ooooooooo ooooooooooooooooooooo ooooooooooo ooooooo#
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
##########################################################################################</code></pre>
<h2 id="example-1-snake-moving-right">Example 1: snake moving right</h2>
<pre><code>X:79/89 Y:9/25 S:1680/2001 B:36
##########################################################################################
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
# o o o o o oooo o #
# oooooooooo o o o o ooo ooooooooo oooo #
# o ooooooooooooooooooooooooo o o o o o #
# o ooooooooooo ooooooooooooooooooooooo oooooooooooooooo o o o #
#oooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o o oo#
# o o oooooooooooooooooooooooo oo o o oooooooooooooooooooH o # &lt;- *HEAD, RIGHT*
# o o o oooooooooooooooooooooooooooooooooooooooooo o o o o o #
# o o o o o o o o o oo o oooooooooooooooooooooooo o #
# o ooooooooooooooooo o o o o oooooooooooo ooooooooooooooooooooooooo o #
# o o o o oooooo o o o o oooooooooooooooooooooooo o o o o o #
#oooooooooooooooooo o o o oo o o o o o ooo oo o oo o o oooooooooooooooooooo#
# o oooooooooooooooooooooooooooooooooooooooooooooooooooo oo Bo o oo o o o # &lt;- *BUG*
# o o ooooooooooooooooooooooooooooooooooooooooooooooooo o oo o o o #
#oooooooooo oooo o o o o o o o ooo o oooooooooooooooooo ooooooooooooooooo#
# oooooooooooooooo o o ooooooooo o ooo o o o o o o ooooooooooooo #
# ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o #
#oooooo o oooooo o o o o o o o ooooooooooooooooooooooooo o ooooooo#
# o o o o o oooo ooooooooooooooooo o o o o o #
# o o o o o oooooo o oooooooo ooooo o #
#ooooooooo ooooooooooooooooooooo ooooooooooo ooooooo#
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
##########################################################################################</code></pre>
<h2 id="example-2-snake-moving-left">Example 2: snake moving left</h2>
<pre><code>X:53/89 Y:18/25 S:1690/2001 B:38
##########################################################################################
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
# o o o o o oooo o #
# oooooooooo o o o o ooo ooooooooo oooo #
# o ooooooooooooooooooooooooo o o o o o #
# o ooooooooooo ooooooooooooooooo o oooooooooooooooo o o o #
#oooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o o oo#
# o B o oooooooooooooooooooooooo o o o oooooooooooooooooooo o # &lt;- *BUG*
# o o o oooooooooooooooooooooooooooooooooooooooooo o o o o o o #
# o o o o o o o o o o o oooooooooooooooooooooooo o o #
# o ooooooooooooooooo o o o o oooooooooo o ooooooooooooooooooooooooo o #
# o o o o oooooo o o o o oooooooooooooooooooooooo o o o o o o #
#oooooooooooooooooo o o o oo o o o o o o o o o oo oooooooooooooooooooooooooo#
# o oooooooooooooooooooooooooooooooooooooooooooooooooooo oo oo o oo o o o #
# o o ooooooooooooooooooooooooooooooooooooooooooooooooo o oo o o o #
#oooooooooo oooo o o o o o o o o o o ooooooooooooooooo ooooooooooooooooo#
# oooooooooooooooo o o ooooooooo o o o o Hooooooooooo o ooooooooooooo # &lt;- *HEAD, LEFT*
# ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o o o o o #
#oooooo o oooooo o o o o o o o ooooooooooooooooooooooooo o ooooooo#
# o o o o o oooo ooooooooooooooooo o o o o o #
# o o o o o oooooo o oooooooo ooooo o #
#ooooooooo ooooooooooooooooooooo ooooooooooo ooooooo#
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
##########################################################################################</code></pre>
<h2 id="example-3-snake-moving-left">Example 3: snake moving left</h2>
<pre><code>X:61/89 Y:6/25 S:1815/2001 B:63
##########################################################################################
# oooooooooooooooooooooooooooooooooT # &lt;- *TAIL*
# o #
# ooooo o ooooooooooo #
# oooooooooo o o B ooooooooooooooooooooo # &lt;- *BUG*
#oooooo o oooooooooooooooooooooooooooooooo Hooooooooooooooooooooooooooo# &lt;- *HEAD, LEFT
# o ooooooooooooooooooooooo o oooo o o o o ooo #
# o o oooo oooooooooooooooooooooooooooooooo o ooooooooooooooooooo ooo #
# o ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ooo #
# o o o o oooooooooooooooooooooooooooooooooooooooooooooo o o o o ooo #
# o oooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooooooooooooooooooooo #
#ooooooooooooooooooooooo o oooooooooo o ooooooooooooooooooooooooooooooo#
# o o o o oooooo o ooooooooooooooooooooooooooooooooooooooooooo #
#oooooooooooooooooo o o o oo o o o ooooo o o oooooooooooooooooooooooooo#
# o oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oo oo #
# o o oooooooooooooooooooooooooooooooooooooooooooooooooo oo o ooooooooooo #
#oooooooooo oooo oooooooooooooo o o ooooooooooooooooo ooooooooooooooooo#
# oooooooooooooooo oo ooooooooo o oooooooooooooo o ooooooooooooooooo #
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooo#
#oooooo ooooooooooooooooooooooooooooooooooooooooo o ooo ooooooo#
# oo o oooo oooo o o oooooo o #
# ooooooooooooooooo ooooooooooooooooooo oooooooooooooooooooo o #
#ooooooooo ooooooooooooooooooooooooooooooooooooooooooooo ooooooo#
# #
##########################################################################################</code></pre>
<h2 id="example-4-snake-moving-left">Example 4: snake moving left</h2>
<pre><code>X:47/89 Y:5/25 S:1815/2001 B:63
##########################################################################################
# ooooooooooooooooT # &lt;- *TAIL*
# o #
# ooooo o ooooooooooo oooo # &lt;- *HEAD, LEFT*
# oooooooooo o o BHooo o ooooooooooooooooooooo # &lt;- *BUG*
#oooooo o oooooooooooooooooooooooooooooooo oooooooooooooooooooooooooooooooooooo#
# o ooooooooooooooooooooooo o oooo o o o o ooo #
# o o oooo oooooooooooooooooooooooooooooooo o ooooooooooooooooooo ooo #
# o ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ooo #
# o o o o oooooooooooooooooooooooooooooooooooooooooooooo o o o o ooo #
# o oooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooooooooooooooooooooo #
#ooooooooooooooooooooooo o oooooooooo o ooooooooooooooooooooooooooooooo#
# o o o o oooooo o ooooooooooooooooooooooooooooooooooooooooooo #
#oooooooooooooooooo o o o oo o o o ooooo o o oooooooooooooooooooooooooo#
# o oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oo oo #
# o o oooooooooooooooooooooooooooooooooooooooooooooooooo oo o ooooooooooo #
#oooooooooo oooo oooooooooooooo o o ooooooooooooooooo ooooooooooooooooo#
# oooooooooooooooo oo ooooooooo o oooooooooooooo o ooooooooooooooooo #
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooo o oooooooooooooo#
#oooooo ooooooooooooooooooooooooooooooooooooooooo o ooo ooooooo#
# oo o oooo oooo o o oooooo o #
# ooooooooooooooooo ooooooooooooooooooo oooooooooooooooooooo o #
#ooooooooo ooooooooooooooooooooooooooooooooooooooooooooo ooooooo#
# #
##########################################################################################</code></pre>
<h2 id="example-5-snake-moving-left-with-snake-inside-itsself">Example
5: snake moving left with snake inside itsself</h2>
<p>Another example invocation where the snake head is in the snake and
where the snake hadn’t yet moved (that is it was still growing):</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">SIZE</span><span class="op">=</span>1500 <span class="va">GROW</span><span class="op">=</span>2 <span class="va">MAXSIZE</span><span class="op">=</span>1600 <span class="ex">./prog</span></span></code></pre></div>
<p>It looked like:</p>
<pre><code>X:55/89 Y:11/25 S:1564/1600 B:32
##########################################################################################
# oooo ooooooooooooooooooooooooo o #
# o ooooooooooooooooooooooooooooooooooooooooooooo ooooooooooooooooo #
#ooo o o o o o oooooo#
# o o o oooooooooooooooooooooooooo o #
#oooooooooooooooooooooooooo o ooo o oo oooooooooooooooooooooo#
#oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo#
# o o ooooooooooooo oooooooooooooooooooooo ooo oo o o o oo#
#ooo o o oooooo o oooo ooo oo o o oooo#
# o o o oooo o o oo ooo oooooooooooooooooo oo#
# o o o ooooooooooooo oooooooooooooooo oooooHoooooooooooooooooooooooooooooo # &lt;- *HEAD, LEFT*
# o o o o ooooooooo oooooooooooooooooooooooooooo o o o o #
# o ooooooo o o o oooooooooooooo o o o o o o ooooo #
# o o o o o o o o o o o o o #
# o o o o o o oB ooooooooooooooooooo o o ooo # &lt;- *BUG*
# o o o o o oooooooooooooooooooooooooooooooooooooooooooo o o #
# oooooooooooooo o o oo o o oooooooooooooooooooooooooooooooooooooo #
# o oo o o oo oooooooooooooo o o o oooooooooooo #
#oooooo oo oooooooooooooo o o o o o o ooo oooooo#
# ooooo o o o o oooooooooooooooooooooooooooooooo o #
# o oooooooooooooo o o o o ooooooooo o o #
# o o oooooo o oooooooooooo o o #
# oooooooooooooooooooooooooooooooooooooooooooooooooooo ooo o #
# ooooooooooo ooooooooooooo o oooooooooo #
##########################################################################################</code></pre>
<p>…and no <strong><em>Preciouss</em></strong>: the <em>itsself</em> was
not a typo but intentional sibilance!</p>
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/end-row.default.html -->
</div>
<!-- END: this line ends content from: inc/end-row.default.html -->
<!-- START: this line starts content from: inc/footer.default.html -->
<div class="footer">
<hr>
<h2>Coda</h2>
<p><a href="https://validator.w3.org/nu/?doc=#">Nu HTML check this web page</a></p>
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
</div>
<!-- END: this line ends content from: inc/footer.default.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->
+338
View File
@@ -0,0 +1,338 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- -->
<!-- The original markdown content was formed by the tool: bin/gen-other-html.sh -->
<!-- The HTML was converted from markdown by the tool: bin/md2html.sh -->
<!-- -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>The International Obfuscated C Code Contest</title>
<meta name="description" content="chocolate-cake.md for 2020/ferguson1">
<meta name="keywords" content="IOCCC, 2020/ferguson1, chocolate-cake.md">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<img src="../../png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
<h1>The International Obfuscated C Code Contest</h1>
<h2>chocolate-cake.md for 2020/ferguson1</h2>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.up2index.html -->
<div class="topnav">
<a class="Left" href="index.html">&uarr; jump to index.html &uarr;</a>
</div>
<!-- END: this line ends content from: inc/topnav.up2index.html -->
<!-- START: this line starts content from: inc/begin-row.default.html -->
<div class="row">
<!-- END: this line ends content from: inc/begin-row.default.html -->
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
<div class="leftcolumn">
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/sidenav.default.html -->
<div class="sidenav">
<a href="#content">Jump to contents</a>
</div>
<hr>
<div class="sidenav">
<a href="../../index.html">IOCCC Home</a>
<a href="../../years.html">Winning Entries</a>
<a href="../../authors.html">People who have won</a>
</div>
<hr>
<div class="sidenav">
<a href="../../news.html">IOCCC News</a>
<a href="../../faq.html#submit">How to enter the IOCCC</a>
<a href="../../faq.html">FAQ</a>
</div>
<hr>
<div class="sidenav">
<a href="../../bugs.html">Bugs &amp; (mis)features</a>
<a href="../../faq.html#fix_an_entry">Fixing IOCCC entries</a>
<a href="../../faq.html#fix_web_site">Fixing the web site</a>
<a href="../../faq.html#fix_author">Fixing author info</a>
<a href="../../thanks-for-help.html">Thanks for the help</a>
</div>
<hr>
<div class="sidenav">
<a href="../../judges.html">The IOCCC Judges</a>
<a href="../../contact.html">Contacting the IOCCC</a>
</div>
<hr>
<div class="sidenav">
<a href="#top">Jump to top</a>
</div>
<!-- END: this line ends content from: inc/sidenav.default.html -->
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
<div class="rightcolumn">
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<a name="content"></a>
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h1 id="double-layered-chocolate-fudge-cake">Double-layered Chocolate
Fudge Cake</h1>
<p>Here’s a delicious double-layered chocolate fudge cake that is
something of my mum’s speciality. It’s complicated and I should warn
that nobody 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>
<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 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 best one I have:</p>
<figure>
<img src="cake.jpg"
alt="picture of the Double-layered chocolate fudge cake" />
<figcaption aria-hidden="true">picture of the Double-layered chocolate
fudge cake</figcaption>
</figure>
<p>There are two sets of ingredients and instructions; the cake and the
icing. In addition there are some <strong>VERY IMPORTANT NOTES</strong>
to pay attention to; some will be repeated because they’re
<strong>VITALLY IMPORTANT</strong> for the quality of the cake. That
cannot be overstated.</p>
<p>Below I have included the ingredients separately but I include them
within the instructions as well and in bold. Also in bold are some of
the special notes.</p>
<p>Finally note that depending on where you are in the world this might
not work in the warmer months of the year and for the icing in
particular.</p>
<h2 id="measurements">Measurements</h2>
<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 just cooking) is <a
href="http://www.onlineconversion.com/cooking.htm"
class="uri">http://www.onlineconversion.com/cooking.htm</a>. This will
particularly matter for cups, teaspoons, tablespoons and ounces.</p>
<h2 id="bakers-chocolate">Baker’s chocolate</h2>
<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 called different things:</p>
<blockquote>
<p>Bitter chocolate contains no sugar and is often called ‘unsweetened’
or ‘baking’ chocolate. In some countries it’s called 100% cacao since
it’s composed only of ground up cocoa beans, and nothing else.</p>
</blockquote>
<p>The FAQ suggests that you might have to look for a baking supply shop
but I cannot offer any specific advice other than it’s unsweetened
chocolate bars for baking. The FAQ talks about what looks like
substitutes but I have no idea what that would turn out as; I somehow
suspect it wouldn’t be good.</p>
<p>Either way <strong>PLEASE STILL PAY ATTENTION TO ALL THE NOTES on the
chocolate IN THE RECIPE and RECIPE NOTES BECAUSE THEY’RE <em>EXTREMELY
IMPORTANT!</em></strong></p>
<h2 id="special-notes-for-the-cake">Special notes for the cake</h2>
<p><strong>PAY CLOSE ATTENTION TO THESE:</strong></p>
<ul>
<li><p><strong>USE <em>MARGARINE</em>! DO <em>NOT</em> USE
BUTTER!</strong> Butter does not work well. If you think it will come
out better by using butter you’re very mistaken; it will come out badly!
People have come back saying it didn’t come out well and they are asked
if they used butter or margarine. They had used butter because they
‘know better’ but they were very wrong and it is why the cake was
ruined.</p></li>
<li><p>Over the years they changed the size of the unsweetened chocolate
squares; they used to be one ounce each; now they are 1/4 ounce each
square so be sure to remember that <strong>THE AMOUNT IS BY OUNCE
<em>NOT SQUARES</em> AS LISTED</strong>. See the measurements link if
there’s any doubt.</p></li>
<li><p>Pay careful attention to the <strong>COOK FOR ONLY THE INDICATED
TIME</strong> part. Note that if your oven cooks a bit hotter you might
have to adjust the timing a bit. This is likely the case if the cake
comes out a little bit dry.</p></li>
<li><p><strong>REMOVE THE CAKE FROM THE PANS <em>2 MINUTES AFTER
REMOVING FROM OVEN</em></strong> and then allow to <strong>FULLY COOL
<em>ON RACKS!</em></strong> The important point is to <strong>MAKE SURE
THAT THEY <em>DON’T OVERCOOK</em></strong>.</p></li>
<li><p>When the recipe was first written they sold powdered sugar in a
box; now it’s confectionery sugar in a bag. My mum experimented with the
amount and found that 4 cups seems about right.</p></li>
<li><p><strong>USE <em>WHOLE MILK!</em></strong> Don’t try skim milk or
whatever per cent of fat milk you have.</p></li>
<li><p>Use <strong>ONLY <em>PURE</em> VANILLA EXTRACT!</strong>
<strong>DO <em>NOT USE IMITATION VANILLA!</em></strong> Not following
this rule will lead to a worse outcome.</p></li>
</ul>
<h2 id="cake-ingredients">Cake Ingredients</h2>
<ul>
<li>3 oz unsweetened (Baker’s) chocolate</li>
<li>2 and 1/4 cups flour</li>
<li>2 tbsp baking soda</li>
<li>1/2 tsp salt</li>
<li>2 and 1/4 cups packed brown sugar</li>
<li>3 eggs</li>
<li>1 and 1/2 tsp <strong>PURE VANILLA EXTRACT (<em>NOT IMITATION
VANILLA!</em>)</strong></li>
<li>1/2 cup <strong>MARGARINE (<em>NOT BUTTER!</em>)</strong></li>
<li>1 cup (boiling) water</li>
<li>1 cup sour cream</li>
</ul>
<h2 id="cake-preparation">Cake Preparation</h2>
<ol type="1">
<li><p>Lightly grease <strong>TWO 9 x 1.5 INCH ROUND PANS</strong>;
lightly dust with flour.</p></li>
<li><p>Preheat oven to <strong>350 F / 176.67 C</strong>.</p></li>
</ol>
<h2 id="cake-directions">Cake Directions</h2>
<ol type="1">
<li><p>Melt <strong>3 OZ UNSWEETENED CHOCOLATE</strong> in double boiler
or small bowl over <strong>hot (<em>BUT NOT BOILING</em>)
water</strong>; let cool whilst proceeding.</p></li>
<li><p>Sift <strong>2 and 1/4 CUPS FLOUR</strong>, <strong>2 TSP BAKING
SODA</strong>, and <strong>1/2 TSP SALT</strong></p></li>
<li><p>Beat <strong>1 STICK MARGARINE (<em>NOT BUTTER!</em>)</strong> in
large bowl <em>until soft</em>. Again <strong>MARGARINE, <em>NOT
BUTTER!</em></strong></p></li>
<li><p>Add <strong>2 and 1/4 CUPS PACKED BROWN SUGAR</strong> and
<strong>3 EGGS</strong>. Beat until light and fluffy.</p></li>
<li><p>Beat in <strong>1 1/2 TSP <em>PURE</em> VANILLA EXTRACT (<em>NOT
IMITATION VANILLA!</em>)</strong> and <strong><em>COOLED</em> MELTED
CHOCOLATE</strong>.</p></li>
<li><p>Stir in dry ingredients alternately with <strong>1 CUP SOUR
CREAM</strong>; always beat until smooth.</p></li>
<li><p>Stir in <strong>1 CUP <em>BOILING</em> WATER</strong>.</p></li>
<li><p>Pour into prepared pans.</p></li>
<li><p>Bake for <strong>ONLY 35 MINUTES</strong> (<strong>NO
LONGER!</strong>) at <strong>350 F / 176.67 C</strong>.</p></li>
<li><p>When you take the cake out put the cake pans on a cooling rack
for **_ONLY TWO MINUTES AND THEN <em>IMMEDIATELY TURN CAKES OUT ON TO
RACK</em><strong>. Let </strong>COOL <em>COMPLETELY!</em>**</p></li>
</ol>
<h2 id="icing-ingredients">Icing Ingredients</h2>
<ul>
<li>4 oz unsweetened chocolate (Baker’s chocolate)</li>
<li>1/2 cup <strong>MARGARINE (<em>NOT BUTTER!</em>)</strong></li>
<li>4 cups powdered sugar</li>
<li>1/2 cup whole milk</li>
<li>2 tsp <strong><em>PURE</em> VANILLA EXTRACT (<em>NOT IMITATION
VANILLA!</em>)</strong></li>
</ul>
<p>You will also need a bigger pan or bowl that can have ice water that
the icing bowl can sit in.</p>
<h2 id="special-notes-for-the-icing">Special notes for the icing</h2>
<p><strong>PAY CLOSE ATTENTION TO THESE:</strong></p>
<ul>
<li><p><strong>MAKE SURE</strong> that the melted chocolate and
<strong>MARGARINE (<em>NOT BUTTER!</em>)</strong> do not get
solid.</p></li>
<li><p>For step #4 put <strong>8 to 10 ICE CUBES</strong> in a pan or
big bowl (that’s big enough that another bowl can fit in it).
<strong>ADD AN INCH OF WATER</strong> and <strong>SET THE BOWL WITH THE
ICING IN THE PAN OR BOWL</strong> of ice water. <strong>DO NOT LET THE
ICING GET WET!</strong></p></li>
<li><p><strong>DO NOT LET ICING GET TOO THICK.</strong></p></li>
<li><p><strong>USE <em>WHOLE MILK!</em></strong> Don’t try skim milk or
whatever per cent of fat milk you have.</p></li>
<li><p>Use <strong>ONLY PURE VANILLA EXTRACT</strong>! <strong>DO NOT
USE IMITATION VANILLA!</strong> Not following this rule will lead to a
worse outcome. As I recall the icing was quite a bit worse (but still
chocolaty at least) the times we had imitation vanilla (simply because
we couldn’t get pure vanilla at the time we needed it). Just don’t do
it.</p></li>
</ul>
<h2 id="icing-directions">Icing Directions</h2>
<ol type="1">
<li><p>Combine <strong>4 OZ UNSWEETENED CHOCOLATE</strong> and
<strong>1/2 CUP <em>MARGARINE (NOT BUTTER!)</em></strong> in pan. Melt
and remove from heat. <strong>DO NOT LET IT GET SOLID!</strong></p></li>
<li><p>Combine <strong>3 1/4 CUPS POWDERED SUGAR</strong>, <strong>1/2
CUPS WHOLE MILK</strong> and <strong>2 TSP </strong><em>PURE</em>
VANILLA EXTRACT (<em>NOT IMITATION VANILLA!</em>)** into a bowl.
<strong>STIR UNTIL SMOOTH</strong>.</p></li>
<li><p>Add chocolate mixture.</p></li>
<li><p>Set bowl in pan/bowl of ice and water. Beat with spoon/mixer
until it’s thick BUT not too thick. <strong>Make <em>SURE</em> ICING
DOES <em>NOT</em> GET WET!</strong> The idea is to <strong>MAKE THE BOWL
IT’S IN COLD <em>BUT TO NOT LET THE ICING GET
WET!</em></strong></p></li>
</ol>
<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<tbody>
<tr class="odd">
<td>(c) Copyright 1984-2020, [Leo Broukhis, Simon Cooper, Landon Curt
Noll][judges] - All rights reserved This work is licensed under a
[Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].</td>
</tr>
<tr class="even">
<td>[judges]: https://www.ioccc.org/judges.html [cc]:
http://creativecommons.org/licenses/by-sa/3.0/</td>
</tr>
</tbody>
</table>
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/end-row.default.html -->
</div>
<!-- END: this line ends content from: inc/end-row.default.html -->
<!-- START: this line starts content from: inc/footer.default.html -->
<div class="footer">
<hr>
<h2>Coda</h2>
<p><a href="https://validator.w3.org/nu/?doc=#">Nu HTML check this web page</a></p>
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
</div>
<!-- END: this line ends content from: inc/footer.default.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->
+244
View File
@@ -0,0 +1,244 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- -->
<!-- The original markdown content was formed by the tool: bin/gen-other-html.sh -->
<!-- The HTML was converted from markdown by the tool: bin/md2html.sh -->
<!-- -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>The International Obfuscated C Code Contest</title>
<meta name="description" content="crazy.log.md for 2020/ferguson1">
<meta name="keywords" content="IOCCC, 2020/ferguson1, crazy.log.md">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<img src="../../png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
<h1>The International Obfuscated C Code Contest</h1>
<h2>crazy.log.md for 2020/ferguson1</h2>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.up2index.html -->
<div class="topnav">
<a class="Left" href="index.html">&uarr; jump to index.html &uarr;</a>
</div>
<!-- END: this line ends content from: inc/topnav.up2index.html -->
<!-- START: this line starts content from: inc/begin-row.default.html -->
<div class="row">
<!-- END: this line ends content from: inc/begin-row.default.html -->
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
<div class="leftcolumn">
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/sidenav.default.html -->
<div class="sidenav">
<a href="#content">Jump to contents</a>
</div>
<hr>
<div class="sidenav">
<a href="../../index.html">IOCCC Home</a>
<a href="../../years.html">Winning Entries</a>
<a href="../../authors.html">People who have won</a>
</div>
<hr>
<div class="sidenav">
<a href="../../news.html">IOCCC News</a>
<a href="../../faq.html#submit">How to enter the IOCCC</a>
<a href="../../faq.html">FAQ</a>
</div>
<hr>
<div class="sidenav">
<a href="../../bugs.html">Bugs &amp; (mis)features</a>
<a href="../../faq.html#fix_an_entry">Fixing IOCCC entries</a>
<a href="../../faq.html#fix_web_site">Fixing the web site</a>
<a href="../../faq.html#fix_author">Fixing author info</a>
<a href="../../thanks-for-help.html">Thanks for the help</a>
</div>
<hr>
<div class="sidenav">
<a href="../../judges.html">The IOCCC Judges</a>
<a href="../../contact.html">Contacting the IOCCC</a>
</div>
<hr>
<div class="sidenav">
<a href="#top">Jump to top</a>
</div>
<!-- END: this line ends content from: inc/sidenav.default.html -->
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
<div class="rightcolumn">
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<a name="content"></a>
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<p>The following are a few screen dumps of:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>100 <span class="va">SHEDS</span><span class="op">=</span>5 <span class="va">GROW</span><span class="op">=</span>-10 <span class="va">SHED</span><span class="op">=</span>50 <span class="va">MAXSIZE</span><span class="op">=</span>250 <span class="ex">./prog</span></span></code></pre></div>
<p>As you will see it took 17 bugs to get down to below 0. Notice how I
had to get down to 0 more than once: because I moved enough times before
I got the last bug that I grew by 5 in size. I then however moved a bit
more and ate a bug which brought me down to -5 therefore winning at the
max size of 250. This then showed:</p>
<pre><code>YOU WIN!
X:62/89 Y:5/25 S:250/250 B:17</code></pre>
<p>Observe all the arrows on the screen; that’s where a bug was that I
ate and then I split off losing 10 in size. The first dump I’m already
at 15/250:</p>
<pre><code>X:17/89 Y:15/25 S:15/250 B:13
##########################################################################################
# &lt;ooooooooo o &lt;ooooooooo* #
# o o&gt; #
# o ooo oooo #
# o o ooooooooo&gt; o v #
# o o oo o #
# o o o o #
# o o o o #
# &lt;oo o o o #
# o #
# o o #
# o o #
# o o o #
# &lt;ooo o oooooooo&gt; #
# &lt;oooooooooooooo o o #
# o o #
# o o #
# &lt; ooo o o #
# o o #
# o v #
# oooooo&gt; #
# o #
# o o&gt; #
# oooooo #
##########################################################################################</code></pre>
<p>But here now I’m at 0; the head is marked <code>H</code> and it’s
moving left.</p>
<pre><code>X:19/89 Y:12/25 S:0/250 B:16
##########################################################################################
# &lt;ooooooooo o &lt;oooooooo &lt;ooooooo #
# o o&gt; oo #
# o ooo oooo #
# o o oooooo*oo&gt; v #
# o o oo o oo&gt; #
# o o o o oo #
# o o o oooo #
# &lt;oo o o o #
# o #
# o o #
# H o o # &lt;- *HEAD, LEFT*
# o o o #
# &lt;ooo o oo ooooo&gt; #
# o o #
# o o #
# o o #
# &lt; ooo o #
# o o #
# &lt;oooooooo o v #
# oooooo&gt; #
# o #
# o o&gt; #
# oooooo #
##########################################################################################</code></pre>
<p>I ended up moving enough times where my size went back up to 5.</p>
<p>Below the snake is moving right and its head is indicated by a
<code>H</code> with the line marked at the right; the bug is marked as
<code>B</code> and is also marked at the right. Notice how it’s in the
body of the snake (but see below)!</p>
<pre><code>X:55/89 Y:4/25 S:5/250 B:16
##########################################################################################
# &lt;ooooooooo o &lt;oooooooo &lt;ooooooo #
# o o&gt; oo #
# ooooH oooo # &lt;- *HEAD, RIGHT*
# o o ooooooBoo&gt; v # &lt;- *BUG*
# o o oo o oo&gt; #
# o o o o oo #
# o o o oooo #
# &lt;oo o o o #
# o #
# o o #
# o o #
# o o o #
# &lt;ooo o oo ooooo&gt; #
# o o #
# o o #
# o o #
# &lt; ooo o #
# o o #
# &lt;oooooooo o v #
# oooooo&gt; #
# o #
# o o&gt; #
# oooooo #
##########################################################################################</code></pre>
<p>But did you see anything strange? The bug is on the fourth line below
the upper wall. However it appears to be inside the body of the snake!
But actually that’s just where the snake split off at some point: the
snake no longer occupies that place and indeed I could safely go through
that part of the screen.</p>
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/end-row.default.html -->
</div>
<!-- END: this line ends content from: inc/end-row.default.html -->
<!-- START: this line starts content from: inc/footer.default.html -->
<div class="footer">
<hr>
<h2>Coda</h2>
<p><a href="https://validator.w3.org/nu/?doc=#">Nu HTML check this web page</a></p>
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
</div>
<!-- END: this line ends content from: inc/footer.default.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->
+879
View File
@@ -0,0 +1,879 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- -->
<!-- The original markdown content was formed by the tool: bin/gen-other-html.sh -->
<!-- The HTML was converted from markdown by the tool: bin/md2html.sh -->
<!-- -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>The International Obfuscated C Code Contest</title>
<meta name="description" content="gameplay.md for 2020/ferguson1">
<meta name="keywords" content="IOCCC, 2020/ferguson1, gameplay.md">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<img src="../../png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
<h1>The International Obfuscated C Code Contest</h1>
<h2>gameplay.md for 2020/ferguson1</h2>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.up2index.html -->
<div class="topnav">
<a class="Left" href="index.html">&uarr; jump to index.html &uarr;</a>
</div>
<!-- END: this line ends content from: inc/topnav.up2index.html -->
<!-- START: this line starts content from: inc/begin-row.default.html -->
<div class="row">
<!-- END: this line ends content from: inc/begin-row.default.html -->
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
<div class="leftcolumn">
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/sidenav.default.html -->
<div class="sidenav">
<a href="#content">Jump to contents</a>
</div>
<hr>
<div class="sidenav">
<a href="../../index.html">IOCCC Home</a>
<a href="../../years.html">Winning Entries</a>
<a href="../../authors.html">People who have won</a>
</div>
<hr>
<div class="sidenav">
<a href="../../news.html">IOCCC News</a>
<a href="../../faq.html#submit">How to enter the IOCCC</a>
<a href="../../faq.html">FAQ</a>
</div>
<hr>
<div class="sidenav">
<a href="../../bugs.html">Bugs &amp; (mis)features</a>
<a href="../../faq.html#fix_an_entry">Fixing IOCCC entries</a>
<a href="../../faq.html#fix_web_site">Fixing the web site</a>
<a href="../../faq.html#fix_author">Fixing author info</a>
<a href="../../thanks-for-help.html">Thanks for the help</a>
</div>
<hr>
<div class="sidenav">
<a href="../../judges.html">The IOCCC Judges</a>
<a href="../../contact.html">Contacting the IOCCC</a>
</div>
<hr>
<div class="sidenav">
<a href="#top">Jump to top</a>
</div>
<!-- END: this line ends content from: inc/sidenav.default.html -->
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
<div class="rightcolumn">
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<a name="content"></a>
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<p>Playing the game is very simple but because there are many different
modes I 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 for the input keys.</p>
<p><a name="toc"></a></p>
<ol type="1">
<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="#gameplay">Gameplay</a></p>
<ul>
<li><p><a href="#initial">The initial screen</a></p></li>
<li><p><a href="#playing">Playing the game</a></p></li>
<li><p><a href="#walls">Walls</a></p></li>
<li><p><a href="#cannibalism">Cannibalism</a></p></li>
<li><p><a href="#shedding">Stretching (shedding)</a></p></li>
<li><p><a href="#winning">Winning</a></p></li>
<li><p><a href="#quitting">Quitting</a></p></li>
</ul></li>
<li><p><a href="#modes">Gameplay modes</a></p>
<ul>
<li><p><a href="#warning"><strong>Photosensitive epilepsy/Stimulation
overload trigger warnings</strong></a></p></li>
<li><p><a href="#drawing">Drawing / Practice mode</a></p></li>
<li><p><a href="#auto">Computer playing / Automatic mode
(<strong>Photosensitive epilepsy/Stimulation overload
trigger</strong>)</a></p>
<ul>
<li><a href="#auto-variations">Variations</a></li>
</ul></li>
<li><p><a href="#grow-shrink">Grow-Shrink (Positive/Negative Winning)
mode</a></p></li>
<li><p><a href="#hypnotic">Hypnotic / Sleepy mode
(<strong>Photosensitive epilepsy/Stimulation overload
trigger</strong>)</a></p></li>
<li><p><a href="#stim">Stimulation / Calming mode</a></p></li>
<li><p><a href="#other-ideas">Other ideas</a></p></li>
</ul></li>
<li><p><a href="#scripts">Scripts</a></p>
<ul>
<li><p><a href="#colours">Colours selection</a></p></li>
<li><p><a href="#preset">Automate the above gameplay modes</a></p></li>
</ul></li>
<li><p><a href="#variables">Other game variables</a></p>
<ul>
<li><p><a href="#wait">WAIT - Snake speed</a></p></li>
<li><p><a href="#evade">EVADE - Bug evasion frequency</a></p></li>
<li><p><a href="#sizes">SIZE / MAXSIZE - Initial snake / max
sizes</a></p></li>
<li><p><a href="#growth">GROW / SHEDS - Growth / Shedding
sizes</a></p></li>
</ul></li>
<li><p><a href="#conclusions">Conclusion (and inspirational words for
everyone)</a></p></li>
</ol>
<h1 id="testing-terminal-environmentcapabilities">1.
<a name="support" href="#toc">Testing terminal
environment/capabilities</a></h1>
<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 GitHub) file for more
information on the terminal capabilities testing utility I include.</p>
<p>For troubleshooting other problems see <a
href="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>
<h1 id="input-keys">2. <a name="input" href="#toc">Input keys</a></h1>
<ul>
<li><p>Left, right, up and down <strong>arrow keys</strong>: move that
direction.</p></li>
<li><p><code>q</code> (and <code>Q</code>): quit the game.</p></li>
<li><p>Space: pause/resume the game (direction keys will also resume).
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 you pressed the current direction key (assuming you
already moved the snake).</p></li>
</ul>
<h1 id="gameplay">3. <a name="gameplay" href="#toc">Gameplay</a></h1>
<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 selection</a>. You can also jump to <a
href="#modes">gameplay modes</a> or <a href="#variables">game
variables</a>.</p>
<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>
<h2
id="gameplay-the-initial-screen"><a name="initial" href="#toc">Gameplay:
The initial screen</a></h2>
<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 1 and the left wall is column 0. Below I use the
coordinates in the X/Y order (ncurses is the opposite: Y/X). I will
parenthesise the numbers below to refer to the number in the
diagram:</p>
<pre><code>X:24/49 Y:8/16 S:5/658 B:0
##################################################
# #
# #
# #
# #
# #
# #
# + #
# #
# * #
# #
# #
# #
# #
# #
##################################################
</code></pre>
<ul>
<li><p>The snake (<code>+</code>) is at (24),(8). The bug char is
<code>*</code> and the wall char is <code>#</code>. When the snake moves
the head will be an arrow facing the direction it is moving; the body is
‘o’.</p></li>
<li><p>The top wall is always line (1), the left wall is always column
(0), the bottom wall is line (16) and the right wall is column (49). If
walls are impassable and you run into any of these the game is over (you
can slither at the edge of the wall); else you’ll come out the opposite
side.</p></li>
<li><p>The snake size is (5): but until you start to move it’s
technically 1 (even if you set <strong>SIZE=0</strong> this applies).
This is so that you can decide which direction from the centre of the
screen. By default the head colour is red; the body is green. The snake
will grow by one until it reaches the right size.</p></li>
<li><p>The maximum snake size is (997): this is the default; it can be
changed but it will always have an upper limit depending on the terminal
size.</p></li>
<li><p>The number of bugs eaten so far is 0.</p></li>
</ul>
<h2
id="gameplay-playing-the-game"><a name="playing" href="#toc">Gameplay:
Playing the game</a></h2>
<pre><code>X:39/49 Y:8/16 S:5/658 B:0
##################################################
# #
# #
# #
# #
# #
# #
# oooo&gt; #
# #
# * #
# #
# #
# #
# #
# #
##################################################</code></pre>
<p>I let the snake grow to its full size (with the head at (39),(8)) and
I’m two places above the bug so let’s go down:</p>
<pre><code>X:39/49 Y:9/16 S:5/658 B:0
##################################################
# #
# #
# #
# #
# #
# #
# oooo #
# v #
# * #
# #
# #
# #
# #
# #
##################################################</code></pre>
<p>Now you see that the snake is going down and in one move the bug will
be eaten. Let’s do that:</p>
<pre><code>X:36/49 Y:10/16 S:10/658 B:1
##################################################
# #
# #
# #
# * #
# #
# #
# #
# #
# ^ o #
# oooo #
# #
# #
# #
# #
##################################################</code></pre>
<p>Observe that the bug was eaten and a new bug spawned elsewhere. I
went left three and then up one and could slither on to the bug.</p>
<h1 id="gameplay-walls"><a name="walls" href="#toc">Gameplay:
Walls</a></h1>
<p>By default walls are passable (<strong>WALLS=1</strong>). Let’s get
to full size and go through the top wall:</p>
<pre><code>X:36/49 Y:15/16 S:10/658 B:1
##################################################
# o #
# o #
# o #
# * o #
# o #
# o #
# o #
# o #
# o #
# #
# #
# #
# #
# ^ #
##################################################</code></pre>
<p>There you can see I have grown to the full size and went through the
top wall; the head is now at the opposite wall. Continuing:</p>
<pre><code>X:36/49 Y:11/16 S:10/658 B:1
##################################################
# o #
# o #
# o #
# * o #
# o #
# #
# #
# #
# #
# ^ #
# o #
# o #
# o #
# o #
##################################################</code></pre>
<p>I might then have turned to the left and then shortly go up to get
the bug. This goes on until you lose, quit or win the game.</p>
<p>When you specify <strong>WALLS=0</strong> the walls become an
obstacle that end the game. It might look like (I set the starting size
to 150 and had only just started):</p>
<pre><code>X:20/49 Y:2/16 S:150/658 B:0
##################################################
# ^ #
# o #
# o * #
# o #
# o #
# o #
# ooooo #
# #
# #
# #
# #
# #
# #
# #
##################################################</code></pre>
<p>If I continue going up I will see:</p>
<pre><code>OUCH!
X:20/49 Y:1/16 S:150/658 B:0</code></pre>
<h1
id="gameplay-cannibalism"><a name="cannibalism" href="#toc">Gameplay:
Cannibalism</a></h1>
<p>By default cannibalism is disabled (<strong>CANNIBAL=0</strong>) so
if you run into yourself it might look something like:</p>
<pre><code>X:45/49 Y:10/16 S:10/658 B:1
##################################################
# #
# #
# #
# * #
# #
# #
# #
# ooooo #
# ^ o #
# ooo #
# #
# #
# #
# #
##################################################</code></pre>
<p>If I were to do any movement but turn to the left I would run into
myself. I’ll go to the right two spaces:</p>
<pre><code>OW!
X:47/49 Y:10/16 S:10/658 B:1</code></pre>
<p>But <strong>CANNIBAL=1</strong> can look very funny both in movement
and still especially when you go through yourself several times when the
snake is rather long. For example going through walls and the snake a
few times:</p>
<pre><code>X:4/49 Y:12/16 S:165/658 B:3
##################################################
#oo o ooooo o o o#
# oooo o ooo o#
# ooooooooooooooooooo#
# o #
# oooooooooo o #
# o o o #
# o oooo o o #
# o o o o #
# ooooooooooooooo #
# o o* #
# oo&gt; o o #
# o oooooooo o #
#oooooooooooooo o oooo oooooooo#
# o o o o o #
##################################################</code></pre>
<p>I’ll go back through myself now:</p>
<pre><code>X:6/49 Y:14/16 S:165/658 B:3
##################################################
#oo o ooooo o o o#
# oooo o ooo o#
# ooooooooooooooooooo#
# o #
# oooooooooo o #
# o o o #
# o oooo o o #
# o o o o #
# ooooooooooooooo #
# o o* #
# ooo o o #
# oo oooooooo o #
#ooooo&gt;oooooooo o oooo oooooooo#
# o o o o o #
##################################################</code></pre>
<p>If you note that the head is at (6),(14) I will go one more to the
right and you will see that the arrow has moved over:</p>
<pre><code>X:7/49 Y:14/16 S:165/658 B:3
##################################################
#oo o ooooo o o o#
# oooo o ooo o#
# ooooooooooooooooooo#
# o #
# oooooooooo o #
# o o o #
# o oooo o o #
# o o o o #
# ooooooooooooooo #
# o o* #
# ooo o o #
# oo oooooooo o #
#oooooo&gt;ooooooo o oooo oooooooo#
# o o o o o #
##################################################</code></pre>
<p>Try this: get a reasonable length and then go back on yourself (if
you’re going left go right etc.) and then after some length (but before
you get beyond the snake) turn (so that you go perpendicular) and then
watch as the snake starts 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> (<a
href="cannibalism.log.md">cannibalism.log.md</a> on GitHub) file. It
explains information about the file 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 inside itself.</p>
<h1
id="gameplay-shedding-stretching"><a name="shedding" href="#toc">Gameplay:
Shedding (stretching)</a></h1>
<p>This feature will make you grow by the value of
<strong><code>SHEDS</code></strong> for every
<strong><code>SHED</code></strong> movements (the counter isn’t
incremented when you eat a bug). Basically growing without eating a bug
(stretching would be better name here).</p>
<h1 id="gameplay-winning"><a name="winning" href="#toc">Gameplay:
Winning</a></h1>
<p>If you ever get to the <strong><code>MAXSIZE</code></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 default) or setting the size to higher
than the default (or &lt; 0 which will end up being &gt; the max size
though I suppose there might be some value that makes it less than again
- I’m not going to try and figure that out however). Anyway:</p>
<div class="sourceCode" id="cb14"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>-1 <span class="ex">./prog</span></span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="ex">YOU</span> WIN!</span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a><span class="ex">X:24/49</span> Y:8/16 S:658/658 B:0</span></code></pre></div>
<p>Observe that the size isn’t the default 997: because the screen size
is too small for that value (see <a
href="terminals.md">terminals.md</a>).</p>
<p>The reason I chose 997 is that it leaves a bit of a challenge for
some (maybe 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 win without any cheat mode enabled on my
24” monitor but I probably would need at least one cheat mode on my 16”
laptop (I don’t need both enabled). I don’t think I need either for
997.</p>
<p>The beauty though is the game can be winnable by anyone since you can
define the max size to win. Games are meant to be fun: who enjoys games
that can never be won? Very few probably do and those who do enjoy them
it probably are games that are relaxing and stimulating (which
admittedly this game can be - but still I want it to be winnable
too).</p>
<p>Another reason I chose 997: it’s prime and the judges love prime
numbers. Actually, this is the main reason for the number: I had changed
it down to 1000 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 the default starting size and growth
size of 5 the number of bugs needed before the game is won is 199 - also
a prime!</p>
<h1 id="gameplay-quitting"><a name="quitting" href="#toc">Gameplay:
Quitting</a></h1>
<p>If you wish to quit you can hit ‘q’ (case-insensitive). For
example:</p>
<pre><code>X:24/49 Y:8/16 S:5/658 B:0</code></pre>
<h1 id="gameplay-modes">4. <a name="modes" href="#toc">Gameplay
modes</a></h1>
<p>Here I list a number of different modes of play. In the <a
href="bugs.html">bugs.html</a> (<a href="bugs.md">bugs.md</a> on GitHub)
file I even show how there’s a built-in test unit for some 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 thought of by a chance; others were thought out from the
beginning but were improved over time.</p>
<p>The <a href="play.sh">play.sh</a> script sets up some of these
automatically; I describe it after the modes below.</p>
<h2
id="photosensitive-epilepsystimulation-overload-trigger-warnings"><a name="warning" href="#toc">Photosensitive
epilepsy/Stimulation overload trigger warnings</a></h2>
<p>If you have <strong>photosensitive epilepsy please be
careful</strong> especially with low values for both
<strong><code>WAIT</code></strong> and
<strong><code>EVADE</code></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 easily can be in the range.</p>
<p>There are different patterns and lights flashing at different speeds
so please exercise caution. This could trigger seizures and <strong>it
might also be too much stimulation for some people.</strong></p>
<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>
<h2
id="gameplay-mode-drawing-practice-mode"><a name="drawing" href="#toc">Gameplay
mode: Drawing / Practice mode</a></h2>
<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 &lt;
0): then the snake does not move until you press a movement key. For
example:</p>
<div class="sourceCode" id="cb16"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="va">WAIT</span><span class="op">=</span>-1 <span class="ex">./prog</span></span></code></pre></div>
<p>When you eat a bug the snake will grow and you can draw more. If you
want to make it so you can go through yourself:</p>
<div class="sourceCode" id="cb17"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="va">WAIT</span><span class="op">=</span>-1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
<p>If you don’t want to start out so small (i.e. you want to be able to
draw more quickly) you can just set the size to a bigger number (and you
could do the same with growth and moult/shed):</p>
<div class="sourceCode" id="cb18"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>50 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">WAIT</span><span class="op">=</span>-1 <span class="ex">./prog</span></span></code></pre></div>
<p>Do note that although you’re a bigger size you still grow one
movement at a time.</p>
<p>Okay but then if you get too many bugs the drawing will be over. If
this proves to be a problem simply do:</p>
<div class="sourceCode" id="cb19"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>100 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">WAIT</span><span class="op">=</span>-1 <span class="va">GROW</span><span class="op">=</span>0 <span class="ex">./prog</span></span></code></pre></div>
<p>Or something like that (maybe make the size bigger but that’s up to
you). You could also set the max size to be the highest possible by
saying</p>
<div class="sourceCode" id="cb20"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="va">MAXSIZE</span><span class="op">=</span>-1</span></code></pre></div>
<p>Which I’ve done in the <a href="play.sh">play.sh</a> script.</p>
<p>I discuss how this mode works in [spoilers.markdown][].</p>
<p>Here’s an example run where I spelt ‘SNAKE’. As you can see it’s far
from perfect: the snake after all does not leave gaps and the game does
not support diagonal movement and I also made a mistake and had to
modify what I was aiming for. But you can consider this mode drawing or
practice mode.</p>
<pre><code> oooooooooo ooooo o oo ooooo
o o oo o oo o ooo o
oooo o oo ooooooo oooo ooooo
o o ooo oo o ooo o
oooo o oo ooo oooooooo&gt; </code></pre>
<h2
id="gameplay-mode-computer-playing-automatic-mode-photosensitive-epilepsystimulation-overload-trigger"><a name="auto" href="#toc">Gameplay
mode: Computer playing / Automatic mode (Photosensitive
epilepsy/Stimulation overload trigger)</a></h2>
<p><strong>Photosensitive epilepsy/stimulation overload trigger
warning:</strong> For those who have epilepsy or are susceptible to
stimulation overload from flashing lights please do be careful with this
mode. Depending on your susceptibility this could very well trigger
seizures or other discomforts and I wouldn’t want that to happen to
anyone. This mode has a lot of flashing of different colours and
depending on the exact parameters you specify it could easily be in the
trigger range for epilepsy but potentially stimulation overload too.</p>
<p>If you’re still here you can create this effect like:</p>
<div class="sourceCode" id="cb22"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a><span class="va">WAIT</span><span class="op">=</span>0 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
<p>As long as the bug evades you’ll find that the snake is growing
because it’s actually eating bugs; the computer is actually playing the
game by itself! You can still move the snake though it won’t seem like
you have much control over it. If you pause the game you can see that
it’s bigger (you probably will be able to even without pausing it).</p>
<p>Basically the snake is moving so fast that because the bug evades the
bug will inevitably move in the snake path’s and therefore be eaten.</p>
<p>You might find it goes quicker if you set the evade count to a lower
value for example 1. Or you might not. But as long as the bug moves the
computer can play by itself.</p>
<p>Quick tests suggest that bigger dimensions it gets bigger quicker.
But it also 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 so with fewer available it has a harder time
finding a place in that one line.</p>
<h3
id="computer-player-variations"><a name="auto-variations" href="#toc">Computer
player variations</a></h3>
<p>Here’s how to make the bug move every time the snake moves:</p>
<div class="sourceCode" id="cb23"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">WAIT</span><span class="op">=</span>0 <span class="va">EVADE</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
<h4 id="help-the-computer-win-fairly-quickly">Help the computer win
fairly quickly</h4>
<p>If you want to see the game ‘win’ try something like:</p>
<div class="sourceCode" id="cb24"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">WAIT</span><span class="op">=</span>0 <span class="va">EVADE</span><span class="op">=</span>1 <span class="va">MAXSIZE</span><span class="op">=</span>10 <span class="ex">./prog</span></span></code></pre></div>
<h4 id="negative-growth-shrink-automatic-mode">Negative growth (Shrink)
Automatic mode</h4>
<p>Here’s a fun one I just thought of (a long time after these other
modes were thought of):</p>
<div class="sourceCode" id="cb25"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a><span class="va">WAIT</span><span class="op">=</span>0 <span class="va">EVADE</span><span class="op">=</span>1 <span class="va">GROW</span><span class="op">=</span>-1 <span class="va">SIZE</span><span class="op">=</span>9 <span class="va">MAXSIZE</span><span class="op">=</span>10 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
<p>What you’ll see is that first the snake will get to the size of 9 -
whether it shows to be 10 characters depends on whether or not it gets a
bug before it can get to that length - and then it’ll start shrinking
until it’s just the head then the head again (i.e. 1 then 0 in size) and
then win! This is also in the <a href="play.sh">play.sh</a> script.</p>
<h4 id="adjusting-the-timespeed">Adjusting the time/speed</h4>
<p>Of course you can also do something like:</p>
<div class="sourceCode" id="cb26"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a><span class="va">WAIT</span><span class="op">=</span>5 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
<p>Which although might not seem like it is significantly slower.</p>
<h4 id="moving-the-snake-about-to-create-patterns">Moving the snake
about to create patterns</h4>
<p>If you press different direction keys in some pattern you will see a
pattern form too (entirely dependent on how fast you react, what keys
you press and I suppose also how much the bug moves and the chance of
being eaten also).</p>
<h4 id="other-ideas">Other ideas</h4>
<p>Here’s an idea: how many moves is needed to make it possible to have
some sort of success in catching bugs? Obviously the dimensions will
affect this value.</p>
<p>How long will it take for the snake to run into itself? For instance
by doing:</p>
<div class="sourceCode" id="cb27"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a><span class="va">WAIT</span><span class="op">=</span>0 <span class="ex">./prog</span></span></code></pre></div>
<p>On my 13” MacBook Pro (replaced later by a 16”) at the default
settings going horizontally the snake ran into itself at:</p>
<pre><code>OW!
X:57/156 Y:20/41 S:155/997 B:30</code></pre>
<p>What if you set the size to a high value? The lowest? There are bound
to be other games to play with this feature!</p>
<h2
id="gameplay-mode-grow-shrink-mode-positive-and-negative-winning"><a name="grow-shrink" href="#toc">Gameplay
mode: Grow-Shrink mode (Positive and Negative Winning)</a></h2>
<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 or growing to the full size directly. This is how it
works:</p>
<p>You have a negative shedding growth and a positive growth size:
negative and positive winning. Depending on the parameters specified it
might go one way over the other. Try:</p>
<div class="sourceCode" id="cb29"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>150 <span class="va">SHEDS</span><span class="op">=</span>-5 <span class="va">GROW</span><span class="op">=</span>10 <span class="va">SHED</span><span class="op">=</span>50 <span class="va">MAXSIZE</span><span class="op">=</span>250 <span class="ex">./prog</span></span></code></pre></div>
<p>What this does is set the size to 150 (to make it not go down so
quickly) and then for each bug you eat it adds 5 to the size; for every
50 moves (that you don’t get the bug) you shrink by 5. You will find
that at times you might only decrease in size but then at other times -
depending on size of screen and how lucky you are with where the bug is
relative to where it last was - you might be growing. Combining this
with the drawing mode could be interesting but I never actually tried
it.</p>
<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 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
dumps with this idea.</p>
<p>You could also have it so that eating a bug makes you shrink and
moving so many moves you grow. I tried this and for me it was far more
fun. The <a href="play.sh">play.sh</a> also has this mode:</p>
<div class="sourceCode" id="cb30"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb30-1"><a href="#cb30-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>100 <span class="va">SHEDS</span><span class="op">=</span>5 <span class="va">GROW</span><span class="op">=</span>-10 <span class="va">SHED</span><span class="op">=</span>50 <span class="va">MAXSIZE</span><span class="op">=</span>250 <span class="ex">./prog</span></span></code></pre></div>
<p>Obviously there are many other variations. The <a
href="play.sh">play.sh</a> script has some of them (the above is option
5; others are 4, 15 and 16 but only options 4 and 5 are called Grow /
Shrink).</p>
<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>
<p><strong>Photosensitive epilepsy/stimulation overload trigger
warning:</strong> 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 susceptibility this could very
well trigger seizures or other discomforts and I wouldn’t want that to
happen to anyone. The default wait time is 231ms, the typical range of
seizures is 3 to 30 flashes per seconds (but can be higher) and that
means that at <strong>EVADE=1</strong> every 231ms there will be a flash
in addition to the snake moving too.</p>
<p>Anyway this might sound absurd but it can be somewhat hypnotic by
doing:</p>
<div class="sourceCode" id="cb31"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb31-1"><a href="#cb31-1" aria-hidden="true" tabindex="-1"></a><span class="va">EVADE</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
<p>And just moving the snake about not trying to catch any bugs - just
let whatever happens happen.</p>
<h2
id="gameplay-mode-stimulation-calming-mode"><a name="stim" href="#toc">Gameplay
mode: Stimulation / Calming mode</a></h2>
<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 the growth size to 0 and then just move the snake
round and round eating bugs until you want to quit. You can enable
cannibalism so that you don’t have to worry about even running into
yourself and losing:</p>
<div class="sourceCode" id="cb32"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb32-1"><a href="#cb32-1" aria-hidden="true" tabindex="-1"></a><span class="va">GROW</span><span class="op">=</span>0 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
<h2
id="gameplay-mode-expansibility"><a name="expansibility" href="#toc">Gameplay
mode: Expansibility</a></h2>
<p>As I was writing this document and the game modes I have thought of
other game modes (they were added) and I have come back to this document
to add more modes. That’s the beauty of the variables I have
implemented: together with the imagination and even just chance
different modes of play can be devised. The drawing mode was a happy
chance of how the <code>timeout()</code> function works for example.</p>
<p>As a person who was heavily involved in MUD development and design I
know very well how games need to be fun and have different options, not
be too easy but 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 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>
<h1 id="scripts">5. <a name="scripts" href="#toc">Scripts</a></h1>
<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>
<h2
id="colours-selection-snake-colours"><a name="colours" href="#toc">Colours
selection: snake-colours</a></h2>
<p>To do this use the <a href="snake-colours">snake-colours</a> script
like so:</p>
<div class="sourceCode" id="cb33"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb33-1"><a href="#cb33-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./snake-colours</span></span></code></pre></div>
<p>If you want to pass in specific variables you can do that too
e.g.:</p>
<div class="sourceCode" id="cb34"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb34-1"><a href="#cb34-1" aria-hidden="true" tabindex="-1"></a><span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="ex">./snake-colours</span></span></code></pre></div>
<p>The script will prompt you for the colour of the walls, snake head,
body and the bug.</p>
<h2
id="automate-the-above-gameplay-modes"><a name="preset" href="#toc">Automate
the above gameplay modes</a></h2>
<p>The <a href="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). 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 snake-colours above) and then
gives you a list of game modes to play. You can pass in the game
variables but note that if you pass in a variable that the mode you
choose uses then the script will override what you pass in.</p>
<p>To use you can do something like:</p>
<div class="sourceCode" id="cb35"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb35-1"><a href="#cb35-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./play.sh</span></span></code></pre></div>
<p>Or to make it so walls are an obstacle:</p>
<div class="sourceCode" id="cb36"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb36-1"><a href="#cb36-1" aria-hidden="true" tabindex="-1"></a><span class="va">WALLS</span><span class="op">=</span>0 <span class="ex">./play.sh</span></span></code></pre></div>
<h1 id="notes-about-some-of-the-game-variables">6.
<a name="variables" href="#toc">Notes about some of the game
variables</a></h1>
<p>The game variables can be used for a variety of things including
different gameplay modes (as shown above) but here are some general
notes about a few of them.</p>
<h2 id="wait-snake-speed"><a name="wait" href="#toc">WAIT: Snake
speed</a></h2>
<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 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>
<p>For every <strong><code>EVADE</code></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 all.</p>
<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>
<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>
<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 time but quickly. It might be in conjunction
with drawing mode.</p>
<p>Note on snake size: there’s a stated size (in the score line) which
is what the snake will ‘populate’ in the snake arrays and the visible
size: as I have 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 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>
<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>
<h1 id="conclusion-and-inspirational-words-for-everyone">7.
<a name="conclusions" href="#toc">Conclusion (and inspirational words
for everyone)</a></h1>
<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 that most people won’t have read this far and
that’s quite all right; I’m very thorough and pay attention to details
obsessively. Creating this game was a delight and I am quite proud of
what I have done.</p>
<p>Thank you for whatever level of attention you felt you could or
wanted to give and enjoy it in whatever way you see fit!</p>
<p><strong>Much more importantly is that Snake aside I hope I have
demonstrated how with the imagination and creativity almost anything is
possible.</strong> This is something <strong>that applies in our world
in every way and <em>everyone</em> can do something amazing if they
believe in themselves!</strong> I would have never thought this the case
for me years ago but I know it’s true now. <strong>Believe in yourself.
Always.</strong></p>
<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<tbody>
<tr class="odd">
<td>(c) Copyright 1984-2020, [Leo Broukhis, Simon Cooper, Landon Curt
Noll][judges] - All rights reserved This work is licensed under a
[Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].</td>
</tr>
<tr class="even">
<td>[judges]: https://www.ioccc.org/judges.html [cc]:
http://creativecommons.org/licenses/by-sa/3.0/</td>
</tr>
</tbody>
</table>
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/end-row.default.html -->
</div>
<!-- END: this line ends content from: inc/end-row.default.html -->
<!-- START: this line starts content from: inc/footer.default.html -->
<div class="footer">
<hr>
<h2>Coda</h2>
<p><a href="https://validator.w3.org/nu/?doc=#">Nu HTML check this web page</a></p>
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
</div>
<!-- END: this line ends content from: inc/footer.default.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->
+1 -1
View File
@@ -885,7 +885,7 @@ years ago but I know it's true now. **Believe in yourself. Always.**
[cannibalism.log.md]: cannibalism.log.md
[cannibalism.log.html]: cannibalism.log.html
[crazy.log.md]: crazy.log.md
[crazy.log.md]: crazy.log.html
[crazy.log.html]: crazy.log.html
[play.sh]: play.sh
-----------------------------------------------------------------------------------------------------
+17 -4
View File
@@ -737,9 +737,9 @@ https://creativecommons.org/licenses/by-sa/4.0/</p>
<h1 id="inventory-for-2020ferguson1"><a name="inventory"></a>Inventory
for 2020/ferguson1</h1>
<p><a href="#top">Jump to top</a></p>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/prog.c">prog.c</a>
- entry source</li>
@@ -755,16 +755,28 @@ href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/pr
<li><a href="COMPILING.html">COMPILING.html</a> - about compiling</li>
<li><a href="HACKING.html">HACKING.html</a> - information for
herpetologist hackers</li>
<li><a href="bugs.html">bugs.html</a> - current bugs and things that
look like bugs but are not</li>
<li><a href="cannibalism.log.html">cannibalism.log.html</a> - about the
snake game</li>
<li><a href="chocolate-cake.html">chocolate-cake.html</a> -
double-layered chocolate fudge cake recipe</li>
<li><a href="crazy.log.html">crazy.log.html</a> - about some screen
dumps</li>
<li><a href="gameplay.html">gameplay.html</a> - how to play the
game</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/play.sh">play.sh</a>
- how to run</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/snake-colours.sh">snake-colours.sh</a>
- script to reset - preset colors</li>
<li><a href="spoilers.html">spoilers.html</a> - SPOILER ALERT - about
the code</li>
<li><a href="terminals.html">terminals.html</a> - terminal capabilities
and dimensions and colors</li>
<li><a href="troubleshooting.html">troubleshooting.html</a> -
troubleshooting the game</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/prog.2.c">prog.2.c</a>
- source with more digraphs</li>
@@ -785,6 +797,7 @@ download entry source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/.entry.json">.entry.json</a>
- description of entry in JSON</li>
@@ -794,7 +807,7 @@ href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/.g
<li><a href=".path">.path</a> - directory path from top directory</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/COMPILING.md">COMPILING.md</a>
- markdown source for crazy.log.html</li>
- markdown source for COMPILING.html</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/HACKING.md">HACKING.md</a>
- markdown source for HACKING.html</li>
@@ -807,13 +820,13 @@ href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/bu
<li><a href="cake.jpg">cake.jpg</a> - image for chocolate cake</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/cannibalism.log.md">cannibalism.log.md</a>
- markdown source for chocolate-cake.html</li>
- markdown source for cannibalism.log.html</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/chocolate-cake.md">chocolate-cake.md</a>
- markdown source for chocolate-cake.html</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/crazy.log.md">crazy.log.md</a>
- markdown source for deckmyn.html</li>
- markdown source for crazy.log.html</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/gameplay.md">gameplay.md</a>
- markdown source for gameplay.html</li>
File diff suppressed because it is too large. Load diff
+464
View File
@@ -0,0 +1,464 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- -->
<!-- The original markdown content was formed by the tool: bin/gen-other-html.sh -->
<!-- The HTML was converted from markdown by the tool: bin/md2html.sh -->
<!-- -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>The International Obfuscated C Code Contest</title>
<meta name="description" content="terminals.md for 2020/ferguson1">
<meta name="keywords" content="IOCCC, 2020/ferguson1, terminals.md">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<img src="../../png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
<h1>The International Obfuscated C Code Contest</h1>
<h2>terminals.md for 2020/ferguson1</h2>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.up2index.html -->
<div class="topnav">
<a class="Left" href="index.html">&uarr; jump to index.html &uarr;</a>
</div>
<!-- END: this line ends content from: inc/topnav.up2index.html -->
<!-- START: this line starts content from: inc/begin-row.default.html -->
<div class="row">
<!-- END: this line ends content from: inc/begin-row.default.html -->
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
<div class="leftcolumn">
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/sidenav.default.html -->
<div class="sidenav">
<a href="#content">Jump to contents</a>
</div>
<hr>
<div class="sidenav">
<a href="../../index.html">IOCCC Home</a>
<a href="../../years.html">Winning Entries</a>
<a href="../../authors.html">People who have won</a>
</div>
<hr>
<div class="sidenav">
<a href="../../news.html">IOCCC News</a>
<a href="../../faq.html#submit">How to enter the IOCCC</a>
<a href="../../faq.html">FAQ</a>
</div>
<hr>
<div class="sidenav">
<a href="../../bugs.html">Bugs &amp; (mis)features</a>
<a href="../../faq.html#fix_an_entry">Fixing IOCCC entries</a>
<a href="../../faq.html#fix_web_site">Fixing the web site</a>
<a href="../../faq.html#fix_author">Fixing author info</a>
<a href="../../thanks-for-help.html">Thanks for the help</a>
</div>
<hr>
<div class="sidenav">
<a href="../../judges.html">The IOCCC Judges</a>
<a href="../../contact.html">Contacting the IOCCC</a>
</div>
<hr>
<div class="sidenav">
<a href="#top">Jump to top</a>
</div>
<!-- END: this line ends content from: inc/sidenav.default.html -->
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
<div class="rightcolumn">
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<a name="content"></a>
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h1 id="terminals">Terminals</h1>
<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 sanity if it causes any problems) as well as colours
(limitations etc.).</p>
<p><a name="toc"></a></p>
<ul>
<li><p><a href="#termcaps">Capabilities support testing
program</a></p></li>
<li><p><a href="#dimensions">Setting the game dimensions</a></p>
<ul>
<li><p><a href="#linescolumns">The LINES and COLUMNS environmental
variables</a></p></li>
<li><p><a href="#insanity">Terminal insanity</a></p></li>
<li><p><a href="#restore">Restoring the terminal</a></p></li>
<li><p><a href="#abuse">Terminal size abuse</a></p></li>
</ul></li>
<li><p><a href="#termlimitations">Terminal limitations</a></p></li>
<li><p><a href="#colours">Terminal colours</a></p>
<ul>
<li><p><a href="#background">Curses background</a></p></li>
<li><p><a href="#monochrome">Monochrome terminals</a></p></li>
<li><p><a href="#colourlimitations">Colour limitations</a></p></li>
<li><p><a href="#disablecolour">Disabling colour</a></p></li>
</ul></li>
</ul>
<h1
id="capabilities-support-testing-program"><a name="termcaps" href="#toc">Capabilities
support testing program</a></h1>
<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 for the capabilities I use in the entry.</p>
<p>It also tries to determine the minimum number of columns to play
without the status line overflowing - even with the dynamic length.
Try:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> make test</span></code></pre></div>
<p>This compiles the program <a href="termcaps.c">termcaps.c</a> and
runs it; you should see something like:</p>
<pre><code>terminal supports cursor movement
terminal supports making cursor invisible
terminal supports bold
terminal supports colours
terminal rows 41 (38 playable)
terminal cols 155 (153 playable)
snake size: 997 (max size: 5776)
bugs: 199 (max size: 1155)
at least 34 columns (currently 155) recommended for snake size 997
at least 37 columns (currently 155) recommended for capped snake size 5776
No problems detected.</code></pre>
<p>Terminal rows and cols are the current values (the number of columns
shown later as well). The snake size is the default size to win (based
on the variables, see below). The <code>max size: 5776</code> is the
capped size (or ‘capsize’). The 199 bugs is approximately the
<code>snake_size / growth_size</code> i.e. how many bugs it will take to
win the game. The max bugs in the <code>bugs</code> line is
approximately <code>max_snake_size / growth_size</code> i.e. how many
bugs it’ll take to win at the maximum (capped) snake size.</p>
<p>If I pass in any of the variables <strong><code>GROW</code></strong>,
<strong><code>MAXSIZE</code></strong>,
<strong><code>SIZE</code></strong> and/or
<strong><code>LINES</code></strong> or
<strong><code>COLUMNS</code></strong> it bases its calculations on those
variables. For example:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> supports cursor movement</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> supports making cursor invisible</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> supports bold</span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> supports colours</span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> rows 41 <span class="er">(</span><span class="ex">38</span> playable<span class="kw">)</span></span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a><span class="ex">terminal</span> cols 155 <span class="er">(</span><span class="ex">153</span> playable<span class="kw">)</span></span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a><span class="ex">snake</span> size: 5776 <span class="er">(</span><span class="ex">max</span> size: 5776<span class="kw">)</span></span>
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a> <span class="ex">bugs:</span> 5771 <span class="er">(</span><span class="ex">max</span> size: 5771<span class="kw">)</span></span>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a><span class="ex">at</span> least 37 columns <span class="er">(</span><span class="ex">currently</span> 155<span class="kw">)</span> <span class="ex">recommended</span> for snake size 5776 </span>
<span id="cb3-13"><a href="#cb3-13" aria-hidden="true" tabindex="-1"></a><span class="ex">at</span> least 37 columns <span class="er">(</span><span class="ex">currently</span> 155<span class="kw">)</span> <span class="ex">recommended</span> for capped snake size 5776 </span>
<span id="cb3-14"><a href="#cb3-14" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-15"><a href="#cb3-15" aria-hidden="true" tabindex="-1"></a><span class="ex">No</span> problems detected.</span></code></pre></div>
<p>As you can see it tells you the max size (the ‘capsized’ snake) as
well as the requested max size (if the requested size is bigger than the
capped size then it will be set to that value instead) of the snake. The
capped size is like in the Snake game itself but the suggested minimum
number of columns is based on a number of variables.</p>
<p>If I were to do the above but set columns to less &lt; 35 then there
would be a problem. But why if the utility recommends at least 37? This
is because the max size of the snake also depends on the terminal size.
This utility is not perfect: I don’t consider shedding; I set growth to
5 if it’s 0 (since it would be indeterminate how many bugs are possible
before ‘winning’ since there would be no ‘winning’); and there are
probably other things too.</p>
<p>As for capabilities: besides cursor movement the others are just nice
to have. From my tests keeping the cursor visible doesn’t ruin gameplay
but it is less distracting if nothing else to have it invisible (in fact
due to the sequence of function calls the cursor would mostly appear to
be not in the game field itself - from memory at least).</p>
<p>Maybe there are other capabilities I should check for that I’m
unaware of but this should give you an idea.</p>
<p>If there are any problems it will say how many (fatal and otherwise).
The fatal problems are if curses fails to initialise or if movement of
cursor cannot be done (both seem unlikely to happen nowadays).</p>
<p>Both scripts run this utility and prompt if there are any problems;
you can continue either way.</p>
<h1
id="setting-the-game-dimensions"><a name="dimensions" href="#toc">Setting
the game dimensions</a></h1>
<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 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>
<p>To specify the lines/columns of curses program per instance use the
<code>LINES</code> and <code>COLUMNS</code> environmental variables.</p>
<p>For demonstration consider the following:</p>
<pre><code> $ echo $LINES $COLUMNS
42 157</code></pre>
<p>Note: I subtract 1 from the max y/x and the max coords in the game
output include the walls and score line but these values are for the
terminal itself.</p>
<p>Say you want 55 columns:</p>
<pre><code> $ COLUMNS=55 ./prog</code></pre>
<p>This will force curses to detect the max columns (X) of your terminal
(for the game dimensions) - to be 55; it might look like this
instead:</p>
<pre><code> X:27/54 Y:20/41 S:5/997 B:0</code></pre>
<p>But problems can arise with messing with dimensions: in my tests this
held only to lines.</p>
<h2 id="terminal-insanity"><a name="insanity" href="#toc">Terminal
insanity</a></h2>
<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 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, 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>
<p>In my tests there is one thing that at least allows you to see the
final score and that is by running <code>clear</code> before running the
program. That’s what the prog.alt version does. You might run it as one
of:</p>
<pre><code> LINES=20 ./prog.alt
LINES=20 ./snake.alt</code></pre>
<p>Even if the final score is visible though the terminal may very well
still be messed up. There are numerous things you might try but probably
the easiest is to run the game again without modifying the dimensions
(and then just quit) or even just the <code>reset</code> command.</p>
<p>The Linux man page says:</p>
<pre><code>You might have to run the `reset` tool like:
&lt;LF&gt;reset&lt;LF&gt;
(the line-feed character is normally control-J) to get the terminal
to work, as carriage-return may no longer work in the abnormal state.</code></pre>
<p>If you don’t have the reset utility you can try:</p>
<pre><code> echo -e \\033c</code></pre>
<p>Otherwise try <code>clear; stty sane</code> (that will turn on echo
also) or if all else fails log out and back in.</p>
<p>For more information on this subject generally see the <a
href="https://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO.html">Linux
keyboard and 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>
<h3 id="terminal-size-abuse"><a name="abuse" href="#toc">Terminal size
abuse</a></h3>
<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 along and thinks he/she will be clever and mess with the
dimensions a bit. Let’s say they have a 13” monitor and they think it’d
be funny to see how 997 lines would work; they might try something
like:</p>
<pre><code> LINES=997 ./prog</code></pre>
<p>What then? Well expect trouble; curses will not know any better and
the max number of lines will be 997. If they were to do:</p>
<pre><code> COLUMNS=997 ./prog</code></pre>
<p>Then they will see a different effect. Again the same reason: the
player trying to be funny.</p>
<p>The game will try and be funny in return and you can expect it to not
function properly. Because that’s what funny means in this context.</p>
<h1
id="terminal-limitations"><a name="termlimitations" href="#toc">Terminal
limitations</a></h1>
<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 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> (<a
href="HACKING.md">HACKING</a> on GitHub) file has information on
this.</p>
<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 causes problems e.g. <strong>LINES=6 COLUMNS=6</strong> and
<strong>LINES=3 COLUMNS=3</strong> caused some nasty issues.</p>
<h1 id="terminal-colours"><a name="colours" href="#toc">Terminal
colours</a></h1>
<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 judges; here I discuss the
background, foreground as well as limitations (in particular runtime
limitations).</p>
<h2 id="curses-background"><a name="background" href="#toc">Curses
background</a></h2>
<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. 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 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 GitHub) file).</p>
<h2
id="monochrome-terminals"><a name="monochrome" href="#toc">Monochrome
terminals</a></h2>
<p>According to my tests for monochrome terminals the screen has the
white and black background; if terminal is configured to be black
background white foreground that is the order it is too. You can try
that like:</p>
<pre><code> TERM=linux-m ./prog</code></pre>
<p>But I do not specifically check if the terminal has colours. Is there
a curses implementation that has a problem here? Below I explain what to
comment out should you need colours to be disabled but I personally have
not run into any problems even with monochrome terminals. Later I say
what to do to remove colour support in the source code itself.</p>
<h2
id="colour-limitations"><a name="colourlimitations" href="#toc">Colour
limitations</a></h2>
<p>According to X/Open Curses, Issue 7 (pg. 57):</p>
<pre><code>With init_pair() and pair_content(), the value of pair must be in a range
from 0 to and including COLOR_PAIRS-1. (There may be an
implementation-specific upper limit on the valid value of pair, but any such
limit is at least 63.) Valid values for f and b are the range from 0 to and
including COLORS-1.</code></pre>
<p>The manpage for <code>init_pair()</code> says this:</p>
<pre><code> These limits apply to color values and color pairs. Values outside these limits are not legal, and may result in a runtime error:
[...]
COLOR_PAIRS corresponds to the terminal database&#39;s max_pairs capability, (see terminfo(5)).</code></pre>
<p>Based on the two as well as the fact that monochrome terminals (I’ve
tried under both Linux and macOS) seem to work fine I believe I am fine
here too. And to confirm this I wrote the following code with the output
below:</p>
<pre><code> #include &lt;curses.h&gt;
int main()
{
initscr();
start_color();
printw(&quot;COLORS: %d\nCOLOR_PAIRS: %d\n&quot;, COLORS, COLOR_PAIRS);
getch();
endwin();
}
TERM=linux-m ./colour_pairs
COLORS: 0
COLOR_PAIRS: 0</code></pre>
<p>Without specifying the TERM I get:</p>
<pre><code> COLORS: 256
COLOR_PAIRS: 32767</code></pre>
<p>In the case that colour is supported the standard states that there
will be more possible colour pairs than I have used so that’s not a
problem either. Perhaps even it would only be a runtime error if the
colours are supported and the number is out of the range? To try and
figure this out I did another test:</p>
<pre><code> int main()
{
initscr();
start_color();
init_pair(COLOR_PAIRS+1, COLOR_WHITE, COLOR_GREEN);
bkgd(COLOR_PAIR(COLOR_PAIRS+1));
init_pair(1, COLOR_WHITE, COLOR_BLACK);
attron(COLOR_PAIR(1));
printw(&quot;COLORS: %d\nCOLOR_PAIRS: %d\n&quot;, COLORS, COLOR_PAIRS);
getch();
endwin();
}</code></pre>
<p>Running it like</p>
<pre><code> TERM=linux-m ./colour_pairs</code></pre>
<p>I got the output as if colours weren’t used: 0 and 0. With coloured
terminals however it was not visible. If I however comment out the call
to <code>bkgd()</code> I get instead:</p>
<pre><code> COLORS: 256
COLOR_PAIRS: 32767</code></pre>
<p>Which leads me to believe that if you try using a value outside the
range it won’t work for a colour-capable terminal but it doesn’t matter
for monochrome 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>
<h2 id="disabling-colour"><a name="disablecolour" href="#toc">Disabling
colour</a></h2>
<p>Nevertheless if it is a problem and you don’t want to use a
monochrome terminal (or can’t):</p>
<p>First comment out the code that has <code>start_color();</code> and
then add <code>return;</code> to the top of the <code>C()</code>
function (the rest of the code won’t be reached). If necessary you can
also comment out the <code>init_pair()</code> calls.</p>
<p>Perhaps you only need to add the <code>return;</code> to
<code>C()</code>. My guess is that’s the case but I do not know for
certain.</p>
<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<tbody>
<tr class="odd">
<td>(c) Copyright 1984-2020, [Leo Broukhis, Simon Cooper, Landon Curt
Noll][judges] - All rights reserved This work is licensed under a
[Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].</td>
</tr>
<tr class="even">
<td>[judges]: https://www.ioccc.org/judges.html [cc]:
http://creativecommons.org/licenses/by-sa/3.0/</td>
</tr>
</tbody>
</table>
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/end-row.default.html -->
</div>
<!-- END: this line ends content from: inc/end-row.default.html -->
<!-- START: this line starts content from: inc/footer.default.html -->
<div class="footer">
<hr>
<h2>Coda</h2>
<p><a href="https://validator.w3.org/nu/?doc=#">Nu HTML check this web page</a></p>
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
</div>
<!-- END: this line ends content from: inc/footer.default.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->
+550
View File
@@ -0,0 +1,550 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- -->
<!-- The original markdown content was formed by the tool: bin/gen-other-html.sh -->
<!-- The HTML was converted from markdown by the tool: bin/md2html.sh -->
<!-- -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>The International Obfuscated C Code Contest</title>
<meta name="description" content="troubleshooting.md for 2020/ferguson1">
<meta name="keywords" content="IOCCC, 2020/ferguson1, troubleshooting.md">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<img src="../../png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
<h1>The International Obfuscated C Code Contest</h1>
<h2>troubleshooting.md for 2020/ferguson1</h2>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.up2index.html -->
<div class="topnav">
<a class="Left" href="index.html">&uarr; jump to index.html &uarr;</a>
</div>
<!-- END: this line ends content from: inc/topnav.up2index.html -->
<!-- START: this line starts content from: inc/begin-row.default.html -->
<div class="row">
<!-- END: this line ends content from: inc/begin-row.default.html -->
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
<div class="leftcolumn">
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/sidenav.default.html -->
<div class="sidenav">
<a href="#content">Jump to contents</a>
</div>
<hr>
<div class="sidenav">
<a href="../../index.html">IOCCC Home</a>
<a href="../../years.html">Winning Entries</a>
<a href="../../authors.html">People who have won</a>
</div>
<hr>
<div class="sidenav">
<a href="../../news.html">IOCCC News</a>
<a href="../../faq.html#submit">How to enter the IOCCC</a>
<a href="../../faq.html">FAQ</a>
</div>
<hr>
<div class="sidenav">
<a href="../../bugs.html">Bugs &amp; (mis)features</a>
<a href="../../faq.html#fix_an_entry">Fixing IOCCC entries</a>
<a href="../../faq.html#fix_web_site">Fixing the web site</a>
<a href="../../faq.html#fix_author">Fixing author info</a>
<a href="../../thanks-for-help.html">Thanks for the help</a>
</div>
<hr>
<div class="sidenav">
<a href="../../judges.html">The IOCCC Judges</a>
<a href="../../contact.html">Contacting the IOCCC</a>
</div>
<hr>
<div class="sidenav">
<a href="#top">Jump to top</a>
</div>
<!-- END: this line ends content from: inc/sidenav.default.html -->
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
<div class="rightcolumn">
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<a name="content"></a>
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h1 id="troubleshooting-snake">Troubleshooting Snake</h1>
<p>In this file I have a list of a number of possible problems that
could show up under some situations as well as some things that might
appear to be happening or be a problem but actually are not. For each
one I have included a summary, a more thorough description and any
resolutions (from easiest to hardest). For anything that can cause more
than one issue I will list those separately to keep it as structured as
possible/easiest to find.</p>
<p><a name="toc"></a> - <a href="#topwall">The top wall isn’t (all/some
of the time) visible!</a></p>
<ul>
<li><p><a href="#notmoving">The snake isn’t moving!</a></p></li>
<li><p><a href="#invisiblehead">I can’t see the snake head (or other
part of the snake)!</a></p></li>
<li><p><a href="#invisiblebug">I can’t see the bug!</a></p></li>
<li><p><a href="#froze">The game froze!</a></p></li>
<li><p><a href="#bigsnake">The game gets slower as the snake gets
bigger!</a></p></li>
<li><p><a href="#headonly">I set SIZE=0 GROW=1, ate a bug but still only
the head was visible! Why?</a></p></li>
<li><p><a href="#monochrome">I like black text on a white background but
even with a white background terminal it ends up black!</a></p></li>
<li><p><a href="#toodark">The text is hard to see (not bright
enough)!</a></p></li>
<li><p><a href="#movefaster">Can I move the snake faster temporarily
without having to modify the wait time?</a></p></li>
<li><p><a href="#envvars">On environmental variables more generally and
string to int conversions</a></p></li>
<li><p><a href="#errors">Errors and error reporting</a></p></li>
</ul>
<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 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 you shouldn’t need it to be very
wide.</p>
<ul>
<li><p>RESOLUTION #0: Use a bigger screen (it doesn’t take that many
columns)</p>
<p><strong>Tip:</strong> try running <code>make test</code> to get an
estimate of the minimum number of columns 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 small screen will make it harder to play esp without the
cheat modes enabled (but they can still be fun with large
screens).</p></li>
<li><p>RESOLUTION #1: Open the <a href="prog.c">prog.c</a> and change
the line</p>
<pre><code> #define J Z(X:%d/%d Y:%d/%d S:%zu/%zu B:%zu\n),Y,y[-2],X, *y, A, g, c );</code></pre>
<p>To be something like:</p>
<pre><code> #define J Z(B:%zu\n), c);</code></pre>
<p>Recompile and try again. That will then show only the number of bugs
eaten. See the <a href="HACKING.html">HACKING.html</a> (<a
href="HACKING.md">HACKING.md</a> on GitHub) file for other data you can
include (though there are some discrepancies here and there as you’ll
see).</p></li>
</ul>
<h2 id="the-snake-isnt-moving"><a name="notmoving" href="#toc">The snake
isn’t moving!</a></h2>
<p>Unless the game is paused this should not be happening. It can appear
sometimes that there isn’t movement and sometimes it might have to take
a moment to ‘unwind’ but as long as the head is moving then everything
is fine.</p>
<p>The tail might not always be moving which could make it seem like the
snake isn’t moving but as long as the head is moving then the snake can
be assumed to be moving.</p>
<ul>
<li><p>RESOLUTION #0: Unless the game is paused as long as the snake
head is moving everything is fine even if it seems sometimes that the
snake tail is still: this is normal and there are a few conditions that
this might especially show itself e.g. when the snake is growing.</p>
<p>If you want to see this in action try:</p>
<pre><code> SIZE=150 SHEDS=10 SHED=1 ./prog</code></pre>
<p>Once you start moving you’ll see that the tail stays still for a
while and 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 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>
<li><p>BOTTOM LINE: If you want more information then see the <a
href="bugs.html">bugs.html</a> (<a href="bugs.md">bugs.md</a> on GitHub)
file.</p></li>
</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>
<p>Possibly this could happen with too long a score line which I already
discussed. It also used to be possible during cannibal mode whilst
cannibalising: you would just have to continue moving on and you’d
eventually find your head (assuming the rest of the screen isn’t covered
with your body!). And what else could you expect if you decided to shove
your head up your …. ? :))</p>
<ul>
<li><p>RESOLUTION #0: Actually I thought it would look better that you
could see the head even when cannibalising so you should be able to lose
your head and at the same time see it!</p></li>
<li><p>RESOLUTION #1: If the terminal width is too small then it could
be that the score line is covering the wall, snake and even bug; I gave
two resolutions to that earlier in this file. To get a recommended
number of columns use <code>make test</code>.</p></li>
</ul>
<h2 id="i-cant-see-the-bug"><a name="invisiblebug" href="#toc">I can’t
see the bug!</a></h2>
<p>This has happened to me a number of times and early in development
there were times that I could swear I even saw it beyond the walls but
this should not be a problem now if it ever was.</p>
<p>However I have made a lot of effort to think of situations that might
make the bug location calculation and placement be a problem and even
did some debug output and wrote another test program to calculate the
maximum number of places the bug could be put etc.</p>
<p>One of the reasons I have the terminal dimensions have a minimum and
also a maximum has to do with the way the bug placement and max size of
the snake (and so arrays) are calculated: it could happen that because
of it being unsigned without there being restrictions it could end up
being a bad value that causes the bug placement loop to never end (in
this case the snake would also stop moving).</p>
<ul>
<li><p>RESOLUTION #0: If evasion mode is enabled (default after 300
moves) just wait it out and the bug will move to a new place and it
might be easier to see in the new place.</p></li>
<li><p>RESOLUTION #1: The terminal size is too small for the score line.
See the earlier problem for how to resolve this if that’s the
case.</p></li>
<li><p>RESOLUTION #2: Sometimes you have to look closely for it can be
easy to miss. If it’s against the wall and the screen is <a
href="https://www.hp-lexicon.org/character/gaunt-family/morfin-gaunt/">Snakey</a>
or you’re tired or the colour contrast isn’t right for you or something
like that it might be harder to see. Try pausing the game (space) and
scan the screen for it. If you really are 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 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 <a href="snake-colours">snake-colours</a> script to select a
different colour scheme.</p></li>
</ul>
<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 have caused this (and I did this deliberately in development
to find all the conditions I could to resolve them).</p>
<ul>
<li><p>RESOLUTION #0: If this does happen it likely is to do with
placement of the bug; that is why I have the max size of the snake
capped a fair bit below the maximum number of coordinates in the game
field: because the bug isn’t to be at a place the snake already
occupies.</p></li>
<li><p>RESOLUTION #1: If the system <code>rand()</code> implementation
is really bad maybe it’s having a problem finding a location to place
the bug. The best I can think of is to try increasing the screen size or
decrease the max size of the snake.</p></li>
<li><p>BOTTOM LINE: If the bug cannot find a place to be this will
likely cause the game to freeze because the game loops until it finds an
available place for the bug to be; if the pRNG is so bad wrt where the
snake occupies it could theoretically happen. If this happens you will
have to kill the game by e.g. ctrl-c. Try increasing the screen size
and/or decreasing the max size of the snake. See below for some
tests.</p>
<p>I removed caps in a test and then:</p>
<pre><code> GROW=1 COLUMNS=30 LINES=10 CANNIBAL=1 MAXSIZE=10000 ./prog</code></pre>
<p>It froze at this point:</p>
<pre><code> X:14/29 Y:5/9 S:323/10000 B:318</code></pre>
<p>This is because there was only one place for the bug - where the
snake head was to be. With these parameters the limit is actually 189!
This could perhaps be increased but the calculation I have used is easy
and although I certainly could make it so it’s one less than the max
that takes more bytes and I don’t see it actually mattering.</p>
<p>Another time I tried:</p>
<pre><code> LINES=6 COLUMNS=6</code></pre>
<p>And it also froze (as noted I impose a minimum of &gt;= 10 for both
LINES and COLUMNS).</p>
<p>Ultimately I had to kill the program due to the game being stuck in
the bug placement routine. I could have put in a maximum number of loops
but what good would that do? It would use more bytes and what would it
do anyway, win? Well that’s what the max size is for.</p></li>
<li><p>TERMINAL SIZE TO MAX SNAKE SIZE CALCULATION ETC.</p>
<p>For this information and more use the termcaps utility:</p>
<pre><code> make test</code></pre>
<p>An example:</p>
<pre><code> terminal supports cursor movement
terminal supports making cursor invisible
terminal supports bold
terminal supports colours
terminal rows 41 (38 playable)
terminal cols 154 (152 playable)
snake size: 997 (max size: 5738)
bugs: 199 (max size: 1147)
at least 34 columns (currently 154) recommended for snake size 997
at least 37 columns (currently 154) recommended for capped snake size 5738
No problems detected.</code></pre>
<p>Why are there only 38 playable lines for 41 rows? The first row is
the score line, the second is the top wall, the last is the bottom wall.
For columns you have the left and rightmost columns for the walls.</p>
<p>The calculation for max size takes place after decrementing the max
y/x; then it’s <code>(maxy - 2) * (maxx - 2)</code>; above that would
be:</p>
<pre><code> (41 - 2) * (156 - 2) == 6006</code></pre>
<p>If for some reason the game were to stall for this purpose you would
have to kill the game by e.g. ctrl-c since the bug placement is stuck in
a loop. This shouldn’t happen though.</p></li>
</ul>
<h2
id="the-game-gets-slower-as-the-snake-gets-bigger"><a name="bigsnake" href="#toc">The
game gets slower as the snake gets bigger!</a></h2>
<p>Realistically the game shouldn’t take that much memory but maybe in
some very busy systems it would have a problem.</p>
<ul>
<li><p>RESOLUTION #0: If the rand() implementation is particularly poor
then it might be that the bug placement is taking more time.</p></li>
<li><p>RESOLUTION #1: It could also be the arrays being updated as the
snake gets bigger.</p></li>
<li><p>BOTTOM LINE: I find it unlikely that either of these happen and I
don’t know what to say; you can try decreasing the max size to see if it
doesn’t reach this problem. Otherwise it would be good to see if you can
find a pattern: is it when the snake is bigger i.e. the screen is rather
fuller than when you first begin? Or is the system rather busy?</p></li>
</ul>
<h2
id="i-set-size0-grow1-ate-a-bug-but-still-only-the-head-was-visible-why"><a name="headonly" href="#toc">I
set <code>SIZE=0 GROW=1</code>, ate a bug but still only the head was
visible! Why?</a></h2>
<ul>
<li><p>RESOLUTION #0: The size includes the head but what should it show
if the size is 0? The head is the obvious choice so once you do get to
size 1 you will still only have the head. When you get to size 2 you’ll
have part of the body too. Try:</p>
<pre><code> SIZE=1 GROW=1</code></pre>
<p>And you will see that at one bug you’ll have size two and just as if
you had two bugs with the previous invocation.</p>
<p>BTW: When you are size 1 you can go back on yourself even if
cannibalism is disabled because there really isn’t anything to go back
through: it’s just you moving the head until you find a body to use!
Once you have size &gt;= 2 then cannibalism mode counts.</p></li>
<li><p>BOTTOM LINE: In some senses SIZE=0 and SIZE=1 are the same
thing.</p></li>
</ul>
<h2
id="i-like-black-text-on-a-white-background-but-even-with-a-white-background-terminal-it-ends-up-black"><a name="monochrome" href="#toc">I
like black text on a white background but even with a white background
terminal it ends up black!</a></h2>
<p>This is a curses thing but fortunately it should be easy enough to
solve.</p>
<ul>
<li><p>RESOLUTION #0: Try setting the terminal to monochrome for the
invocation of the game. Depending on what is installed on your system
you might not have a monochrome terminal but you can certainly get them.
In Red Hat systems these can be found in the package ncurses-term but
maybe that will vary on others. I don’t recall having to install it
under macOS nor Fedora but those systems have GUIs so that’s probably
why; in CentOS I did have to install it specially.</p>
<p>The <code>-m</code> suffix to terminal names means monochrome. Under
Linux this terminal is under <code>/usr/share/terminfo/l/linux-m</code>
and under macOS (Catalina at least) it’s at
<code>/usr/share/terminfo/6c/linux-m</code> (for macOS Ventura it’s
<code>/usr/share/terminfo/6c/linux-m</code>).</p></li>
<li><p>BOTTOM LINE: Try using a monochrome terminal for the game by
e.g.:</p>
<pre><code> TERM=linux-m ./prog</code></pre>
<p>And then on your white background terminal the game should keep the
background white and the foreground black. This will of course mean you
have no colour but unfortunately changing the background colour of
curses would 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>
<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>
</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>
<ul>
<li><p>RESOLUTION #0: Make sure that your terminal settings have for
bold text a brighter font. The way I have my terminal profiles set up is
to use bright colours for bold text. I specifically enable bold in the
program so try and find out if enabling brighter colours is
possible.</p>
<p>If it’s already set at brighter colours I do not know what to say.
Try playing with the colours in your terminal, maybe the font size or
various other settings. Probably better to make a new profile for this
first in case you mess up your old one. FWIW I haven’t had this problem
on consoles only and in my systems I have the option to enable brighter
colours for bold - it was only in testing that I came across this
problem.</p></li>
</ul>
<h2
id="can-i-move-the-snake-faster-temporarily-without-having-to-modify-the-wait-time"><a name="movefaster" href="#toc">Can
I move the snake faster temporarily without having to modify the wait
time?</a></h2>
<p>Yes. The <code>getch()</code> call is non-blocking when the timeout
value is positive so it’s up to that number of milliseconds.</p>
<ul>
<li><p>RESOLUTION #0: All you need to do then is hold down the direction
key (or for that matter any other key that <code>getch()</code> will
pick up on). You can also rapidly push the key instead of holding it
down.</p></li>
<li><p>BOTTOM LINE: Depending on the key repeat rate and/or how fast you
repeatedly hit the key you can have more control over the speed - as
long as it is quicker than the regular wait time. For negative wait time
(drawing mode) you have to hit a key every time to move because it is
blocking.</p></li>
</ul>
<h2
id="on-environmental-variables-more-generally-and-string-to-int-conversions"><a name="envvars" href="#toc">On
environmental variables more generally and string to int
conversions</a></h2>
<p>What happens if you do:</p>
<div class="sourceCode" id="cb12"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="va">WALLS</span><span class="op">=</span> <span class="ex">./prog</span></span></code></pre></div>
<p>Can you run into the wall since you didn’t specify a value and the
default is 1? No. That’s not the way it works. By saying WALLS= you have
told the system that there is that environmental variable. However the
way the <code>strtoul()</code> functions work is that if there’s no
valid input it returns 0. This can be detected but it’s wasteful
(iocccsize wise) and I have never felt that having invalid input for a
number could have a better value than 0.</p>
<p>If however you were to give valid input followed by invalid input the
valid input would be parsed. For example:</p>
<div class="sourceCode" id="cb13"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="va">WALLS</span><span class="op">=</span>1test <span class="ex">./prog</span></span></code></pre></div>
<p>would let you go through the walls. On the other hand</p>
<div class="sourceCode" id="cb14"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="va">WALLS</span><span class="op">=</span>test1 <span class="ex">./prog</span></span></code></pre></div>
<p>would not. Furthermore if you specify the same variable more than
once it’s the last one that counts. For example:</p>
<div class="sourceCode" id="cb15"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="va">WALLS</span><span class="op">=</span>0 <span class="va">WALLS</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>1 <span class="va">CANNIBAL</span><span class="op">=</span>0 <span class="ex">./prog</span></span></code></pre></div>
<p>would allow you to go through walls but you could not
cannibalise.</p>
<p>Also note that I specify base 0 which means that you can also have it
in hex and octal. These are all the same:</p>
<pre><code>SIZE=0x3
SIZE=3
SIZE=03</code></pre>
<p>The way the functions work is if 0x (or 0X) it’s considered hex; if
prefixed with a 0 it’s octal and otherwise it’s decimal. If you specify
invalid data (even if only at the beginning of the string) the functions
return 0. For example:</p>
<pre><code>SIZE=0
SIZE=f
SIZE=-
SIZE=f1</code></pre>
<p>are all equivalent.</p>
<p>Observe that:</p>
<pre><code>SIZE=08</code></pre>
<p>is invalid input because octal only has digits 0 - 7: the resulting
size will be 0.</p>
<p>I discuss the signed/unsigned issue to do with curses and sizes in C
being unsigned in <a href="bugs.html">bugs.html</a> (<a
href="bugs.md">bugs.md</a> on GitHub) but probably there isn’t anything
more to say here.</p>
<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’ and you have every right to curse it to hell if that’s
what you so wish. Apparently curses will report an error itself if that
function fails but that escaped my notice until later on so you might
get two errors in that case.</p>
<p>Assuming it succeeds the game obtains the maximum y/x of the
terminal. The screen size must be at least 10 lines/columns (though in
code the number will not be 10); if either is smaller you will get
‘screen too small’ and the game will end (yes things that haven’t begun
can be ended).</p>
<p>If <code>calloc()</code> fails to obtain the needed memory you’ll see
something like (here it was before I added proper - to make the perfect
and obvious pun - capsizing so that by setting the size to -1 it went to
the max unsigned value):</p>
<div class="sourceCode" id="cb19"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> MAXSIZE=-1 ./prog</span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a><span class="ex">memory</span> error</span>
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a><span class="ex">X:0/157</span> Y:0/42 S:3/18446744073709551614 B:0</span></code></pre></div>
<p>BTW: There are two arrays that have to be
<strong><code>MAXSIZE</code></strong> (technically + 1).</p>
<p>Is it possible that some value specified by the user could mess this
up? I do not know but what I do know is that because it’s unsigned it
can’t be negative; if the max size is 0 then the array size will be 1
but it won’t matter because the snake size will be &gt;= that max
anyway. But here’s a curious output:</p>
<div class="sourceCode" id="cb20"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="va">SIZE</span><span class="op">=</span>1 <span class="va">MAXSIZE</span><span class="op">=</span>0 <span class="ex">./prog</span></span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="ex">YOU</span> WIN!</span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a><span class="ex">X:78/156</span> Y:20/41 S:0/0 B:0</span></code></pre></div>
<p>Why does it show snake size as 0 when I specified 1? It’s because the
max size is 0 and I limit the size to be no bigger than the max
size.</p>
<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<tbody>
<tr class="odd">
<td>(c) Copyright 1984-2020, [Leo Broukhis, Simon Cooper, Landon Curt
Noll][judges] - All rights reserved This work is licensed under a
[Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].</td>
</tr>
<tr class="even">
<td>[judges]: https://www.ioccc.org/judges.html [cc]:
http://creativecommons.org/licenses/by-sa/3.0/</td>
</tr>
</tbody>
</table>
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/end-row.default.html -->
</div>
<!-- END: this line ends content from: inc/end-row.default.html -->
<!-- START: this line starts content from: inc/footer.default.html -->
<div class="footer">
<hr>
<h2>Coda</h2>
<p><a href="https://validator.w3.org/nu/?doc=#">Nu HTML check this web page</a></p>
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
</div>
<!-- END: this line ends content from: inc/footer.default.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->
+34 -10
View File
@@ -9,14 +9,6 @@
{ "author_handle" : "Cody_Boone_Ferguson" }
],
"manifest" : [
{
"file_path" : "index.html",
"inventory_order" : 10,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : "prog.c",
"inventory_order" : 20,
@@ -49,6 +41,14 @@
"display_via_github" : true,
"entry_text" : "original source"
},
{
"file_path" : "chocolate-cake.html",
"inventory_order" : 100,
"OK_to_edit" : true,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "encrypted chocolate cake recipe"
},
{
"file_path" : "input.txt",
"inventory_order" : 100,
@@ -57,6 +57,14 @@
"display_via_github" : true,
"entry_text" : "sample input"
},
{
"file_path" : "obfuscation.html",
"inventory_order" : 100,
"OK_to_edit" : true,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "about the obfuscation of this entry"
},
{
"file_path" : "obfuscation.txt",
"inventory_order" : 100,
@@ -73,6 +81,14 @@
"display_via_github" : true,
"entry_text" : "Enigma machine simulato source code"
},
{
"file_path" : "recode.html",
"inventory_order" : 100,
"OK_to_edit" : true,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "recode configurator documentation"
},
{
"file_path" : "try.alt.sh",
"inventory_order" : 100,
@@ -137,6 +153,14 @@
"display_via_github" : false,
"entry_text" : "download entry source"
},
{
"file_path" : "index.html",
"inventory_order" : 2000000000,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : ".entry.json",
"inventory_order" : 4294967295,
@@ -183,7 +207,7 @@
"OK_to_edit" : true,
"display_as" : "markdown",
"display_via_github" : true,
"entry_text" : "markdown source for COMPILING.html"
"entry_text" : "markdown source for chocolate-cake.html"
},
{
"file_path" : "ioccc-cake.jpg",
@@ -207,7 +231,7 @@
"OK_to_edit" : true,
"display_as" : "markdown",
"display_via_github" : true,
"entry_text" : "markdown source for index.html"
"entry_text" : "markdown source for recode.html"
}
]
}
+335
View File
@@ -0,0 +1,335 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- -->
<!-- The original markdown content was formed by the tool: bin/gen-other-html.sh -->
<!-- The HTML was converted from markdown by the tool: bin/md2html.sh -->
<!-- -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>The International Obfuscated C Code Contest</title>
<meta name="description" content="chocolate-cake.md for 2020/ferguson2">
<meta name="keywords" content="IOCCC, 2020/ferguson2, chocolate-cake.md">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<img src="../../png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
<h1>The International Obfuscated C Code Contest</h1>
<h2>chocolate-cake.md for 2020/ferguson2</h2>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.up2index.html -->
<div class="topnav">
<a class="Left" href="index.html">&uarr; jump to index.html &uarr;</a>
</div>
<!-- END: this line ends content from: inc/topnav.up2index.html -->
<!-- START: this line starts content from: inc/begin-row.default.html -->
<div class="row">
<!-- END: this line ends content from: inc/begin-row.default.html -->
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
<div class="leftcolumn">
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/sidenav.default.html -->
<div class="sidenav">
<a href="#content">Jump to contents</a>
</div>
<hr>
<div class="sidenav">
<a href="../../index.html">IOCCC Home</a>
<a href="../../years.html">Winning Entries</a>
<a href="../../authors.html">People who have won</a>
</div>
<hr>
<div class="sidenav">
<a href="../../news.html">IOCCC News</a>
<a href="../../faq.html#submit">How to enter the IOCCC</a>
<a href="../../faq.html">FAQ</a>
</div>
<hr>
<div class="sidenav">
<a href="../../bugs.html">Bugs &amp; (mis)features</a>
<a href="../../faq.html#fix_an_entry">Fixing IOCCC entries</a>
<a href="../../faq.html#fix_web_site">Fixing the web site</a>
<a href="../../faq.html#fix_author">Fixing author info</a>
<a href="../../thanks-for-help.html">Thanks for the help</a>
</div>
<hr>
<div class="sidenav">
<a href="../../judges.html">The IOCCC Judges</a>
<a href="../../contact.html">Contacting the IOCCC</a>
</div>
<hr>
<div class="sidenav">
<a href="#top">Jump to top</a>
</div>
<!-- END: this line ends content from: inc/sidenav.default.html -->
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
<div class="rightcolumn">
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<a name="content"></a>
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h1 id="blyzot-erhnfpm-tgbmmuykd-sczuo-mkwo">Blyzot-erhnfpm Tgbmmuykd
Sczuo Mkwo</h1>
<p>Fmjy’m u ejbtspawc uynzki-ydvutrn uycmtblxh pebvw rqoa nvnk tp
vqzcueaih gm sj cqo’f cdiiykyqer. Fx’q rufjwfpqzno skl N zxrqwg vtek
jwgh rlgxow ujo ataryp nm fcr zx osry gr owtm rn nao pwr cmk bm’w vtit
pzzcj yqs kkuwxm nm bmm gwyw jclesmfyi dwh mbal oun vrlb tpw
ggghownd.</p>
<p>Qk qvvr pclboqp yfq lzqw fztzk kqtix ‘pxrzgprnl’ ylbxo hyyt rjjo! Sdq
cmiygcx qotfb yg hzomk yk’q kggh xxln. Sbd nygpg <a
href="ucjei-lven.pzi">nsxeu-tppf.ctk</a> bea s lrdcss fhbnzks ch uowuqbp
<code>JUWPJ</code> cfwy xqo phxq axzblp gqozp, l impebytcy yoxt. Xkg
lwrarhk jyvns byg rigsb ajq oc ojgpyepc (14 Mwuplopu) hc 2022 zr jc’o
bls ptdz zjr Y tdzr:</p>
<figure>
<embed src="moxi.stc" />
<figcaption aria-hidden="true">aghllpv in kct Fajihs-bkmpoyk rgswgeimr
sxfah ofgk</figcaption>
</figure>
<p>Buhcv qvb zap clcw le vwmzqatokfu txu rigmaxhrvvrc; duw bhjk bwq zdz
qwfvm. Er vhuuuyey yjdew hom vrwm <strong>UMLW EDOMAUQLC XTSAO</strong>
oa ful jozfwdrus nc; oikl ywtr cu mnkmvoro cqkoakn yzrt’xa
<strong>PMINGEM PTOFGCPLN</strong> ihk atp xksdtxv yw ggt rnwk. Fjtp
uttbhy ui ltketccabj.</p>
<p>Vaqhz X texd qmdummxg cix gqmnuwnjxil juojuiriqt psl J uukfprr vigk
esjxsj oad fhvvhmtbaqdk xh uwcs etm kr ocnt. Ueee ue ezib fsl bpzt lg
bwz tbsvbvx ljeio.</p>
<p>Wrxqsdv plys didm gfbmmjdqp rh kgkzu zub jzo nj soj hfefe yewd ofsqe
kzd djve cs jrv eqdycb gqjkbz fd djg dzzy gcc vcs pkl upqgs tj
hndlmzqyse.</p>
<h2 id="fydmeefakhdr">Fydmeefakhdr</h2>
<p>Bjcq owe kqfxcfimql cwhdd qpcp oj Vabbgrkr sumyxpun jrk hilou lg lux
eatbiczhtfko gxr bs vay XG mashqmcvx. Y bbft mrtxslqd (olxl lcf jtyq
ngsi frzm xhlr twmlnhe) dq
&lt;nvrt://vbx.dtfevjdzqjrhcarz.wyy/fthcjau.kqy&gt;. Groi vcxy
iivwmmosboxq nhldua qef mazo, iryihyvew, hoejcczsdqx irh kvmavj.</p>
<h2 id="diwuam-blnnhvxhq">Diwua’m blnnhvxhq</h2>
<p>Jtmxt’t xauphebaf la y ompso hzsw kwf ztc ovvcees eo wrkbgmyc pb
wriamhhqhlk bdtgtnbsn kgzc ptjx tiy novwfy. Segyofxtw na p [wwrnzuvcuj
SYO][] gb oqndz wv kstodh cahbovqdw zlgxsr:</p>
<blockquote>
<p>Umiwkh qmvecmimt ssdjkzgq zs rgvln rfp up fxwut jgigfc ‘kwwicrngdhh’
nb ‘mqinqz’ ofvycfnbw. Ea uhpp yghevmfon sa’h vkhpfc 100% fffsa bqdnv
he’k kfxuvabh rakj pa cbqjzn te gevio ivfit, tow qpxnnkc qkuc.</p>
</blockquote>
<p>Zfr TGA lgoupgpq csxw mzj fknie gchf wr zdbm huc b fwfdpx jbvzow pbkf
tts C vswagx sslnn nfn hgtrawqu hndrey fvsqk fcqh ci’y spbnyhufppq
muvoddwqd jmzy zdz psyhob. Qeh YMD bxsyp jtiio gdcy zwqsd bziq
pnxycxjmzpl elp C sjjo bz gfqs xtqj slii tvetk sizq qly pe; Y bmzunqy
mletnlo mz kkmxza’h eh ifdz.</p>
<p>Cksoax nwe <strong>SMTEXS OLXVT YQJ BDHLSVZIM WF SOC UVJ CNZDN et umz
kgsgmxujj UG OZG EXUGWO ufw MYBAJB LAVQU GFPLKGC CUTF’FQ <em>IOVXVXQOK
KIFRJRZTP!</em></strong></p>
<h2 id="jeveget-lncfe-hix-amh-djlx">Jeveget lncfe hix amh djlx</h2>
<p><strong>BMM MISRS BJXXUQLBK FA NTBGX:</strong></p>
<ul>
<li><p><strong>XXA <em>QGHBNTBVK</em>! BH <em>LRX</em> MAZ
ZGDSMI!</strong> Jwafgu ykda hfr cgff srmw. Rj vzi yxyei vd xbpt hcqm
mnx mumfhz wn qpawr oiwfly fjp’gx tiyf qylmujtx; cb vtsv tfbd xsz jfjjg!
Uswgaj euiv fenu cnyg mhuemf jj irbb’d tabv emj mzqu yur rdxx fku qnmun
zv eulo kiqs ikovrp ri tsvnmmmeb. Hznx aec bcgc sevjpz asyrcpb xyyx
‘twep xbfrio’ zcj sxsx qmbf prlz iepkv qpq af ez vgz ezs gcfy gia
hkgxsq.</p></li>
<li><p>Jpbu sgx jlitg ikwl mioefrv egv zoil ps eqf drxryonrfka etwpnbfzb
qhvgpwt; detu bwwz nz mo isl cyjwl bnuw; lnm ogxf vqj 1/4 zflkm yeyc
xbxixy tw cg qbsi sp vvjaonsm fwim <strong>BSJ EAHXAV FU NF SDSWV
<em>DFM TKFQUHJ</em> RM ZAAVDK</strong>. Rlr isp vtzntmndtzpv cusl pp
ewdkv’g nwu uhihp.</p></li>
<li><p>Jwz ooxjwqt cdltmixjm sp avk <strong>FAAS ACX PKIC DKZ SFURBLEYS
RKPX</strong> iqsx. Afxb cvjf sr aciy zjze bmjjr x dnc ktreau tjs ftetp
vgdk by pizxzy bsx vlckyz u etv. Yeqv qb hczrit jtg alkm tk xmp qxdx
owujg dfy x dddphl zvc mpa.</p></li>
<li><p><strong>YKREKJ ZAZ SHYT VMRI XID WREW <em>2 RAIIAPH QQCPX
HTNFHPOJ PQWL SDMU</em></strong> srv nyip kuchp ic <strong>IPVSL FMZB
<em>CS PIJDF!</em></strong> Ypq vubxnengj kzwja uv gz <strong>WSCJ ZEJZ
RUZL BAAT <em>FCA’O RXHVJZQL</em></strong>.</p></li>
<li><p>Pndo udv kkhpba cvj klegy ogsgmhl awmz wgvn rplanlua djtqc te f
eyu; hnr gx’i pqetlodderczv nzjev ca s zol. Ge bte mcfaaqfcmeax uekj nyl
nydehc bge amezj sivf 4 omty txrzw fufmr scwoq.</p></li>
<li><p><strong>CBU <em>UVCBM YNCR!</em></strong> Rdg’x fgz tghh ispx xi
xgjcgdjn osl uzcy cc rpx blmy gag jdfg.</p></li>
<li><p>Fqr <strong>XFVM <em>LHDH</em> RQLACVJ PVBWPMV!</strong>
<strong>GR <em>PTL ZOF GJWBVOTUH BOEASEQ!</em></strong> Zbz slzfdbdvk
vjko ohpg rauk phez be w ppevc fcpbuem.</p></li>
</ul>
<h2 id="mhaq-tbwhtqpayzx">Mhaq Tbwhtqpayzx</h2>
<ul>
<li>3 no xovjudihzxw (Sqwnw’q) uoavvhzbq</li>
<li>2 gha 1/4 madf nfqza</li>
<li>2 yjpa azagtv mdtt</li>
<li>1/2 qab jeio</li>
<li>2 xqc 1/4 dwho supjxa evufg pryge</li>
<li>3 wcrc</li>
<li>1 jma 1/2 wim <strong>JTVQ HLKEGCE SDVZMSS (<em>CIX QXMWCOPHH
NFYSARC!</em>)</strong></li>
<li>1/2 unl <strong>YTVMXUZVU (<em>IPY AXNUQL!</em>)</strong></li>
<li>1 svd (lepmtxq) yddvt</li>
<li>1 qbq wikb jzkzg</li>
</ul>
<h2 id="srgk-hpqxbulqtwy">Srgk Hpqxbulqtwy</h2>
<ol type="1">
<li><p>Rwvllzf dymgzp <strong>AOM 9 o 1.5 SAWO UZTVS FPBN</strong>;
dylwhju zpvc twag dvgcf.</p></li>
<li><p>Jxfvlxq vnre ht <strong>350 J / 176.67 F</strong>.</p></li>
</ol>
<h2 id="eqvj-enosawdjxq">Eqvj Enosawdjxq</h2>
<ol type="1">
<li><p>Qvxx <strong>3 IH ERAZZALRVRT DFDKSHYGM</strong> cu fwsnet ziwopo
zx usuxu rkne rxwa <strong>uxx (<em>GEB THJ FJKXNLU</em>)
grzvm</strong>; wyy ycgm kldvlc nmyiuhczmf.</p></li>
<li><p>Mxyz <strong>2 kdv 1/4 RVGV KWGQF</strong>, <strong>2 PTQ NSRBCW
XUEI</strong>, tmj <strong>1/2 MWA XIHI</strong></p></li>
<li><p>Cuko <strong>1 LBJGV EQIUKDFEH (<em>HAO DZBJIN!</em>)</strong> am
ceivw ijbb <em>xhfdg cjkc</em>. Ghkwx <strong>XEWLKDZFW, <em>OLY
QEBCYZ!</em></strong></p></li>
<li><p>Des <strong>2 wki 1/4 XSFV HJYGUO CHYEB TEMDM</strong> qxt
<strong>3 TFRA</strong>. Esfk cadkr xvsrq zov avwopx.</p></li>
<li><p>Iwjf os <strong>1 1/2 YMH <em>LOEJ</em> XRUOHPO MMDXCOE (<em>MGV
XASVIPNIV PSYDGXH!</em>)</strong> bcn <strong><em>QVEFTM</em> KHSIYI
VXBZZTTKP</strong>.</p></li>
<li><p>Csxo fc bxu jlspzumxvcf kmwodfkxtkx jtvy <strong>1 KXF AMRD
DDDLF</strong>; pxlddn yukh ypapm dpaafr.</p></li>
<li><p>Aoqj qz <strong>1 KIM <em>CRWCWJC</em> RWNTW</strong>.</p></li>
<li><p>Cube qkar hmjmrwob ajlw.</p></li>
<li><p>Ordp wzk <strong>ETVS 35 HCYRLCV</strong> (<strong>KD
SYFNQY!</strong>) uc <strong>350 W / 176.67 D</strong>.</p></li>
<li><p>Zkkp ius dhja kjw fzmg pqu jmx ojd kgbv fpde af n tfzbkyi tvvh
mia **_SQQN LMY SBXJCQA IEY GNOE <em>WFXHMCWXSSL WWZM XHOSY FJW TY GX
HNWM</em><strong>. Wwn </strong>OLJC <em>USBYUCPUXS!</em>**</p></li>
</ol>
<h2 id="kjted-efcqnplspdo">Kjted Efcqnplspdo</h2>
<ul>
<li>4 bc lfpjwafstfc btthlwwis (Skrvb’h nthtyxkxo)</li>
<li>1/2 dlg <strong>ATXQRITQP (<em>YCD PEGGGJ!</em>)</strong></li>
<li>4 xhnl cypelpkc jgwxc</li>
<li>1/2 tfe pufjy rotw</li>
<li>2 kls <strong><em>MNCS</em> ZPAWTOW LSDKTSL (<em>VRN VXFCHNNMJ
SXKTWIF!</em>)</strong></li>
</ul>
<p>Rem bdku dzpm vyuw n gvyxqs gkb ve kbyc hbxj dvr vkqb lpg rubqo susl
syw dbmqj qfht omj vfs rx.</p>
<h2 id="nhchqms-jsivn-hhx-qjv-zxzca">Nhchqms jsivn hhx qjv zxzca</h2>
<p><strong>FIO KICKH NCSGMJBRP HW LMFYH:</strong></p>
<ul>
<li><p><strong>OKRA IVBF</strong> owzl yna jwohls upchbknmo bkm
<strong>YGZZDYSKZ (<em>UNS YYYORJ!</em>)</strong> ii qyk cij
crbxw.</p></li>
<li><p>Irc qvbw #4 eqn <strong>8 cn 10 RRH FLSUO</strong> hj s dck ex
dyx mnjj (cxtx’i cqm xiivap ntnk zgewbli wbta pvr wti cd fz).
<strong>YVH TC BFQY ZM PSWUX</strong> zvy <strong>CDC WXK IUOW MAAJ ETR
WDEOP QV EVQ URO AF ESVC</strong> dd fwg yhuit. <strong>RM MFF COS ELB
GVZCL PPM IRA!</strong></p></li>
<li><p><strong>BC KNZ FMU NVZEZ XFQ YXG EOYUB.</strong></p></li>
<li><p><strong>DNI <em>FPTBF NTEL!</em></strong> Arp’j hzn lfuj jhnx wd
adnytarh sov qfuo xp tuu eypo bgk zdmt.</p></li>
<li><p>Zdw <strong>RMDK OFCR LEALWTC DHXXWIN</strong>! <strong>NM ZRP
OIM QRMQQRGFQ JKJYGEJ!</strong> Wfm qztrqlotv ivvv tsrg rkgu ddot br u
uhxyw rjxvhtd. Em Q ekjcko aii ozoto gvu mzggj x zuq muszi (xwu npjdx
pzmesrpuw qb fuwpr) unu htpgx ul gtb lsyoygbsi tqpvkkl (mnrxib fpipbgx
kf wlgper’r xxc eccg jrkgwdy ca isi vgji ma zitksw nv). Ytqs bfq’s rl
qo.</p></li>
</ul>
<h2 id="murew-ohoodwphiu">Murew Ohoodwphiu</h2>
<ol type="1">
<li><p>Vmwtwlf <strong>4 IK QVQJMGVORKA UAKNDZTCP</strong> lsj
<strong>1/2 RPO <em>LGIRLIFJD (OTK XQEJUF!)</em></strong> zc fzp. Ocfm
rgr jgrqkl ymhy nspp. <strong>FT GFX VXV SY SSO HPSQE!</strong></p></li>
<li><p>Xhvunaw <strong>3 1/4 HNZJ RLQNCLPV KHCHX</strong>, <strong>1/2
QNFU BJCGF ASBH</strong> dyw <strong>2 FPA </strong><em>ZGXF</em>
PVXXWWQ RAEZEEC (<em>QCE UYOHRHVQD DVEUWNP!</em>)** stpn l njmv.
<strong>YNMC PMMJD DXNZMJ</strong>.</p></li>
<li><p>Vfs mrbmrtzsm qnoxsux.</p></li>
<li><p>Isu yapu nd iij/fyqc sj jur rvz jdfaa. Gvdh hnrj jqrfj/krztm
nwuzg ca’m efxhj FPY iyl qmi cvdpx. <strong>Ysxn <em>VZTL</em> KFEAT
QAWE <em>DZH</em> ZDO FXY!</strong> Qfw aeqm jo al <strong>UUIJ YXJ MDKH
JE’W BW QVVR <em>CPD AW IWS WQY HOR HMPGW CMZ
LTF!</em></strong></p></li>
</ol>
<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<tbody>
<tr class="odd">
<td>(q) Beqmpxdco 1984-2020, [Mlp Xmzzsgng, Ypgqh Edmmnc, Dvrmer Mzva
Hpwr][yrotjo] - Ivr beoqgu lyxytxxt Fwvv qmjv ld svkqxrlh aibco d
[Lzyelscr Jaonjqx Engmwcsrknd-RwponJkktx 3.0 Jrdllayi Glnwmvc][py].</td>
</tr>
<tr class="even">
<td>[mbwvfy]: xfeog://vcp.nihxr.bpx/ylvnhd.dnvh [sw]:
vgfc://gnwnxoisovojzby.dhl/tndtbatn/wh-bb/3.0/</td>
</tr>
</tbody>
</table>
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/end-row.default.html -->
</div>
<!-- END: this line ends content from: inc/end-row.default.html -->
<!-- START: this line starts content from: inc/footer.default.html -->
<div class="footer">
<hr>
<h2>Coda</h2>
<p><a href="https://validator.w3.org/nu/?doc=#">Nu HTML check this web page</a></p>
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
</div>
<!-- END: this line ends content from: inc/footer.default.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->
+10 -3
View File
@@ -965,9 +965,9 @@ https://creativecommons.org/licenses/by-sa/4.0/</p>
<h1 id="inventory-for-2020ferguson2"><a name="inventory"></a>Inventory
for 2020/ferguson2</h1>
<p><a href="#top">Jump to top</a></p>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/prog.c">prog.c</a>
- entry source</li>
@@ -980,15 +980,21 @@ href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/pr
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/prog.orig.c">prog.orig.c</a>
- original source</li>
<li><a href="chocolate-cake.html">chocolate-cake.html</a> - encrypted
chocolate cake recipe</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/input.txt">input.txt</a>
- sample input</li>
<li><a href="obfuscation.html">obfuscation.html</a> - about the
obfuscation of this entry</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/obfuscation.txt">obfuscation.txt</a>
- sample input</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/recode.c">recode.c</a>
- Enigma machine simulato source code</li>
<li><a href="recode.html">recode.html</a> - recode configurator
documentation</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/try.alt.sh">try.alt.sh</a>
- how to run alternative code</li>
@@ -1015,6 +1021,7 @@ download entry source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/.entry.json">.entry.json</a>
- description of entry in JSON</li>
@@ -1028,7 +1035,7 @@ href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/RE
<li><a href="cake.jpg">cake.jpg</a> - image for chocolate cake</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/chocolate-cake.md">chocolate-cake.md</a>
- markdown source for COMPILING.html</li>
- markdown source for chocolate-cake.html</li>
<li><a href="ioccc-cake.jpg">ioccc-cake.jpg</a> - image for chocolate
cake</li>
<li><a
@@ -1036,7 +1043,7 @@ href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/ob
- markdown source for obfuscation.html</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/recode.md">recode.md</a>
- markdown source for index.html</li>
- markdown source for recode.html</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
+371
View File
@@ -0,0 +1,371 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- -->
<!-- The original markdown content was formed by the tool: bin/gen-other-html.sh -->
<!-- The HTML was converted from markdown by the tool: bin/md2html.sh -->
<!-- -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>The International Obfuscated C Code Contest</title>
<meta name="description" content="obfuscation.md for 2020/ferguson2">
<meta name="keywords" content="IOCCC, 2020/ferguson2, obfuscation.md">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<img src="../../png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
<h1>The International Obfuscated C Code Contest</h1>
<h2>obfuscation.md for 2020/ferguson2</h2>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.up2index.html -->
<div class="topnav">
<a class="Left" href="index.html">&uarr; jump to index.html &uarr;</a>
</div>
<!-- END: this line ends content from: inc/topnav.up2index.html -->
<!-- START: this line starts content from: inc/begin-row.default.html -->
<div class="row">
<!-- END: this line ends content from: inc/begin-row.default.html -->
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
<div class="leftcolumn">
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/sidenav.default.html -->
<div class="sidenav">
<a href="#content">Jump to contents</a>
</div>
<hr>
<div class="sidenav">
<a href="../../index.html">IOCCC Home</a>
<a href="../../years.html">Winning Entries</a>
<a href="../../authors.html">People who have won</a>
</div>
<hr>
<div class="sidenav">
<a href="../../news.html">IOCCC News</a>
<a href="../../faq.html#submit">How to enter the IOCCC</a>
<a href="../../faq.html">FAQ</a>
</div>
<hr>
<div class="sidenav">
<a href="../../bugs.html">Bugs &amp; (mis)features</a>
<a href="../../faq.html#fix_an_entry">Fixing IOCCC entries</a>
<a href="../../faq.html#fix_web_site">Fixing the web site</a>
<a href="../../faq.html#fix_author">Fixing author info</a>
<a href="../../thanks-for-help.html">Thanks for the help</a>
</div>
<hr>
<div class="sidenav">
<a href="../../judges.html">The IOCCC Judges</a>
<a href="../../contact.html">Contacting the IOCCC</a>
</div>
<hr>
<div class="sidenav">
<a href="#top">Jump to top</a>
</div>
<!-- END: this line ends content from: inc/sidenav.default.html -->
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
<div class="rightcolumn">
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<a name="content"></a>
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h1 id="obfuscation">Obfuscation</h1>
<ul>
<li><p>Strings identifying what it is are encrypted by the Enigma itself
(with its default settings). The strings are: <code>Position</code>,
<code>Setting</code>, <code>Ring</code>, <code>Plugboard pair</code>
<code>Reflector</code>. Together these would be a dead giveaway to
anyone familiar with the Enigma machine and some of them by themselves
would be a dead giveaway too. I can’t even explain how I did this
(although I’m sure at one point I could have) but I do think it’s pretty
cool to have the text encrypted by the program and still be capable of
printing it correctly all without giving anything away.</p></li>
<li><p>Digraphs. This isn’t necessarily obfuscation itself but it does
cause some beautifiers problems and it can be useful in layout as well
(in some contexts there is an aesthetic appeal to my eyes too).</p></li>
<li><p>Compound literal of ints of size 13 that have a variety of
different data (including what was originally two arrays plus some
additional ints).</p></li>
<li><p>Negative pointer offsets. This include calculated offsets into
the huge Y&lt;:19:&gt;&lt;:27:&gt; but it’s not the only example. Here
the compound literal of 13 ints:</p>
<pre><code>int *z=(int[13]) { 0 } , *e, *g;</code></pre>
<p>Then in main:</p>
<pre><code>e = z + 10;
g = e + 1;
for (j=-3; j &lt; 0; ++j)
e&lt;:j:&gt; = j+3;</code></pre>
<p>Which I think is more confusing: when one is iterating an array you
don’t expect to start out with index &lt; 0 but to then compare that
that index &lt; 0 and increment until 0 along with setting the value of
the array to j + 3 is more confusing still. There are at least two other
ways that are much easier to read that could accomplish the same thing.
It continues on:</p>
<pre><code>/* ... */
e&lt;:i-3:&gt; = (j &lt; 1 ? 1 : (j &gt; 5 ? 5 : j))-1;</code></pre></li>
<li><p>Observe these two functions:</p>
<pre><code>void w(char *s, int k, int v)
{
for(e&lt;:2:&gt; = 0; s&lt;:*P:&gt;; ++e&lt;:2:&gt;)
{
v = s&lt;:e&lt;:2:&gt;:&gt;;
if(v &gt; 64 &amp;&amp; v &lt; 91)
s&lt;:e&lt;:2:&gt;:&gt; = (((v - 65 + k) % 26) + 65);
}
}
void Q(void)
{
for(*g = 0; *g &lt; 3; ++*g)
{
*Y&lt;:16+e&lt;:1:&gt;:&gt;=S&lt;:e&lt;:e&lt;:1:&gt;-3:&gt;:&gt;;
R&lt;:e&lt;:1:&gt;:&gt;=Y&lt;:e&lt;:-3+e&lt;:1:&gt;:&gt;:&gt;;
w(R[*g],*(e+e&lt;:1:&gt;-6)=q(Y&lt;:8:&gt;,*Y&lt;:7:&gt;),*g);
}
}</code></pre>
<p>First of all: why do I set <code>e[2]</code> to 0 and increment it
for each pass in the loop, but then the condition for the loop is
<code>s[*P]</code>?</p>
<p>Second notice the many references to e[1] (as e[1] and <em>g). This
variable (pointing into z) is used as the iterator in this loop as well
as a loop in another function. Now why do I pass </em>g to the function
w()? To mislead. Originally it was more misleading in that I didn’t
touch the parameter ‘v’ in the function and did a *g = v; at the end of
the function. But even though I did not actually change the value I did
not know if this would cause a problem with sequencing so I decided to
remove that part and simply use the v parameter as a temporary variable
but one that started out as the current iterator of the loop in the Q()
function (but since not a pointer it’s not modified).</p>
<p>Originally I went further than that but due to order of evaluation
being unspecified I changed it to what it is now. Anyway:</p>
<p>You can also see that I use the value of e[1]-3 as the index of S[e]
(so S[e[e[1]-3]]) (I think I said that right; I honestly don’t know now
because there is such major array and offset abuse. The entire prog.c is
riddled with offset abuses.).</p></li>
<li><p>If you observe that above the compound literal <code>z</code> is
of size 13 but I point <code>e</code> to be <code>z + 10</code>. Why?
Twofold: (1) I decided to make use of one of them as a temporary
variable instead of a regular int in the function (so make it global);
and (2) I didn’t want to risk changing all the offsets: thus I just made
that address <code>e[1]</code>. Thus I also have:</p>
<pre><code>for (*g = 0 ; *g &lt; 10; ++*g)
{
r&lt;:-2:&gt; = Y&lt;:14:&gt;&lt;:*(e+1):&gt;; r&lt;:-3:&gt; = Y&lt;:15:&gt;&lt;:1&lt;:e:&gt;:&gt;;
if (r&lt;:-3:&gt; &amp;&amp; r&lt;:-2:&gt; == r&lt;:-1:&gt;)
return r&lt;:-3:&gt;;
if (r&lt;:-2:&gt; &amp;&amp; r&lt;:-3:&gt; == r&lt;:-1:&gt;)
return r&lt;:-2:&gt;;
}</code></pre>
<p>This <code>e[1]</code> of course is the same as <code>*g</code> as
above and as you can see has multiple dimensions (that is the reference
to Y does) too (and this is also strewn about the code). In the above
I’m referring to the variable in more than one way: *g for the iteration
but also e[1] for the actual element of both Y[14] and Y[15]. I also
happen to use S (via r which points to S + 10) which I use as the two
chars to compare (this is the plugboard function).</p></li>
<li><p>The above function Z() takes a <code>char x</code> but you won’t
notice it being used at all. Why? In fact I call it like so:</p>
<pre><code>k = Z(r&lt;:-1:&gt;=k);</code></pre>
<p>The char is just used as a way to be able to call the function and
assign to the proper variable at the same time: in the function Z I
don’t care about x because it’s the same value as r[-1] (which I do care
about). Why is it attached to S? Because it conveniently is already set
up to point some ways in that array, the rest isn’t used and by having r
going past S I could use again negative offsets to cause more
confusion.</p></li>
<li><p>Although this is clearly already shown in the above there are
other ways I refer to the same variable in more than one way (or in some
cases maybe more correct to say ‘same location’). In the Z() function
for example:</p>
<pre><code>r&lt;:-2:&gt; = Y&lt;:14:&gt;&lt;:*(e+1):&gt;; r&lt;:-3:&gt; = Y&lt;:15:&gt;&lt;:1&lt;:e:&gt;:&gt;;</code></pre>
<p>I refer to e[1] as both: *(e+1) and 1[e].</p></li>
<li><p>Replacing a number of <code>if ..</code>s with
<code>... &amp;&amp; (...)</code>s (in one case at least it’s nested
further:
<code>f &amp;&amp; (f = 0 &amp;&amp; (a = W(A,a)));</code>).</p></li>
<li><p>Three different char arrays in one: the rotors settings, the
positions and the notches for each rotor. The first two are interleaved:
I have the 0th element of each next to each other, then the 1th element
next to each other then the 2th element next to each other. Then it’s
the notch settings. The first two arrays here require some index
calculations like <code>i+i%3</code> and <code>i+i+1</code> depending on
which ‘array’ is needed. At other points I refer to those elements by
direct index (sort of).</p></li>
<li><p>Another set of char arrays in one: the five rotors as well as the
two reflectors in one <code>char [][27]</code>. This makes for some fun
code like:</p>
<pre><code>(Y&lt;:e&lt;:-10:&gt;+5:&gt;&lt;:k-&#39;A&#39;:&gt;) &amp;&amp; (k = Y&lt;:e&lt;:-10:&gt;+5:&gt;&lt;:k-&#39;A&#39;:&gt;);</code></pre>
<p>(Of course this also removes an if statement by joining with a
&amp;&amp;).</p></li>
<li><p>In fact I decided that the above two arrays in arrays needed to
be merged with the rest of the char arrays so that’s what I have done.
They have different purposes and they’re referred to differently. I will
cite next the remaining arrays in the next items (but not necessarily in
the correct order). Notice that the array I’m talking about is the
massive <code>Y&lt;:19:&gt;&lt;:27:&gt;</code>.</p></li>
<li><p>The alphabet (this is one string).</p></li>
<li><p>The plugboard (this is two arrays).</p></li>
<li><p>The Enigma ciphered text for prompting for input (five
strings).</p></li>
<li><p>The relevant notches (this is not the same as the five notch
letters!) (this is three chars but each in a different element of the
<code>char Y[19][27]</code> - for why see below).</p></li>
<li><p>I’m not even sure if there are any others due to the way I have
done this; to save iocccsize bytes I have used the first element of
three of the strings when I only did need the first element (since doing
e.g. <code>f[3][2]</code> takes more bytes than <code>*f[3]</code> or
whatever). All in all though there are 18 different strings (in some
cases only the first char is relevant) in <code>char Y[19][27]</code>
with a multitude of different uses. Some of these are as I noted
scrambled. Some default to empty string which might hide that it’s even
there.</p></li>
<li><p>Although minor I have made use of the result of the end of a for
loop in the beginning in the next loop in main(): <code>j</code> will
end up being 0 and I need it at 9 so I do <code>j += 9</code> in the
initialisation of the for loop instead of simply setting it to
9.</p></li>
<li><p>The judges don’t like obfuscation through the C preprocessor.
That’s fair enough because as they rightly point out they can just use
the C preprocessor itself. But although I have quite a few cpp
directives I am not using them for obfuscation but rather to save bytes.
For examples:</p>
<pre><code>%:define J(x) do(*x)=getchar(); while((*x)==&#39;\n&#39;)</code></pre>
<p>Is used quite a number of times and although it could be a function
that takes a pointer to an int it was more convenient this way (I
believe it used more bytes but I no longer know that). There are many
others and they all save bytes (or at least most of them do if not all).
There is one in particular I want to bring up though because I think
it’s a curious one and it ties in to another point above:</p>
<pre><code>%:define A(y) *(&amp;Y&lt;:7:&gt;&lt;:1:&gt;+(y))</code></pre>
<p>What is special about this one: Above I noted how I sort of refer
directly to the notch settings (I think it was the notch settings
anyway). Now I could have done say</p>
<pre><code>char a = Y[7][1], b = Y[7][3], c = Y[7][5];</code></pre>
<p>But I felt that doing instead the pointer arithmetic was worth doing.
However it used significantly more bytes even as a macro: 17 if I recall
right. That’s with the macro. If I were to include it three times by
itself it’d be many more. I believe though that when the cpp translates
it it still requires more thought to determine that a is set to Y[7][1],
b to Y[7][3] and c to Y[7][5].</p></li>
</ul>
<h1 id="obfuscation-wrt-recode.c">Obfuscation wrt recode.c</h1>
<ul>
<li><p>To cause confusion I have used the same names of variables and
functions (well recode.c has more functions and variables) but with
different meanings. For example in recode.c <code>R</code> is a
<code>char R[3]</code> but in prog.c it’s <code>char *R[3]</code>.
Another example is where in prog.c <code>Y</code> is
<code>char Y[19][27]</code> in recode.c it’s <code>char *Y[3]</code>.
Some are use swaps but not necessarily all. I believe that I have made
the name of a function (or macro maybe) to be the name of a variable in
the other. Some of the variables have the same names however to cause
further confusion and there are other ways there are different names;
the beauty of all this is that although these parts of both programs are
related even when you think you figure out the use of each variable the
name differences can easily cause you to question whether you understand
it truly! Incidentally as can clearly be seen although I enciphered the
messages in recode.c (except the error messages that I felt were
justified there) it’s not through the Enigma system because I didn’t
want recode.c to give many hints as to how prog.c works. I don’t believe
deciphering recode.c will explain how my entry works because recode.c
doesn’t use the Enigma algorithm and even the strings are done very
differently (and separated) so that one cannot easily replace the
<code>char</code> variables in recode.c, move them to prog.c, compile
and expect it to work right.</p></li>
<li><p>Also what is this about ?</p>
<pre><code> /\
/ This is *not* what you think:
void D(char*x){ /* ... */ }</code></pre>
<p>Is that valid and if so how does it function? Yes it’s valid but I’ll
leave the other part of the question up to the reader to answer. Hint:
you already know how it works (yes, really you do)! Another hint: This
is and is not a misleading comment (conversely this makes this hint both
misleading - and also not).</p></li>
</ul>
<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<tbody>
<tr class="odd">
<td>(c) Copyright 1984-2020, [Leo Broukhis, Simon Cooper, Landon Curt
Noll][judges] - All rights reserved This work is licensed under a
[Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].</td>
</tr>
<tr class="even">
<td>[judges]: https://www.ioccc.org/judges.html [cc]:
http://creativecommons.org/licenses/by-sa/3.0/</td>
</tr>
</tbody>
</table>
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/end-row.default.html -->
</div>
<!-- END: this line ends content from: inc/end-row.default.html -->
<!-- START: this line starts content from: inc/footer.default.html -->
<div class="footer">
<hr>
<h2>Coda</h2>
<p><a href="https://validator.w3.org/nu/?doc=#">Nu HTML check this web page</a></p>
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
</div>
<!-- END: this line ends content from: inc/footer.default.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->
+711
View File
@@ -0,0 +1,711 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- -->
<!-- The original markdown content was formed by the tool: bin/gen-other-html.sh -->
<!-- The HTML was converted from markdown by the tool: bin/md2html.sh -->
<!-- -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>The International Obfuscated C Code Contest</title>
<meta name="description" content="recode.md for 2020/ferguson2">
<meta name="keywords" content="IOCCC, 2020/ferguson2, recode.md">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<img src="../../png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
<h1>The International Obfuscated C Code Contest</h1>
<h2>recode.md for 2020/ferguson2</h2>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.up2index.html -->
<div class="topnav">
<a class="Left" href="index.html">&uarr; jump to index.html &uarr;</a>
</div>
<!-- END: this line ends content from: inc/topnav.up2index.html -->
<!-- START: this line starts content from: inc/begin-row.default.html -->
<div class="row">
<!-- END: this line ends content from: inc/begin-row.default.html -->
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
<div class="leftcolumn">
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/sidenav.default.html -->
<div class="sidenav">
<a href="#content">Jump to contents</a>
</div>
<hr>
<div class="sidenav">
<a href="../../index.html">IOCCC Home</a>
<a href="../../years.html">Winning Entries</a>
<a href="../../authors.html">People who have won</a>
</div>
<hr>
<div class="sidenav">
<a href="../../news.html">IOCCC News</a>
<a href="../../faq.html#submit">How to enter the IOCCC</a>
<a href="../../faq.html">FAQ</a>
</div>
<hr>
<div class="sidenav">
<a href="../../bugs.html">Bugs &amp; (mis)features</a>
<a href="../../faq.html#fix_an_entry">Fixing IOCCC entries</a>
<a href="../../faq.html#fix_web_site">Fixing the web site</a>
<a href="../../faq.html#fix_author">Fixing author info</a>
<a href="../../thanks-for-help.html">Thanks for the help</a>
</div>
<hr>
<div class="sidenav">
<a href="../../judges.html">The IOCCC Judges</a>
<a href="../../contact.html">Contacting the IOCCC</a>
</div>
<hr>
<div class="sidenav">
<a href="#top">Jump to top</a>
</div>
<!-- END: this line ends content from: inc/sidenav.default.html -->
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
<div class="rightcolumn">
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<a name="content"></a>
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h1
id="the-recode-configurator-documentation-and-a-fun-way-to-explore-my-2020-ioccc-enigma-simulator">The
recode configurator documentation (and a fun way to explore my 2020
IOCCC Enigma simulator)</h1>
<p>N.B. At the end of this file I have given a fun exercise that can be
used to explore my <a
href="https://www.cryptomuseum.com/crypto/enigma/index.htm">Enigma
machine</a> <a href="prog.c">simulator</a>. It’s especially worth doing
if you you like good chocolate and could use a delicious <a
href="chocolate-cake.html">Double-layered Chocolate Fudge Cake</a>.</p>
<p>Alternatively if you just want the <a
href="../ferguson1/chocolate-cake.md">recipe</a> you could look at my <a
href="../ferguson1/prog.c">Snake entry ‘Don’t tread on me’ award</a>
since it’s also there and not enciphered.</p>
<p><a name="toc"></a></p>
<ul>
<li><p><a href="#recode">What is recode and why is it
recommended?</a></p></li>
<li><p><a href="#options">Options</a></p>
<ul>
<li><p><a href="#samefile">Protecting against the same I/O
file</a></p></li>
<li><p><a href="#fileoptions">File options parser
limitation</a></p></li>
<li><p><a href="#validation"><code>-R</code> option
validation?</a></p></li>
</ul></li>
<li><p><a href="#pipingtorecode">Piping commands to recode</a></p></li>
<li><p><a href="#pipingtoenigma">Piping recode to the Enigma
simulator</a></p></li>
<li><p><a href="#manuallytest">Manually test the recode program with the
Enigma program</a></p></li>
<li><p><a href="#onlyconfig">Only write config file</a></p></li>
<li><p><a href="#reuseconfig">Reusing a configuration</a></p></li>
<li><p><a href="#passtoenigma">Write config file, read data file and
pass to Enigma simulator</a></p></li>
<li><p><a href="#directlytoenigma">Piping directly to the Enigma code
once (with randomised settings, saved)</a></p></li>
<li><p><a href="#conclusion">Usage conclusion</a></p></li>
<li><p><a href="#additions">Example additions</a></p></li>
<li><p><a href="#exampleuses">Example uses</a></p></li>
<li><p><a href="#cake">Deliciously Enigmatic: Double-layered Chocolate
Fudge Cake</a></p></li>
</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>
<p>To demonstrate how to and why you should use the <a
href="recode.c">recode</a> program with the <a href="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)
commentary.</p>
<p>It would not be possible to do all that the recode program does in my
entry itself but I wanted to demonstrate the features of my entry and
this seemed the best way to do that. It also enhances the use of the
simulator to make it reusable etc.</p>
<p>The recode name idea is that it recodes the input (validating first)
to be input for the simulator itself. It can pseudo-randomly select all
the settings, it can write the settings to a file, read from input file
(e.g. for the text to encipher/decipher if piped to the simulator)
etc.</p>
<p>Basically it’s a configurator for the Enigma simulator that makes it
easier to use the simulator as well as to reuse the configuration to
decipher messages that have been enciphered by those settings. But it
also tries to make it look more like the real thing in that it shows the
actual rotors (e.g. labelling them with the Roman numeral, showing their
actual orders etc.), the reflectors (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 wonderful ‘challenge’ for everyone.</p>
<h1 id="options"><a name="options" href="#toc">Options</a></h1>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./recode</span> <span class="at">-h</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="ex">usage:</span> ./recode <span class="pp">[</span><span class="ss">options</span><span class="pp">]</span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="ex">-v</span> display selected settings</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="ex">-r</span> pseudo-randomly select settings</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="ex">-f</span><span class="op">&lt;</span>input file<span class="op">&gt;</span> read file for Enigma input</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="ex">-R</span><span class="op">&lt;</span>string<span class="kw">|</span><span class="fu">file</span><span class="op">&gt;</span> init settings from settings string or file</span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="ex">-o</span><span class="op">&lt;</span>output file<span class="op">&gt;</span> write settings to file</span></code></pre></div>
<p><code>-r</code> randomises settings. It won’t prompt you for settings
but it will for input if you don’t give the option to read in a file for
input.</p>
<p><code>-v</code> shows selected settings. For example combining
<code>-r</code> and <code>-v</code>:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo IOCCC <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-r</span> <span class="at">-v</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 1: <span class="er">(</span> <span class="ex">I</span><span class="kw">)</span> <span class="ex">EKMFLGDQVZNTOWYHXUSPAIBRCJ</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 2: <span class="er">(</span> <span class="ex">V</span><span class="kw">)</span> <span class="ex">VZBRGITYUPSDNHLXAWMJQOFECK</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 3: <span class="er">(</span> <span class="ex">IV</span><span class="kw">)</span> <span class="ex">ESOVPZJAYQUIRHXLNFTGKDCMWB</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> settings: WAR</span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> positions: XKE</span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="ex">Reflector:</span> <span class="er">(</span><span class="ex">B</span><span class="kw">)</span> <span class="ex">YRUHQSLDPXNGOKMIEBFZCWVJAT</span></span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#01: XE</span></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#02: HJ</span></span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#03: SA</span></span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#04: PY</span></span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#05: CI</span></span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#06: ZB</span></span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#07: WD</span></span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#08: QN</span></span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#09: RU</span></span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#10: VG</span></span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a><span class="ex">1WX5AK4RE1XEHJSAPYCIZBWDQNRUVGIOCCC</span></span></code></pre></div>
<p>Though you won’t find some of those strings in <a
href="recode.c">recode.c</a> or <a href="prog.c">prog.c</a>. Yes the
<code>WAR</code> for the Ringstellung (Ring settings) is an amusing
coincidence <em>but it really did happen!</em></p>
<p>As for <code>-f</code> the contents would be output with the settings
e.g. to pipe to <code>prog</code> itself (as if you redirected the file
contents to the Enigma machine for encipherment/decipherment). If the
file cannot be opened it sets back to stdin.</p>
<p><code>-o</code> outputs the settings to the file. If the file cannot
be opened for writing or is the same file name (see below) then only
stdout will be used. Example of randomised output going to a file:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-r</span> <span class="at">-oconfig</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">3PP4UB5GG1ELGTKFCOPVBNUYXJAWSDIOCCC</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat config</span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="ex">3PP4UB5GG1ELGTKFCOPVBNUYXJAWSD$</span></span></code></pre></div>
<p>Notice that a terminating newline isn’t added. Also note that it
outputs to stdout so you can pipe it to the Enigma machine but at the
same time have the settings saved for deciphering the text later (the
configuration does not have the input but both the configuration and the
input text is printed to stdout).</p>
<p>If you want to initialise the settings from previously saved settings
(as a string or an input file that has the same format) use the
<code>-R&lt;settings&gt;</code> option. 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 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 in <a href="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>
<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 name I won’t write to it. From a quick test this
is important particularly if neither file exist because if both calls to
<code>stat()</code> fail then the inodes will be the same (since what
else could they be set to but the same initial value?). 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 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>
<h2
id="file-options-parser-limitation"><a name="fileoptions" href="#toc">File
options parser limitation</a></h2>
<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>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-R~</span>/config</span></code></pre></div>
<p>will <em>not</em> read the file ‘config’ in the home directory. I
show another way to achieve this later.</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>
<p>Again the <code>-R</code> option does not validate input. For
validation you have to run the program interactively.</p>
<h1
id="piping-commands-to-recode"><a name="pipingtorecode" href="#toc">Piping
commands to recode</a></h1>
<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>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo testing test tests <span class="kw">|</span> <span class="ex">./recode</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="ex">1AB2BB3CC1testing</span> test tests</span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo testing test tests <span class="kw">|</span> <span class="ex">./recode</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="ex">mfrwxan</span> lzng ofnlu</span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo testing test tests <span class="kw">|</span> <span class="ex">./recode</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="ex">./recode</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a><span class="ex">1AB2BB3CC1mfrwxan</span> lzng ofnlu</span>
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo testing test tests <span class="kw">|</span> <span class="ex">./recode</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="ex">./recode</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a><span class="ex">testing</span> test tests</span></code></pre></div>
<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 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>
<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 need be done at all) then make sure to redirect stderr to
/dev/null. If you don’t you might see something like:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-r</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 1: IOCCC</span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="ex">Setting</span> 1: Position 1: Ring 2: Setting 2: Position 2: Ring 3: Setting 3: Position 3: Reflector: Plugboard pair 1: Plugboard pair 2: Plugboard pair 3: Plugboard pair 4: Plugboard pair 5: Plugboard pair 6: Plugboard pair 7: Plugboard pair 8: Plugboard pair 9: Plugboard pair 10: DEVIY</span></code></pre></div>
<p>What happened is that <code>Ring 1:</code> is printed to stderr but
since it’s not been redirected to <code>/dev/null</code> it prints this
out; at this point however it prompts for 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. 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 class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat input</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-finput</span></span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a><span class="ex">Rotors:</span></span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">1</span><span class="kw">)</span> <span class="ex">I:</span> EKMFLGDQVZNTOWYHXUSPAIBRCJ</span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">2</span><span class="kw">)</span> <span class="ex">II:</span> AJDKSIRUXBLHWTMCQGZNPYFVOE</span>
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">3</span><span class="kw">)</span> <span class="ex">III:</span> BDFHJLCPRTXVZNYEIWGAKMUSQO</span>
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">4</span><span class="kw">)</span> <span class="ex">IV:</span> ESOVPZJAYQUIRHXLNFTGKDCMWB</span>
<span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">5</span><span class="kw">)</span> <span class="ex">V:</span> VZBRGITYUPSDNHLXAWMJQOFECK</span>
<span id="cb7-11"><a href="#cb7-11" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> rotor 1 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 1</span>
<span id="cb7-12"><a href="#cb7-12" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> rotor 2 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 2</span>
<span id="cb7-13"><a href="#cb7-13" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> rotor 3 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 3</span>
<span id="cb7-14"><a href="#cb7-14" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> setting 1 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-15"><a href="#cb7-15" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> setting 2 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-16"><a href="#cb7-16" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> setting 3 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-17"><a href="#cb7-17" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> position 1 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-18"><a href="#cb7-18" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> position 2 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-19"><a href="#cb7-19" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> position 3 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb7-20"><a href="#cb7-20" aria-hidden="true" tabindex="-1"></a><span class="ex">Reflector:</span></span>
<span id="cb7-21"><a href="#cb7-21" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">1</span><span class="kw">)</span> <span class="kw">(</span><span class="ex">B</span><span class="kw">)</span> <span class="ex">YRUHQSLDPXNGOKMIEBFZCWVJAT</span></span>
<span id="cb7-22"><a href="#cb7-22" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">2</span><span class="kw">)</span> <span class="kw">(</span><span class="ex">C</span><span class="kw">)</span> <span class="ex">FVPJIAOYEDRZXWGCTKUQSBNMHL</span></span>
<span id="cb7-23"><a href="#cb7-23" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> reflector <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 2<span class="kw">)</span><span class="bu">:</span> 2</span>
<span id="cb7-24"><a href="#cb7-24" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 1: AB</span>
<span id="cb7-25"><a href="#cb7-25" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 2: CD</span>
<span id="cb7-26"><a href="#cb7-26" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 3: ..</span>
<span id="cb7-27"><a href="#cb7-27" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 4: EF</span>
<span id="cb7-28"><a href="#cb7-28" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 5: GH</span>
<span id="cb7-29"><a href="#cb7-29" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 6: IJ</span>
<span id="cb7-30"><a href="#cb7-30" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 7: KL</span>
<span id="cb7-31"><a href="#cb7-31" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 8: MN</span>
<span id="cb7-32"><a href="#cb7-32" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 9: OP</span>
<span id="cb7-33"><a href="#cb7-33" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 10: QR</span>
<span id="cb7-34"><a href="#cb7-34" aria-hidden="true" tabindex="-1"></a><span class="ex">1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC</span></span></code></pre></div>
<p>Notice that I skipped a <a
href="https://www.cryptomuseum.com/crypto/enigma/i/sb.htm">plugboard
pair</a>; this can be done in a number of ways but two dots is one.
Notice also that it’s in a different order than the simulator: because
with the size restrictions on my entry I saved bytes by using the same
loop where I could. It just felt more natural to have them grouped
together in a configurator for the <a href="prog.c">simulator</a>.</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="ex">HQNVO</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="bu">echo</span> 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRHQNVO <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span></code></pre></div>
<p>As you can see the <code>recode</code> program prompts for the
settings and outputs the input for the Enigma program. I then
copied/pasted that output to the program and got the result
<code>HQNVO</code>.</p>
<p>Following this I piped the original output (of <code>recode</code>)
to the simulator and then piped that to the echo of the input settings
(replacing the IOCCC with the Enigma enciphered output) and then got the
result IOCCC: the original input! (This was before I implemented the
<code>-R</code> option to greatly simplify things.)</p>
<p>Of course the last command was redundant in that I didn’t need to
show the first part again; I could have just done the latter part but I
wanted to show the way the pipeline works with settings etc.</p>
<p>What happens if the plugboard pairs are the same but in a different
order? It’s the same output:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo 1AA2AA3AA2AB..CDEFGHIJKLMNOPQRIOCCC<span class="kw">|</span><span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="ex">HQNVO</span></span></code></pre></div>
<p>Also if you flip the order of the letters in the pair e.g. the AB as
BA instead:</p>
<div class="sourceCode" id="cb10"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo 1AA2AA3AA2BA..CDEFGHIJKLMNOPQRIOCCC<span class="kw">|</span><span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="ex">HQNVO</span></span></code></pre></div>
<h1 id="only-write-config-file"><a name="onlyconfig" href="#toc">Only
write config file</a></h1>
<div class="sourceCode" id="cb11"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-v</span> <span class="at">-oconfig</span> <span class="at">-finput</span> <span class="op">&gt;</span>/dev/null</span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Rotors:</span></span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">1</span><span class="kw">)</span> <span class="ex">I:</span> EKMFLGDQVZNTOWYHXUSPAIBRCJ</span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">2</span><span class="kw">)</span> <span class="ex">II:</span> AJDKSIRUXBLHWTMCQGZNPYFVOE</span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">3</span><span class="kw">)</span> <span class="ex">III:</span> BDFHJLCPRTXVZNYEIWGAKMUSQO</span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">4</span><span class="kw">)</span> <span class="ex">IV:</span> ESOVPZJAYQUIRHXLNFTGKDCMWB</span>
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">5</span><span class="kw">)</span> <span class="ex">V:</span> VZBRGITYUPSDNHLXAWMJQOFECK</span>
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> rotor 1 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 1</span>
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> rotor 2 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 2</span>
<span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> rotor 3 <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 5<span class="kw">)</span><span class="bu">:</span> 3</span>
<span id="cb11-11"><a href="#cb11-11" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> setting 1 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> A</span>
<span id="cb11-12"><a href="#cb11-12" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> setting 2 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> C</span>
<span id="cb11-13"><a href="#cb11-13" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> setting 3 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> E</span>
<span id="cb11-14"><a href="#cb11-14" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> position 1 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> B</span>
<span id="cb11-15"><a href="#cb11-15" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> position 2 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> D</span>
<span id="cb11-16"><a href="#cb11-16" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> position 3 <span class="er">(</span><span class="ex">A</span> <span class="at">-</span> Z<span class="kw">)</span><span class="bu">:</span> F</span>
<span id="cb11-17"><a href="#cb11-17" aria-hidden="true" tabindex="-1"></a><span class="ex">Reflector:</span></span>
<span id="cb11-18"><a href="#cb11-18" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">1</span><span class="kw">)</span> <span class="kw">(</span><span class="ex">B</span><span class="kw">)</span> <span class="ex">YRUHQSLDPXNGOKMIEBFZCWVJAT</span></span>
<span id="cb11-19"><a href="#cb11-19" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">2</span><span class="kw">)</span> <span class="kw">(</span><span class="ex">C</span><span class="kw">)</span> <span class="ex">FVPJIAOYEDRZXWGCTKUQSBNMHL</span></span>
<span id="cb11-20"><a href="#cb11-20" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> reflector <span class="er">(</span><span class="ex">1</span> <span class="at">-</span> 2<span class="kw">)</span><span class="bu">:</span> 2</span>
<span id="cb11-21"><a href="#cb11-21" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 1: AB</span>
<span id="cb11-22"><a href="#cb11-22" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 2: CD</span>
<span id="cb11-23"><a href="#cb11-23" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 3: EF</span>
<span id="cb11-24"><a href="#cb11-24" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 4: GHIJ</span>
<span id="cb11-25"><a href="#cb11-25" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 5: IJ</span>
<span id="cb11-26"><a href="#cb11-26" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 6: KL</span>
<span id="cb11-27"><a href="#cb11-27" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 7: MN</span>
<span id="cb11-28"><a href="#cb11-28" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 8: OP</span>
<span id="cb11-29"><a href="#cb11-29" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 9: QR</span>
<span id="cb11-30"><a href="#cb11-30" aria-hidden="true" tabindex="-1"></a><span class="ex">Input</span> plugboard pair 10: ST</span>
<span id="cb11-31"><a href="#cb11-31" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 1: <span class="er">(</span> <span class="ex">I</span><span class="kw">)</span> <span class="ex">EKMFLGDQVZNTOWYHXUSPAIBRCJ</span></span>
<span id="cb11-32"><a href="#cb11-32" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 2: <span class="er">(</span> <span class="ex">II</span><span class="kw">)</span> <span class="ex">AJDKSIRUXBLHWTMCQGZNPYFVOE</span></span>
<span id="cb11-33"><a href="#cb11-33" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> 3: <span class="er">(</span><span class="ex">III</span><span class="kw">)</span> <span class="ex">BDFHJLCPRTXVZNYEIWGAKMUSQO</span></span>
<span id="cb11-34"><a href="#cb11-34" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> settings: ACE</span>
<span id="cb11-35"><a href="#cb11-35" aria-hidden="true" tabindex="-1"></a><span class="ex">Ring</span> positions: BDF</span>
<span id="cb11-36"><a href="#cb11-36" aria-hidden="true" tabindex="-1"></a><span class="ex">Reflector:</span> <span class="er">(</span><span class="ex">C</span><span class="kw">)</span> <span class="ex">FVPJIAOYEDRZXWGCTKUQSBNMHL</span></span>
<span id="cb11-37"><a href="#cb11-37" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#01: AB</span></span>
<span id="cb11-38"><a href="#cb11-38" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#02: CD</span></span>
<span id="cb11-39"><a href="#cb11-39" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#03: EF</span></span>
<span id="cb11-40"><a href="#cb11-40" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#04: GH</span></span>
<span id="cb11-41"><a href="#cb11-41" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#05: IJ</span></span>
<span id="cb11-42"><a href="#cb11-42" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#06: KL</span></span>
<span id="cb11-43"><a href="#cb11-43" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#07: MN</span></span>
<span id="cb11-44"><a href="#cb11-44" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#08: OP</span></span>
<span id="cb11-45"><a href="#cb11-45" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#09: QR</span></span>
<span id="cb11-46"><a href="#cb11-46" aria-hidden="true" tabindex="-1"></a><span class="ex">Plugboard</span> pair <span class="co">#10: ST</span></span></code></pre></div>
<p>Notice that I redirect stdout to /dev/null so that the config is only
written to the file config. But also notice that for <a
href="https://www.cryptomuseum.com/crypto/enigma/i/sb.htm">plugboard
pair</a> 4 I typed in <code>GHIJ</code> and it didn’t report an error.
Neither did it complain about <code>IJ</code> in the next pair. This is
because it consumes input overflow.</p>
<p>It shouldn’t be this way for the simulator though because that could
cause inconsistent number of characters expected before the text to
encipher.</p>
<div class="sourceCode" id="cb12"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat config</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a><span class="ex">1AB2CD3EF2ABCDEFGHIJKLMNOPQRST</span></span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> <span class="er">(</span> <span class="fu">cat</span> config <span class="kw">;</span> <span class="fu">cat</span> input <span class="kw">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a><span class="ex">LRAVE</span></span>
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> <span class="er">(</span> <span class="fu">cat</span> config <span class="kw">;</span> <span class="fu">cat</span> input <span class="kw">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="kw">(</span> <span class="fu">cat</span> config <span class="kw">;</span> <span class="bu">echo</span> LRAVE <span class="kw">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span></code></pre></div>
<p>What if you don’t want to worry about having to specify input but
just have the settings written? You can do that too by either sending a
newline or else directly type ctrl-d (or whatever you have EOF set to)
or give it an empty file.</p>
<p>The following are all equivalent in that they will write to a
settings file (the first one will print a newline with the echo but that
won’t matter):</p>
<div class="sourceCode" id="cb13"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-r</span> <span class="at">-osettings</span></span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo <span class="at">-n</span> <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-r</span> <span class="at">-osettings</span></span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> <span class="op">&gt;</span> empty</span>
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-r</span> <span class="at">-osettings</span> <span class="op">&lt;</span> empty</span>
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat empty <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-r</span> <span class="at">-osettings</span></span>
<span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-r</span> <span class="at">-osettings</span></span>
<span id="cb13-7"><a href="#cb13-7" aria-hidden="true" tabindex="-1"></a><span class="ex">^D</span></span></code></pre></div>
<p>(Above ^D was not shown but I typed it.) The way it works: if nothing
is read 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
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 class="sourceCode" id="cb14"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo <span class="at">-n</span><span class="kw">|</span><span class="ex">./recode</span> <span class="at">-r</span> <span class="at">-oconfig</span></span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="ex">4UH5II1RJ1SPIFEJLYGZWRTBHVCAMN$</span></span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat input.txt</span>
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span> 2020 Enigma simulator example text file</span>
<span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a><span class="ex">This</span> is a sentence.</span>
<span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-9"><a href="#cb14-9" aria-hidden="true" tabindex="-1"></a><span class="ex">This</span> is another sentence.</span>
<span id="cb14-10"><a href="#cb14-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-11"><a href="#cb14-11" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> <span class="er">(</span> <span class="fu">cat</span> config <span class="kw">;</span> <span class="fu">cat</span> input.txt <span class="kw">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="op">&gt;</span> output</span>
<span id="cb14-12"><a href="#cb14-12" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat output</span>
<span id="cb14-13"><a href="#cb14-13" aria-hidden="true" tabindex="-1"></a><span class="ex">AAPRT</span> 2020 Dkemny tpgnjsjai xpovrgl jvgs wxra</span>
<span id="cb14-14"><a href="#cb14-14" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-15"><a href="#cb14-15" aria-hidden="true" tabindex="-1"></a><span class="ex">Fytt</span> ly m xyiilaqh.</span>
<span id="cb14-16"><a href="#cb14-16" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-17"><a href="#cb14-17" aria-hidden="true" tabindex="-1"></a><span class="ex">Ybbp</span> ox dmuzerm oscwgytb.</span>
<span id="cb14-18"><a href="#cb14-18" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> <span class="er">(</span> <span class="fu">cat</span> config <span class="kw">;</span> <span class="fu">cat</span> output <span class="kw">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="op">&gt;</span> io</span>
<span id="cb14-19"><a href="#cb14-19" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> diff io input.txt</span>
<span id="cb14-20"><a href="#cb14-20" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span></span></code></pre></div>
<p>Alternatively you can just use the <code>-R</code> and
<code>-f</code> options:</p>
<div class="sourceCode" id="cb15"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-finput.txt</span> <span class="at">-Rconfig</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="op">&gt;</span> output2</span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> diff output output2</span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span></span></code></pre></div>
<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>
<pre><code>$ ./recode -finput.txt -oconfig | ./prog - 2&gt;/dev/null &gt; output
Rotors:
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
(2) II: AJDKSIRUXBLHWTMCQGZNPYFVOE
(3) III: BDFHJLCPRTXVZNYEIWGAKMUSQO
(4) IV: ESOVPZJAYQUIRHXLNFTGKDCMWB
(5) V: VZBRGITYUPSDNHLXAWMJQOFECK
Input rotor 1 (1 - 5): 2
Input rotor 2 (1 - 5): 5
Input rotor 3 (1 - 5): 3
Input setting 1 (A - Z): C
Input setting 2 (A - Z): O
Input setting 3 (A - Z): D
Input position 1 (A - Z): E
Input position 2 (A - Z): L
Input position 3 (A - Z): O
Reflector:
(1) (B) YRUHQSLDPXNGOKMIEBFZCWVJAT
(2) (C) FVPJIAOYEDRZXWGCTKUQSBNMHL
Input reflector (1 - 2): 2
Input plugboard pair 1: TR
Input plugboard pair 2: SN
Input plugboard pair 3: OG
Input plugboard pair 4: ME
Input plugboard pair 5: XY
Input plugboard pair 6: WZ
Input plugboard pair 7: UV
Input plugboard pair 8: AB
Input plugboard pair 9: CD
Input plugboard pair 10: FI
$ cat config
2CE5OL3DO2TRSNOGMEXYWZUVABCDFI</code></pre>
<p>Besides a famous book that I happen to love (who doesn’t? Ah, but
what is it Cody?) there’s also a reference to code which I also love
(just as all participants of the IOCCC do). Other things there don’t
mean anything but what does is the output:</p>
<div class="sourceCode" id="cb17"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat output</span>
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a><span class="ex">DBFAF</span> 2020 Ittejg ltblwriac uqdfqvr dhqh ghhf</span>
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a><span class="ex">Jsjy</span> ce v pxdmullo.</span>
<span id="cb17-5"><a href="#cb17-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-6"><a href="#cb17-6" aria-hidden="true" tabindex="-1"></a><span class="ex">Sara</span> tj rtaayak uxfhjcti.</span>
<span id="cb17-7"><a href="#cb17-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-8"><a href="#cb17-8" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-Rconfig</span> <span class="at">-foutput</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb17-9"><a href="#cb17-9" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span> 2020 Enigma simulator example text file</span>
<span id="cb17-10"><a href="#cb17-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-11"><a href="#cb17-11" aria-hidden="true" tabindex="-1"></a><span class="ex">This</span> is a sentence.</span>
<span id="cb17-12"><a href="#cb17-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-13"><a href="#cb17-13" aria-hidden="true" tabindex="-1"></a><span class="ex">This</span> is another sentence.</span></code></pre></div>
<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>
<p>This is like the above only randomised:</p>
<div class="sourceCode" id="cb18"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./recode <span class="at">-r</span> <span class="at">-oconfig</span><span class="kw">|</span><span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a><span class="ex">UGEVP</span></span></code></pre></div>
<p>Note that I typed in <code>IOCCC</code> and sent <code>EOF</code>
(ctrl-d); the settings were written to the config file (for deciphering
later) and then all of it was piped to the Enigma entry resulting in the
line below IOCCC. But let’s verify it worked out okay:</p>
<div class="sourceCode" id="cb19"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat config</span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a><span class="ex">2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ</span></span></code></pre></div>
<p>Without having to copy/paste intermediate results:</p>
<div class="sourceCode" id="cb20"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo IOCCC <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-Rconfig</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-Rconfig</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span></code></pre></div>
<p>You can also use a string for the <code>-R</code> option. I’ll use
command substitution and actual pasting to demonstrate:</p>
<div class="sourceCode" id="cb21"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo IOCCC <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-R</span><span class="va">$(</span><span class="fu">cat</span> config<span class="va">)</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null <span class="kw">|</span> <span class="ex">./recode</span> <span class="at">-R2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a><span class="ex">IOCCC</span></span></code></pre></div>
<h1 id="usage-conclusion"><a name="conclusion" href="#toc">Usage
conclusion</a></h1>
<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 ideas of what could be done and how this
entry might be used (including that delicious challenge).</p>
<h1 id="example-additions"><a name="additions" href="#toc">Example
additions</a></h1>
<ul>
<li>Add code (to <a href="prog.c">prog.c</a>) that tries to determine
possible decipherments based on a given crib (or set of cribs).</li>
</ul>
<h1 id="example-uses"><a name="exampleuses" href="#toc">Example
uses</a></h1>
<ul>
<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 reasons I explained in the remarks (including
that I cannot easily verify one particular as well as the fact that
there were different procedures, different machines etc. - plus my
vision is not good enough for the quality of the pictures).</p></li>
<li><p>Try making sense of a politician’s speeches by putting them into
the simulator. It might not make much sense but can it honestly be that
much worse ? :) Actually yes it could be (and we don’t need the Enigma
helping them either) and I can think of a whole host of other things
more entertaining including watching dry paint stay dry on a wall but
why not poke fun at politicians anyway?</p></li>
<li><p>Best idea: try the below experiment!</p></li>
</ul>
<h1
id="deliciously-enigmatic-double-layered-chocolate-fudge-cake"><a name="cake" href="#toc">Deliciously
Enigmatic: Double-layered Chocolate Fudge Cake</a></h1>
<p>As I was making the above silly list something occurred to me. My <a
href="/2020/ferguson1/prog.c">other entry</a> this year includes a
recipe for a wonderful double-layered chocolate fudge cake but why would
it not be included in this one too? But then if that’s the case why on
Earth should it be unscrambled?</p>
<p>So this is what I offer: if you take one of the settings below and
run the simulator on the file <a
href="chocolate-cake.html">chocolate-cake.html</a> you will have a
wonderful chocolate cake recipe (that even my late stepmum who didn’t
even like chocolate loved - it’s a speciality of my mum’s and they were
the best of friends too). If you’re lazy (or just want some delicious
double-layered chocolate fudge cake!) just go and look at the <a
href="../ferguson1/chocolate-cake.html">recipe</a> (or <a
href="../ferguson1/chocolate-cake.md">here</a> if on GitHub) in my other
entry. Then again if you’re lazy you’re probably not reading this far!
:)</p>
<p>The settings is one of the below but a couple questions you might ask
yourself:</p>
<ol type="1">
<li><p>Are any invalid input?</p></li>
<li><p>Is there some other kind of trickery involved here?</p></li>
</ol>
<p>I can think of the best way to answer these and I think I need not
even mention it. Have fun and enjoy!</p>
<p>BTW: Depending on where you are in this world and how warm it is the
icing can be a bit of an issue - I give some ideas in the file on what
can be done for this. At worst though the icing won’t come out as good
as it usually does. That’s assuming you follow in the instructions
exactly as they are; it’s a very picky recipe.</p>
<h2 id="hints">Hints:</h2>
<ol type="1">
<li><p>It’s not the middle one.</p></li>
<li><p>Yes there are some things kind of spelt here. These include
things about cake and chocolate. Some things spelt mean nothing whatever
and can be considered coincidences. Some were randomised.</p></li>
<li><p>There is an obscure thing about my entry that can help locate the
proper key of the 16 given below! The questions are what is it and is is
it worth going this way? (I think the second answer is ‘no’ but that’s
me.)</p></li>
<li><p>The above points might or might not be relevant. What is relevant
is one will reveal a wonderful <a
href="chocolate-cake.html">Double-layered Chocolate Fudge Cake</a>
recipe:</p></li>
</ol>
<pre><code> 142CHOCOLATESVCAKESTBJLKMUMVWX
0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI
3UY0XF4QG1GTJQLARPKHBEMCOFVUIN
0WE1HK4PL0RVSGXFDKENZYTPCMAHUW
2LV0KC1IE0HTFPCLWOJDBQIRVMEAGN
1SS4QX2RY1SRAQGKUYHCBLPFJDVTNZ
3IW1QR0TZ0GQEDWIYJUPMFZBRAONHS
3OP1KN4MO0HPFZCEAKYQIRXGVMOTUW
4OC2CC0AK1CODELUVRSNGKIZBJPTMY
4MU0MS1CA1KELUVRSXTABJNOCDMQFG
0MU4MC2HO1CLATEFBJMONPQRVWXYZD
125CHOCOLATESEXCAKESJADFNOPQRS
0CH3OC1OL1ATEMBJNOCDLSIFWHRVXY
4MU1MS3CA0KECHOLATBJSNPXVUFGZY
4VW0SL1YB0IYJSLBECKTNAXGPUVHRF
0MC4OH2CO1LATEUMBJCDFGHINOPRQS</code></pre>
<p>BTW: What’s the middle of a list with even numbered items anyway?</p>
<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<tbody>
<tr class="odd">
<td>(c) Copyright 1984-2020, [Leo Broukhis, Simon Cooper, Landon Curt
Noll][judges] - All rights reserved This work is licensed under a
[Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].</td>
</tr>
<tr class="even">
<td>[judges]: https://www.ioccc.org/judges.html [cc]:
http://creativecommons.org/licenses/by-sa/3.0/</td>
</tr>
</tbody>
</table>
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/end-row.default.html -->
</div>
<!-- END: this line ends content from: inc/end-row.default.html -->
<!-- START: this line starts content from: inc/footer.default.html -->
<div class="footer">
<hr>
<h2>Coda</h2>
<p><a href="https://validator.w3.org/nu/?doc=#">Nu HTML check this web page</a></p>
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
</div>
<!-- END: this line ends content from: inc/footer.default.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->
+8 -8
View File
@@ -9,14 +9,6 @@
{ "author_handle" : "Edward_Giles" }
],
"manifest" : [
{
"file_path" : "index.html",
"inventory_order" : 10,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : "prog.c",
"inventory_order" : 20,
@@ -65,6 +57,14 @@
"display_via_github" : false,
"entry_text" : "download entry source"
},
{
"file_path" : "index.html",
"inventory_order" : 2000000000,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : ".entry.json",
"inventory_order" : 4294967295,
+2 -1
View File
@@ -273,9 +273,9 @@ https://creativecommons.org/licenses/by-sa/4.0/</p>
<h1 id="inventory-for-2020giles"><a name="inventory"></a>Inventory for
2020/giles</h1>
<p><a href="#top">Jump to top</a></p>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/giles/prog.c">prog.c</a>
- entry source</li>
@@ -295,6 +295,7 @@ source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/giles/.entry.json">.entry.json</a>
- description of entry in JSON</li>
+19 -24
View File
@@ -194,35 +194,30 @@ Entries of 2020 - The 27th IOCCC</h1>
<p><strong>Download IOCCC</strong> <a
href="2020/ioccc.2020.tar.bz2">2020 entry source</a></p>
<ul>
<li><a href="2020/burton/index.html">2020/burton</a> - Best
one-liner</li>
<li><a href="2020/carlini/index.html">2020/carlini</a> - Best of show -
abuse of libc</li>
<li><a href="2020/endoh1/index.html">2020/endoh1</a> - Most
explosive</li>
<li><a href="2020/endoh2/index.html">2020/endoh2</a> - Best
perspective</li>
<li><a href="2020/endoh3/index.html">2020/endoh3</a> - Most
head-turning</li>
<li><a href="2020/ferguson1/index.html">2020/ferguson1</a> - Don’t tread
on me award</li>
<li><a href="2020/ferguson2/index.html">2020/ferguson2</a> - Most
<li><a href="burton/index.html">2020/burton</a> - Best one-liner</li>
<li><a href="carlini/index.html">2020/carlini</a> - Best of show - abuse
of libc</li>
<li><a href="endoh1/index.html">2020/endoh1</a> - Most explosive</li>
<li><a href="endoh2/index.html">2020/endoh2</a> - Best perspective</li>
<li><a href="endoh3/index.html">2020/endoh3</a> - Most head-turning</li>
<li><a href="ferguson1/index.html">2020/ferguson1</a> - Don’t tread on
me award</li>
<li><a href="ferguson2/index.html">2020/ferguson2</a> - Most
enigmatic</li>
<li><a href="2020/giles/index.html">2020/giles</a> - Most phony</li>
<li><a href="2020/kurdyukov1/index.html">2020/kurdyukov1</a> - Best
<li><a href="giles/index.html">2020/giles</a> - Most phony</li>
<li><a href="kurdyukov1/index.html">2020/kurdyukov1</a> - Best
utility</li>
<li><a href="2020/kurdyukov2/index.html">2020/kurdyukov2</a> - Least
<li><a href="kurdyukov2/index.html">2020/kurdyukov2</a> - Least
detailed</li>
<li><a href="2020/kurdyukov3/index.html">2020/kurdyukov3</a> - Bset
slaml prragom</li>
<li><a href="2020/kurdyukov4/index.html">2020/kurdyukov4</a> - Best
abuse of lámatyávë</li>
<li><a href="2020/otterness/index.html">2020/otterness</a> - Most
<li><a href="kurdyukov3/index.html">2020/kurdyukov3</a> - Bset slaml
prragom</li>
<li><a href="kurdyukov4/index.html">2020/kurdyukov4</a> - Best abuse of
lámatyávë</li>
<li><a href="otterness/index.html">2020/otterness</a> - Most
percussive</li>
<li><a href="2020/tsoj/index.html">2020/tsoj</a> - Most misleading
<li><a href="tsoj/index.html">2020/tsoj</a> - Most misleading
indentation</li>
<li><a href="2020/yang/index.html">2020/yang</a> - Best abuse of
CPP</li>
<li><a href="yang/index.html">2020/yang</a> - Best abuse of CPP</li>
</ul>
<p> <strong>Jump to:</strong> <a href="#">top</a></p>
+8 -8
View File
@@ -9,14 +9,6 @@
{ "author_handle" : "Ilya_Kurdyukov" }
],
"manifest" : [
{
"file_path" : "index.html",
"inventory_order" : 10,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : "prog.c",
"inventory_order" : 20,
@@ -89,6 +81,14 @@
"display_via_github" : false,
"entry_text" : "download entry source"
},
{
"file_path" : "index.html",
"inventory_order" : 2000000000,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : ".entry.json",
"inventory_order" : 4294967295,
+2 -1
View File
@@ -223,9 +223,9 @@ https://creativecommons.org/licenses/by-sa/4.0/</p>
<h1 id="inventory-for-2020kurdyukov1"><a name="inventory"></a>Inventory
for 2020/kurdyukov1</h1>
<p><a href="#top">Jump to top</a></p>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov1/prog.c">prog.c</a>
- entry source</li>
@@ -255,6 +255,7 @@ download entry source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov1/.entry.json">.entry.json</a>
- description of entry in JSON</li>
+8 -8
View File
@@ -9,14 +9,6 @@
{ "author_handle" : "Ilya_Kurdyukov" }
],
"manifest" : [
{
"file_path" : "index.html",
"inventory_order" : 10,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : "prog.c",
"inventory_order" : 20,
@@ -89,6 +81,14 @@
"display_via_github" : false,
"entry_text" : "download entry source"
},
{
"file_path" : "index.html",
"inventory_order" : 2000000000,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : ".entry.json",
"inventory_order" : 4294967295,
+2 -1
View File
@@ -227,9 +227,9 @@ https://creativecommons.org/licenses/by-sa/4.0/</p>
<h1 id="inventory-for-2020kurdyukov2"><a name="inventory"></a>Inventory
for 2020/kurdyukov2</h1>
<p><a href="#top">Jump to top</a></p>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov2/prog.c">prog.c</a>
- entry source</li>
@@ -257,6 +257,7 @@ download entry source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov2/.entry.json">.entry.json</a>
- description of entry in JSON</li>
+8 -8
View File
@@ -9,14 +9,6 @@
{ "author_handle" : "Ilya_Kurdyukov" }
],
"manifest" : [
{
"file_path" : "index.html",
"inventory_order" : 10,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : "prog.c",
"inventory_order" : 20,
@@ -81,6 +73,14 @@
"display_via_github" : false,
"entry_text" : "download entry source"
},
{
"file_path" : "index.html",
"inventory_order" : 2000000000,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : ".entry.json",
"inventory_order" : 4294967295,
+2 -1
View File
@@ -178,9 +178,9 @@ https://creativecommons.org/licenses/by-sa/4.0/</p>
<h1 id="inventory-for-2020kurdyukov3"><a name="inventory"></a>Inventory
for 2020/kurdyukov3</h1>
<p><a href="#top">Jump to top</a></p>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov3/prog.c">prog.c</a>
- entry source</li>
@@ -207,6 +207,7 @@ download entry source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov3/.entry.json">.entry.json</a>
- description of entry in JSON</li>
+8 -8
View File
@@ -9,14 +9,6 @@
{ "author_handle" : "Ilya_Kurdyukov" }
],
"manifest" : [
{
"file_path" : "index.html",
"inventory_order" : 10,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : "prog.c",
"inventory_order" : 20,
@@ -81,6 +73,14 @@
"display_via_github" : false,
"entry_text" : "download entry source"
},
{
"file_path" : "index.html",
"inventory_order" : 2000000000,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : ".entry.json",
"inventory_order" : 4294967295,
+2 -1
View File
@@ -239,9 +239,9 @@ https://creativecommons.org/licenses/by-sa/4.0/</p>
<h1 id="inventory-for-2020kurdyukov4"><a name="inventory"></a>Inventory
for 2020/kurdyukov4</h1>
<p><a href="#top">Jump to top</a></p>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov4/prog.c">prog.c</a>
- entry source</li>
@@ -268,6 +268,7 @@ download entry source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov4/.entry.json">.entry.json</a>
- description of entry in JSON</li>
+8 -8
View File
@@ -9,14 +9,6 @@
{ "author_handle" : "Nathan_Otterness" }
],
"manifest" : [
{
"file_path" : "index.html",
"inventory_order" : 10,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : "prog.c",
"inventory_order" : 20,
@@ -73,6 +65,14 @@
"display_via_github" : false,
"entry_text" : "download entry source"
},
{
"file_path" : "index.html",
"inventory_order" : 2000000000,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : ".entry.json",
"inventory_order" : 4294967295,
+2 -1
View File
@@ -263,9 +263,9 @@ https://creativecommons.org/licenses/by-sa/4.0/</p>
<h1 id="inventory-for-2020otterness"><a name="inventory"></a>Inventory
for 2020/otterness</h1>
<p><a href="#top">Jump to top</a></p>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/otterness/prog.c">prog.c</a>
- entry source</li>
@@ -286,6 +286,7 @@ download entry source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/otterness/.entry.json">.entry.json</a>
- description of entry in JSON</li>
+8 -8
View File
@@ -9,14 +9,6 @@
{ "author_handle" : "Tsoj" }
],
"manifest" : [
{
"file_path" : "index.html",
"inventory_order" : 10,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : "prog.c",
"inventory_order" : 20,
@@ -57,6 +49,14 @@
"display_via_github" : false,
"entry_text" : "download entry source"
},
{
"file_path" : "index.html",
"inventory_order" : 2000000000,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : ".entry.json",
"inventory_order" : 4294967295,
+2 -1
View File
@@ -237,9 +237,9 @@ https://creativecommons.org/licenses/by-sa/4.0/</p>
<h1 id="inventory-for-2020tsoj"><a name="inventory"></a>Inventory for
2020/tsoj</h1>
<p><a href="#top">Jump to top</a></p>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/tsoj/prog.c">prog.c</a>
- entry source</li>
@@ -257,6 +257,7 @@ source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/tsoj/.entry.json">.entry.json</a>
- description of entry in JSON</li>
+8 -8
View File
@@ -9,14 +9,6 @@
{ "author_handle" : "Don_Yang" }
],
"manifest" : [
{
"file_path" : "index.html",
"inventory_order" : 10,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : "prog.c",
"inventory_order" : 20,
@@ -73,6 +65,14 @@
"display_via_github" : false,
"entry_text" : "download entry source"
},
{
"file_path" : "index.html",
"inventory_order" : 2000000000,
"OK_to_edit" : false,
"display_as" : "html",
"display_via_github" : false,
"entry_text" : "entry home page"
},
{
"file_path" : ".entry.json",
"inventory_order" : 4294967295,
+2 -1
View File
@@ -244,9 +244,9 @@ https://creativecommons.org/licenses/by-sa/4.0/</p>
<h1 id="inventory-for-2020yang"><a name="inventory"></a>Inventory for
2020/yang</h1>
<p><a href="#top">Jump to top</a></p>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/yang/prog.c">prog.c</a>
- entry source</li>
@@ -268,6 +268,7 @@ source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="index.html">index.html</a> - entry home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/yang/.entry.json">.entry.json</a>
- description of entry in JSON</li>