Truly complete 2024/ferguson1 and litmus test

The truly complete part is a reference to commit
ad622a5354. This also means that prog.c
need never be updated again, which was the entire point of that commit
that fell just short of the mark.

Fixed links in obfuscation.html.

Added litmus test to explain how I actually tested the program with all
the jumps.

Fixed typo in data file that I discovered during the above litmus test.

Fixed other files as well.

The .entry.json had a minor mod too, to better reflect what a file
actually is.

Rebuilt obfuscation.html and index.html.

Added target to Makefile which was also used during testing (this might
be explained in the obfuscation.html).
This commit is contained in:
Cody Boone Ferguson committed 2025-08-18 08:50:37 -07:00
1 parent 7bd60f26ac
commit 5455784566
14 files changed
+401 -197

No files matched your search

+133 -49
View File
@@ -486,7 +486,7 @@ Harmful”</a></em>.
See the Communications of the ACM, March 1987, Page 195-196.</p>
</blockquote>
<p>(I refute some things in my program that directly contradicts Frank’s
letter in amusing or at least instructional ways in my <a href="#devil">remarks above</a>.</p>
letter in amusing or at least instructional ways in my <a href="index.html#devil">remarks</a>.</p>
<p>I added bold to logical conclusion because I wanted to stress this. I’m afraid
they were wrong, oh so very VERY <strong>VERY</strong> WRONG. 24 <code>goto</code>s, according to
<code>hines</code> itself, is not the <code>goto</code> logical conclusion. I agree it’s a beautiful
@@ -495,11 +495,11 @@ counter-example for that letter but oh is everyone in for a HUGE SHOCK!</p>
too many, even in a large program, let alone a small one. Even one <code>goto</code> is too
many. Unless I am very much mistaken, I have broken the record by a huge margin.</p>
<p>Here’s the horrifying and hilarious truth: I beat it out by <del>92</del> 107
MORE, <strong>BEFORE</strong> the cpp at <del>116</del> 131 and after the cpp is through I
beat it by <strong>125</strong> MORE (!!), <strong>AT 149!</strong> Yes, you read that right.
<del>134</del> 149 <code>goto</code>s! The originally submitted prog.c, submitted for
practical reasons only, had it at, as might be guessed, 116/134 before and after
the cpp.</p>
MORE, <strong>BEFORE</strong> the cpp at <del>116</del> 134 and after the cpp is through I
beat it by <strong>128</strong> MORE (!!), <strong>AT 152!</strong> Yes, you read that right.
<del>134</del> 152 <code>goto</code>s! The originally submitted prog.c, submitted for
practical reasons only, had it at, as might be guessed from above, 116/134
before and after the cpp.</p>
<p>Even removing what I think were the only dead <code>goto</code>s in the incomplete version,
two of them, including one that is in the <code>w()</code> macro that would be translated
into more, I beat it by 90 more, at 114 before the cpp, and 99 more after the
@@ -509,26 +509,26 @@ MEASLY 109? THIS SHOULD NOT HAPPEN. Well it did happen and this HAS to be a
joke, right? I’m sorry but it is NOT a joke. I am for real. There REALLY are
that many and that is ridiculous.</p>
<p>Okay so it’s a joke in another way but nonetheless YES I <strong>REALLY DID</strong> put in
<del>116/134</del> 131/149 <code>goto</code>s, depending on if you pre-process it or not!
<del>116/134</del> 134/152 <code>goto</code>s, depending on if you pre-process it or not!
YES I might be mad. YES I think it’s HILARIOUS. But if it was not for the
IOCCC… Well, as I mention in my <a href="#devil">remarks above</a>, EVEN ONE IS TOO MANY
IOCCC… Well, as I mention in my <a href="index.html#devil">remarks above</a>, EVEN ONE IS TOO MANY
in real code.</p>
<p>I dare you to run the program in a debugger from start to finish to see how many
line jumps there truly are. After I won I did it once: removing the <code>#include</code>s,
blank lines, lines with only variables and lines with just braces (i.e. only
lines of code) the program has just 58 lines and in a single run there were a
lines of code) the program has just 55 lines and in a single run there were a
total of <strong>1416</strong> (!) line changes, counting function calls. In <code>main()</code> itself
the line changed a total of <strong>1131</strong> (!) times!</p>
<p>The best (or worst, depending on how you look at it :-) ) part is this works. As
I note in those concluding remarks, a <a href="https://www.apple.com">nameless company</a>
actually introduced a security hole from ONE <code>goto</code>. Yet I have
<del>116/134</del> 131/149 and it actually works? That is surely obscene. And
<del>116/134</del> 134/152 and it actually works? That is surely obscene. And
beautiful. But wrong.</p>
<p>Oh and BTW: it appears that <code>hines</code> is a bit confused about my entry, though I’m
not really sure why. In any case, I not only have dethroned <code>hines</code> (sorry
…but also not sorry!) but I have, as noted already, beaten the original BASIC
game by <del>7</del> 22 more <code>goto</code>s at <del>116</del> 131 before the cpp
and <del><strong>18 MORE</strong></del> <strong>40 MORE</strong> after the cpp, at 149!</p>
game by <del>7</del> 25 more <code>goto</code>s at <del>116</del> 134 before the cpp
and <del><strong>18 MORE</strong></del> <strong>43 MORE</strong> after the cpp, at 152!</p>
<p>It’s almost impossible to add more <code>goto</code>s. With the iocccsize it is impossible,
if I don’t want to sacrifice the rest of the program. You’ll see why soon. But
even if that was not the case I wanted room for the other things I did, some of
@@ -542,7 +542,7 @@ in general, where code can be, where labels can be, really everything: the code
is in all the wrong places.</p>
<p>This is not counting other cool things like a single <code>char *</code> holding near 200
<code>char *</code>s. No. I do not mean an array of <code>char *</code>s! I mean a single flat <code>char *</code>! Yet in the code I index it AS IF it’s a <code>char *[]</code>, just to add to the
confusion (as if the <del>134</del> 149 <code>goto</code>s are not bad enough). But it’s
confusion (as if the <del>134</del> 152 <code>goto</code>s are not bad enough). But it’s
not a <code>char *[]</code>. It’s a single <code>char *</code>, which is the contents of the data
file.</p>
<p>There are other things I have done, of course.</p>
@@ -594,15 +594,15 @@ have lost my mind this program sure as hell lost its mind! And it’s my fault.
Hilarious.</p>
<p>Counting whitespace this program is only 4666 bytes according to <code>wc -c</code> (macOS
at the least, maybe others): quite intentionally to be on theme. That’s a
relatively short program to have <del>116</del> 131 <code>goto</code>s or more when
filtered through <code>cc -E</code> (<del>134</del> 149!), wouldn’t you say? If that’s NOT
relatively short program to have <del>116</del> 134 <code>goto</code>s or more when
filtered through <code>cc -E</code> (<del>134</del> 152!), wouldn’t you say? If that’s NOT
too many, then I ask you WHAT IS?</p>
<p>As said in numerous places, IT IS MUCH SMALLER than the BASIC file I included
even after stripping it of much of it. My program also has more events. I think
the BASIC one has 16 not counting the mountains code and mine is 23 not counting
the mountains code, which obviously I also include and has more events (if we
count the doctor visits an event then even more).</p>
<p>I discuss this some in my concluding <a href="#devil">remarks above</a>, as well as
<p>I discuss this some in my concluding <a href="index.html#devil">remarks above</a>, as well as
mentioning that there are other events besides those 23. I certainly will not
reveal all though. The humour and jokes sections of that file says more but the
concluding remarks are for a summary and why I think that this code is worthy of
@@ -631,7 +631,7 @@ code, as this program also shows. It’s just that the amount of <code>goto</cod
the worst of it as you never know where the program will be next, and that’s
putting it in a simpler way. Much, much, MUCH simpler way, in fact, as you’ll
see.</p>
<p>Either way this program, and I mention this in my <a href="#devil">remarks above</a> in an
<p>Either way this program, and I mention this in my <a href="index.html#devil">remarks above</a> in an
admittedly long editorial plea (although it does it by going over what I have
done in simpler terms than this file), serves as a public service, warning about
<code>goto</code>. The article about goto considered harmful has nothing against this, or
@@ -640,8 +640,8 @@ been mad enough to do what I have done.</p>
<p>Here are some fun statistics from a somewhat rudimentary program on both the
prog.c and after filtered through <code>cc -E</code>. First prog.c. Prepare to be
horrified, if you’re not already:</p>
<pre><code> 131 goto
301 semicolon
<pre><code> 134 goto
304 semicolon
143 colon
51 if
11 else
@@ -662,10 +662,10 @@ horrified, if you’re not already:</p>
1 char
1 size_t
Ratio: 1.01 gotos per keyword</code></pre>
<p>1.01 goto per keyword? But then there’s the cpp filtered code…</p>
<pre><code> 149 goto
339 semicolon
Ratio: 1.03 gotos per keyword</code></pre>
<p>1.03 goto per keyword? But then there’s the cpp filtered code…</p>
<pre><code> 152 goto
342 semicolon
143 colon
51 if
11 else
@@ -686,9 +686,13 @@ horrified, if you’re not already:</p>
1 char
1 size_t
Ratio: 1.11 gotos per keyword</code></pre>
<p>1.11!</p>
<p>For comparison, here is the original version:</p>
Ratio: 1.13 gotos per keyword</code></pre>
<p>1.13! Did you also notice that despite there being 32 <code>case</code> statements there
are <strong>0</strong> <code>break</code>s? See the label <code>Z</code> for how that one works, although as you’ll
notice one event actually flows right into it only to move on to the next part
of the code. Additionally there are many <code>goto</code>s and labels in the <code>switch()</code>s
that don’t belong there in normal code, or for that matter in any code.</p>
<p>Anyway for comparison, here is the original version’s stats:</p>
<pre><code> 116 goto
294 semicolon
138 colon
@@ -837,7 +841,7 @@ it.</p>
<p>There are a lot of ways to obscure code and I don’t believe anyone has taken
<code>goto</code> to this obscenity in C. I believe the one with the most <code>goto</code>s is
1987/hines and, as noted earlier, it reports on itself as having only 24
<code>goto</code>s. Yet I have <del>116</del> 131 before the cpp and <del>134</del> 149
<code>goto</code>s. Yet I have <del>116</del> 134 before the cpp and <del>134</del> 152
(!!) after the cpp.</p>
<p>And unfortunately for you dear reader I have done other things that also are
quite different and totally unrelated to <code>goto</code>s. Even so the <code>goto</code> madness by
@@ -996,7 +1000,8 @@ one question their sanity even more. Yes I’m probably a sociopath.</p>
* filtered through the cpp and 134 after the cpp and I didn&#39;t wish to
* repeatedly revisit this file trying to explain everything.</code></pre>
<p>…and of course now the count, prog.c being the full version and prog.alt2.c
being the practical version, have the count at 131/149.</p>
being the practical version, have the count at 131/149 (actually, prog.alt2.c
has the 116/134).</p>
<p>I hope you understand but I do believe it’s a gain not a loss. It is good enough
especially as it’s only for educational value - or to examine my head (though
prog.c might be better for that?). As noted the code (and jokes) took a couple
@@ -1065,7 +1070,7 @@ is? In some ways it is actually polymorphic, doing drastically different things,
depending on the pRNG and which event it is.</p>
<p>At one point I was <strong>DEAD CERTAIN</strong> that part of this that should not be dead
was dead. But every part of it that is meant to be live is. There was a part
that was broken but that was fixed. As I noted in my <a href="#devil">remarks above</a>,
that was broken but that was fixed. As I noted in my <a href="index.html#devil">remarks above</a>,
this event (11 in particular, under <code>V</code>), will not necessarily do anything, as
it depends on another call to the pRNG. This is good because otherwise every
time it triggered it would cause severe illness.</p>
@@ -1495,7 +1500,7 @@ well-rounded in obfuscation.</p>
</div>
<p><strong>IMPORTANT NOTE TO THE JUDGES</strong>: if any problems in the data file exist,
remember to regenerate it as described in the Judges section and/or the
Troubleshooting section in the <a href="#devil">remarks above</a>. It is greatly
Troubleshooting section in the <a href="index.html#devil">remarks above</a>. It is greatly
appreciated that if by some chance you do run into a problem that you do this
quick procedure (the addpadding <code>-d</code> option can also be used to reveal what the
program is doing for those who wish to see more, although trying to play the
@@ -1511,7 +1516,7 @@ does (unless I missed it in a rule) <strong>BUT EVEN IF</strong> that’s all go
are <strong>ANY</strong> issues <strong>PLEASE</strong> run the <code>addpadding</code> tool manually (or better yet
<code>make makedata</code>).</p>
<p>The data file key is part of the obfuscation both in code and in data; it also
stays on theme. As noted in my <a href="#devil">remarks above</a>, I have bypassed the
stays on theme. As noted in my <a href="index.html#devil">remarks above</a>, I have bypassed the
concern of SUS portability by including my own tools, much like previous winning
entries did with POSIX compatibility.</p>
<p>I finally added the test rule to the Makefile to be sure things are sane too,
@@ -1709,7 +1714,8 @@ instructional either. I have included everything that is needed, however.</p>
<code>data.scrnshot.src</code> are created/used by <code>addpadding</code> and are vital to the game
(for the .asc data files it is for the non-emoji version, <code>prog.asc</code>, but used
by the same code, hence the <code>DATA</code> macro and the same applies to the screenshot
friendly one, as I discussed in the data files versions in my <a href="#devil">remarks above</a>).</p>
friendly one, as I discussed in the data files versions in my <a href="index.html#devil">remarks
above</a>).</p>
<p>The <code>data*.src</code> files are included for the purpose of allowing the files to be
created prior to running the game as they are vital, just like previous entries
with their data files.</p>
@@ -1770,11 +1776,85 @@ near 200 <code>char *</code>s in a single <code>char *</code> (NOT a <code>char
interesting and it’s one of the reasons I’m quite proud of it.</p>
<p>Interesting thing to ponder: what happens if a string is too long for the
padding?</p>
<div id="litmus">
<h3 id="litmus-test">Litmus test</h3>
</div>
<p>I did not write about this as much in my submission but since I made some
updates post winning I figured I would write about the litmus test that I
devised, to know that everything is working right.</p>
<p>It should be noted however that unless you know the code <strong>EXTREMELY</strong> well
(which probably only means me :-) and this will probably get less true as time
goes by) it might be hard to perform this and be 100% certain it is okay. This
especially goes because there are things that most people would think are logic
flow errors but are very intentional. I mentioned some in my
<a href="index.html">remarks</a>.</p>
<p>I did briefly mention this in my <a href="index.html">remarks</a> but here is a bit more
detail. It seems fitting here as the obfuscation talks about <code>goto</code>s more.</p>
<p>The key here is the events switch. If every event can fire without, for
instance, running through the game until you die, and you can also get sick, get
hurt (both of which can happen with different events or rather will) and also
make sure to have the right amount of (for instance) ammo for one event, right
amount (&gt; 666 and &lt; 666) money for when you need the doctor, and also trying to
spend too much money (as in you don’t have that much money as well as &gt; 666) at
the fort (this can also be done in the beginning of the game before you go on
the trail because it’s actually the same code reused) along with some things
only I might know (but perhaps not? You decide! :-) ) then <del>you</del> I can
be sure the code works as intended.</p>
<p>One of the above things actually did go wrong earlier on but fortunately it was
caught early on as it required rolling back a commit; if I had done many commits
after the problematic commit I would have lost a lot of time I kept adding more
events and more <code>goto</code>s.</p>
<p>Here is how to test every event in the event loop, though as some are chances
based on which event fires, you might have to run it multiple times. But since
one should go through the game or at least a few turns (at least!) per event,
this is not a problem. I should remind you that there are times where an event
might fire but might not do anything. This happens to do with event 11 and where
it goes and what it does.</p>
<p>To really test it well the last time I did this was in the
<a href="https://github.com/ioccc-src/winner/blob/master/2024/ferguson1/prog.gotos.c">prog.gotos.c</a> file as it’s the code
merged close together, taking it WAY BEYOND rule 2b limit (due to <code>;</code>, <code>{</code>
and <code>}</code> not being followed by spaces and the prog.c being at the max already).
This benefited me as I could also verify that the formatting did not get messed
up i.e. the code did not get mangled when merging lines.</p>
<p>The event switch is the following code (from prog.c):</p>
<pre><code> Y:switch(q=x(0,22))
</code></pre>
<p>so what you do is change the <code>x(0,22)</code> to go from 0 to 22, meaning that you have
to compile the code 23 times. If one wants to check the <code>heaven</code> label they need
to modify <code>i</code> to be <code>17</code> at a specific spot (well - or end up triggering a
certain piece of code, which I think is in event 11, though it’s not as
straight-forward as just testing that, although you could just set <code>i=17;</code> in
the right spot).</p>
<p>One should also try hunting and also going to the fort, at random times, but it
should not be needed in every run. The same applies to the other checks that
aren’t event specific.</p>
<p>One more thing about events: some events can be a different message per instance
so just because the same message does not repeat every time for a specific event
does not mean it is not correct; not only is this the case for event 11 but it’s
also the case for some others too. Another example is event 15 but it’s not the
only one (well, it might be, but there are various other events - events are not
just in the event switch! - that have different messages depending on the pRNG
and other circumstances).</p>
<p>One other thing is that it is good to test having no oxen and also having enough
oxen where you will eat one (this can depend on the event and also if you’re out
of food so this also varies).</p>
<p>As you can see there is a lot to test but doing this, assuming I’ve not left
anything out, allows one to verify the code is correct. This is one of the
reasons I took extreme care when developing and why it required constant
testing! In fact the bug I mentioned where it took me from an event all the way
to the end of the game, was only for one event, so if that didn’t fire I might
have missed it until I checked every event. This is how perilous it is with
<code>goto</code>s but as I noted even though I have (pre-processed) 152 <code>goto</code>s it works.
Of course it shouldn’t but it does.</p>
<div id="conclusions">
<div id="conclusion">
<h3 id="conclusions">Conclusions</h3>
</div>
</div>
<p>A question: is this well-rounded in obfuscation as the judges like? Definitely.</p>
<p>The fact that close to 200 NUL terminated strings are in a single <code>char *</code> (!!),
the odd looking compound literal, the maze of <code>goto</code>s (<del>116</del> 131 or
<del>134</del> 149 depending on if you pre-process the code), the bastardised
the odd looking compound literal, the maze of <code>goto</code>s (<del>116</del> 134 or
<del>134</del> 152 depending on if you pre-process the code), the bastardised
Duff’s device, the strange labels inside <code>switch()</code>s, the jumping into and out
of <code>switch()</code>s only to jump back in (or out), the for loops split across several
parts of the code (one making it look like variables are uninitialised), if/else
@@ -1791,27 +1871,31 @@ want to waste perfectly good spaghetti. There comes a point when there’s just
much spaghetti that it’s wasted, if it can even be cooked. I believed I reached
the latter. But of course that was a practical choice - and not my complete
version. It was just easier to test as I had another version to contend to.</p>
<p>But let’s say I had more space with iocccsize: do you REALLY expect me to add
more spaghetti? There isn’t anything that could be done, even if it was possible
to maintain this huge platter of delicious spaghetti without gaining fifty
kilograms. Besides, I don’t want to see spaghetti EVER AGAIN!! I’ve had enough
of it for a lifetime! Okay, that’s not really true…it DOES sound good but I
won’t likely be having it for a while. Can you actually blame me though? This
spaghetti almost strangled me to death, like it did the Devil (I provided
photographic proof of this earlier if you missed that). Still…now that things
have settled a bit, I rather desire very much a platter of spaghetti.</p>
<p>Do you REALLY expect me to add more spaghetti? There isn’t anything that could
be done, even if it was possible to maintain this huge platter of delicious
spaghetti without gaining fifty kilograms. Besides, I don’t want to see
spaghetti EVER AGAIN!! I’ve had enough of it for a lifetime! Okay, that’s not
really true…it DOES sound good but I won’t likely be having it for a while.
Can you actually blame me though? This spaghetti almost strangled me to death,
like it did the Devil (I provided photographic proof of this earlier if you
missed that). Still…now that things have settled a bit, I rather desire very
much a platter of spaghetti.</p>
<p>Okay so I <strong>did</strong> it after the win for the ‘full version’ but that only makes it
even more ludicrous doesn’t it?</p>
<p>I have already demonstrated several other subtle and unique things but the
<code>goto</code>s are what really makes it hard to parse; the other things are REALLY cool
(unlike the spaghetti, at least hopefully) and interesting, and unique (or so I
think), but those would be much less tasty without the HUGE pot of spaghetti
(okay, once some of it is put on a plate).</p>
<p>If I added more <code>goto</code>s it would be meaningless. A large family might not even
be able to eat it all without some of it going to waste. The <code>goto</code>s and how
they’re used make it hard to follow this code, in fact making it very
unpredictable. It is constantly jumping to unusual places and doing things that
seem downright illegal. It should not work.</p>
<p>If I added more <code>goto</code>s it would be meaningless (does that mean that the fact I
did it it’s meaningless? In a strange way the answer is it’s not actually
meaningless :-) ). A large family might not even be able to eat it all without
some of it going to waste. The <code>goto</code>s and how they’re used make it hard to
follow this code, in fact making it very unpredictable. It is constantly jumping
to unusual places and doing things that seem downright illegal. It should not
work.</p>
<p>But it <strong>DOES</strong> work. Exactly as I meant. As noted in my concluding remarks in
my <a href="#devil">remarks above</a>, I started introducing bugs. It was extremely hard to
my <a href="index.html#devil">remarks above</a>, I started introducing bugs. It was extremely hard to
find ways to make the spaghetti even more twisted. How is that even POSSIBLE? I
don’t think you could manage that with ACTUAL spaghetti!</p>
<p>On top of all this: I kept it thematic, in code <strong>and</strong> data, and the code even