The International Obfuscated C Code Contest

A 27th IOCCC Winner

Don’t tread on me award

Cody Boone Ferguson
Twitter: @xexyl

The code for this entry can be found in prog.c

Judges' comments:

To use:

WAIT=100 WALLS=0 CANNIBAL=0 ./prog
# Start pressing some arrow keys


make test



SIZE=-1 ./prog


WAIT=75 GROW=-1 SIZE=5 CANNIBAL=1 ./prog


Selected Judges Remarks:

As the Gadsden flag warns, beware of the snake! This game has a number of configurable pitfalls including walls and snakes.

There is a good deal of useful documentation that is provided with this entry:

Documented game features!

Information about terminal capabilities, dimensions (setting and how to restore sanity if it causes any problems) as well as colours (limitations etc.).

Workaround for various game features

Bugs and things that might seem like bugs but are not.

Because most of us could use some Double-layered Chocolate Fudge Cake!

Read ONLY if you really must give up trying to de-obfuscate!

Author’s comments:

Feature-rich curses implementation of the Snake game (with many gameplay modes and options)

Snake has two cheat modes (passable walls and self [cannibalism]), a drawing (or practising) mode, can play by itself (and win!), is coloured (included and scripts compile in player-selected colours) and there are many other play modes (many more can be devised with the imagination and the environmental variables; see gameplay.markdown / gameplay.html for many examples) and options. You can pause and there’s even a built-in test unit for some features! The following variables change the game in the following ways (all can be combined):

There are no complicated command line invocations; it’s just a matter of passing into the game descriptively named variables and I include a script that sets up many different gameplay modes (gameplay.markdown and

The gameplay.markdown (gameplay.html) file has all the information on what the game looks like, how to play, the different types of modes (that I have thought of so far) including all those in the above list. Along with the and scripts it’s probably the most important file for players.

The gameplay file is long but it includes game printouts as well as explaining the many different gameplay modes. The script automates most (if not all) of the gameplay modes described in the gameplay file (it also allows you to change colours like as well as the judges' suggestions (that I don’t document so as to not spoil them). You can pass in environmental variables to both scripts though obviously some will conflict with different options in

Probably just as important is chocolate-cake.html with an old but wonderful recipe (because the judges love chocolate and who can blame them? - also it goes with one of the IAQs I include later).

The troubleshooting.markdown (troubleshooting.html) file has some advice on potential problems (and things that might appear to be problems at first glance but are not) that I have thought of or encountered.

The terminals.markdown (terminals.html) has a variety of information specific to terminals from input/directions, dimensions, sanity and colours: a sort of troubleshooting guide for terminals with some additional information.

The spoilers.markdown has a variety of information including some of the obfuscation techniques and a bit of how it works.

The bugs.markdown (bugs.html) has a list of known bugs and things that look like bugs but aren’t as well as documenting a built-in test unit for some features.

Because all IOCCC entries should have a man page I have included one (even though much of it is what’s also above). To render try:

    man ./snake.1

The COMPILING file has a few portability notes and the HACKING file has some information on how one might modify things, things that could be implemented (and how to/how not to go about some of the things) as well as some other information on the entry (some of which is deliberately not true - a variation of misleading comments). These files are probably insignificant.

I will have more information about this entry at after the winning entries have been published.

For the files I recommend looking at the html files with a browser; this particularly goes for the gameplay.html, bugs.html, terminals.html and troubleshooting.html - along with the most important one chocolate-cake.html.


On a more serious note look at bugs.markdown (bugs.html).

NAQs/IAQs (Never/Infrequently Asked Questions)

Do I have any inspirations for this entry?

There are two in particular. First is a long time mate of mine wrote a bash implementation of Snake several years ago (uncoloured, no cheat modes, hardcoded dimensions etc. - in fact everything was hardcoded).

Back then I had thought of making a curses implementation of it but I never got round to it. When the judges announced that the 2020 IOCCC contest would be open from late December 2019 through 15 March 2020 I started thinking again on what might be a good entry. By chance I thought of the Snake game and so wrote it finishing the implementation of everything on 8 November 2019. Did I say everything? That’s an unintentional lie; I thought it was everything but I implemented many new things after that. In fact I have numerous times thought I was done only to have added yet another feature - or two or three or more!

Second is the old Atari game Surround. There were a few modes as I recall. The object of the game was to surround your opponent so that they would run into you, the wall or themselves. The opponent was either the computer or another player.

In one mode you could go through walls (that’s where I got the idea to do likewise). There was also a drawing mode where you could just move round making different designs though that this is in my entry is a happy coincidence (because timeout() will block when it gets a negative value). It’s true that in my Snake it’s not quite the same but it’s close enough. Perhaps it can be made more like Surround if it grows every movement but then depending on the max size of the snake the game might be over fairly quickly (I don’t remember how it was done in Surround).

In Surround each move you made you would grow in size by one. This is what inspired the shedding mode. Anyway I always loved the game and it’s similar to Snake in several ways.

Are there any features I thought of that I wanted to implement but did not get to for some reason or another?

Yes. I thought it would be fun if there were other obstacles for the snake (in my mind I was thinking of barriers like the walls but in the field).

I also thought it would be fun to have more than one bug at some point after say the snake gets to be some size. One of the reasons I didn’t do this is because I was trying to save iocccsize bytes. I never got round to this though and I feel that the features I have implemented are far more interesting and fun.

Another idea is having portals or teleportation but there are a number of problems with those that would have to be worked out too.

I would have loved for it to be practical to support diagonal movement but as I describe elsewhere it’s not. That’s perhaps what I regret most. It would be possible to choose letters instead of arrow keys but even if that fit in the size restrictions how would I show the head? I looked at the extended ncurses character set and I didn’t see any diagonal arrows. I suppose I could have it not show the arrows but then that brings an old problem back.

Nevertheless I am quite happy with the features in the game and I hope everyone who plays it enjoys it as much as I enjoyed writing/playing it.

Are there ways that one can make this game easier?

I can think of at the least the following:

Are there ways to make it harder?

And if you’re a show-off you can try:

But if that’s not enough I don’t know what to tell you other than suggest that you make use of your talents for financial gain or at least a world record. Either way I tip my proverbial snakeskin hat to you (animal cruelty but a pun is a pun and every pun deserves to be shed).

How do snakes grow in real life?

They grow through a process called moulting - shedding their skin (other creatures also moult). This takes place over some days and unlike humans snakes never stop growing (though growth slows down as they mature). I chose the variables SHED and SHEDS for simplicity and because the words are shorter. I don’t like the words because it’s rather a misnomer but what I had chosen before was longer - STRETCH and STRETCHES.

Any other interesting things about snakes?

For the fascinating science behind snake slithering see Snake walk: The physics of slithering. For the bizarre thought of snake human hybrids see human snakes. The latter is hard to comprehend and there are some sad tails (tales) in there too because I believe that people actually believe in this (how/why I do not know) and they really do tell the truth as they see it (even if impossible).

Why can you go the opposite direction and so immediately die when not cannibalising?

When Ilya Kurdyukov was playing with this he questioned why this is possible when other implementations don’t have it this way. There are a few reasons.

First is that the friend’s implementation had it that way and it had been a long time since I had played it (if I ever did? I don’t know now: I played so many games over the years and the game most alike it that I played is Surround, as below).

It also is the way it is in Surround.

It makes cannibalism mode very interesting.

And I happen to like it the way I have it. In the end a snake isn’t an obstacle for itself but in the game it is and I went all the way instead of only halfway.

It also would take more bytes and that’s a problem with IOCCC rule 2b.

But if you have a problem with it you can always enable cannibalism and keep walls passable and not worry about dying.

Do you have any DELICIOUS CHOCOLATE CAKE recipes?

Why yes I do! So good in fact that even my late stepmum who didn’t even like chocolate (except white chocolate) loved this cake. It’s a double-layered chocolate fudge cake. See the file chocolate-cake.html for the recipe. Note that it’s a complicated but it’s well worth it!

I included it in all my entries this year because if any of them won more people can have this recipe; also it might help remind the judges that they really should have their cook bake it so they can all - including the cook should they also like chocolate - enjoy the cake whilst judging (and otherwise - it’s a big cake and very rich). Sadly they didn’t get to enjoy it during their judging due to the pandemic but maybe next time (or they can do on their own).

Do make sure to pay attention to all notes!

A note on the icing and room temperature

Please be advised that the note there that talks about the icing being difficult in too warm room is rather significant; unfortunately with SARS-CoV-2 this might be more of a problem depending on how long it lasts and where you reside. If necessary use the refrigerator or else air conditioner to cool down the place.

What are the files prog.2.c, prog.3.c, prog.3-j.c and prog.alt.c ?

I submitted three Snake versions; these are the other layouts for those few (or more likely none) who are interested to see them.

The prog.2.c has more digraphs but I think no other significant differences.

The prog.3.c is in a more artistic layout (a backwards S), has at least one additional obfuscation technique (see spoilers) but it also has more digraphs and as the judges said they feel that digraphs are dated so that’s probably why they chose the first layout. The prog.3-j.c version is prog.3.c with a shorter J define.

The prog.alt.c version is the one that allows for customising the bug colour and it’s used in both and It also calls erase() first, clearing the screen, which the and scripts also both do.

Author’s dedication:

Winning thoughts, dedications and thanks

Once again I’m honoured to win along with some of the other veterans who I have a huge amount of respect for; there’s Don Yang, Dave Burton, Yusuke Endoh and Edward Giles all of whom are amazing programmers. I’m especially proud to win besides Dave Burton and Yusuke Endoh but Don Yang and Edward Giles too.

But there are some others who I don’t remember like Ilya Kurdyukov (who’s offered a lot of interesting thoughts on Snake and who plans to have his own version after the entries are published), Nathan Otterness, Nicholas Carlini (whose entry is an absolutely brilliant abuse of printf - and I totally agree with the judges comments that your entry is so novel that it’ll be worth special mention in the future Best of IOCCC list!) and tsoj too.

Well done and congratulations to all of you again! Thank you for submitting the wonderful entries and I’m honoured to have my two entries beside yours!

To Dave Burton I thank you for your wonderful comments as well as pointing out that even with prog.orig.c it probably would be better to make use of the alt target instead of naming prog.c prog.orig.c. You’re quite right, I had thought of it but you brought it up so I could correct it. Much appreciated mate.

I would like to dedicate this entry to my wonderful mum Dianne Ferguson whom I love with all my heart and soul <3 Thank you for being the best mother imaginable! You’ve been there for me in the darkest of my hours without question without complaint and with all the love, compassion, empathy, sympathy and devotion anyone could ever ask for. Bless you again and again and again dear mother.

I also want to dedicate this to Vicky Wilmore who has given me a lot of love the past few years and who was there for me in some very dark times. Thank you Vicky sweetheart from the bottom of my heart and soul. Although we have parted ways, whether for now or for ever, you will always always always have a place in my heart and soul xxx

I would like to thank my dear friend Martijn Schoemaker for encouraging me in my programming over the years and who I owe a great deal to. Thank you for believing in me and my programming abilities (and other abilities) even when I couldn’t believe in myself! Very much appreciated especially coming from an amazing programmer who I have huge admiration for!

I want to thank Ilya Kurdyukov for his helpful comments, suggestions and reporting the problem about half-width/full-width char spacing. He’s been playing with some versions of his own and will have them on GitHub after the 2020 IOCCC winning entries have been published.

Finally I want to thank Leo Broukhis, Simon Cooper and Landon Curt Noll for continuing to hold the contest after all these years - and for having selected my entries. It’s a huge honour; thank you! I also happen to love your comments as well as the award titles. And yes indeed ‘most of us could use Double-layered Chocolate Fudge Cake!’

Creative Commons License

© Copyright 1984-2020, Leo Broukhis, Simon Cooper, Landon Curt Noll - All rights reserved
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.