Ping pong: A game that requires a C compiler to play

thunderbong1 pts0 comments

2025/uellenberg - Ping pong prize

Please Enable JavaScript

Entries

Winning entries

Winning authors

Location of authors

Bugs and (mis)features

Fixing entries

Updating author info

Thanks for the help

Status

News

Contest status

IOCCC rules

IOCCC guidelines

Markdown guidelines

Security policy

FAQ

Frequently asked questions

Enter the IOCCC

Compiling entries

Running entries

How to help

About

Home page

IOCCC social media

About the IOCCC

The judges

Contact us

The International Obfuscated C Code Contest

2025/uellenberg - Ping pong prize

Quine pong

&larr; 2025/tompng<br>&uarr; 2025 &uarr;<br>2025/yang1 &rarr;<br>C code<br>Makefile<br>Inventory<br>Original C

Author:

Name: Jonah Uellenberg

Location: US - United States of America (United States)

Award: Ping pong prize

To build:

make all<br>To use:

./prog | tee prog1.c | cc -xc -o prog1 - ; ./prog1 | diff - prog1.c<br>Try:

./try.sh<br>Alternate code:

Alternate build:

make prog.alt<br>Alternate use:

./prog.alt | tee prog1.alt.c | cc -xc -o prog1.alt - ; ./prog1.alt | diff - prog1.alt.c<br>Judges’ remarks:

This presses so many of our buttons, not just W and E!

Nevertheless, please resist the urge to write “Quine Doom” as a next year’s<br>IOCCC submission.

A fun challenge

Please checkout the fun challenge(s) for this winning entry.

Author’s remarks:

Quine Pong

This is my version of pong with a killer upgrade - it requires a C compiler<br>to use! Running the program produces the source code to generate the next<br>frame, formatted to display the current frame. By repeatedly compiling<br>and running each successive frame, you can play the game. To move,<br>pass either “w” (up) or “e” (down) as an argument. You play as the<br>paddle on the right, and your opponent is the computer. If you don’t<br>love the thought of running the same commands over and over again ( :(<br>), you can just run try.sh, which automates this process and lets you<br>interact directly using your keyboard.

Make sure you win against the computer at least once, there’s a fun<br>surprise waiting for you (spoilers in the next section)! Go on, go play<br>the game, I’ll still be waiting for you when you return.

Now that all the obfuscated C fans are distracted, it’s time I<br>let you in on what’s really going on. See, this code isn’t really<br>obfuscated. It never was. No, it’s compiled . That’s right, not a<br>single nibble desecrated by human hands, only purified in the unfeeling<br>steel of liveness analysis, constant folding, variable reallocation,<br>and compile-time evaluation. And the best part? There’s a source file<br>out there, just waiting to be read. Comprehendible variable names,<br>comments explaining the justification for every block of code, and not<br>a magic number in sight (well, maybe a few - no one’s perfect). Imagine<br>that! Don’t believe me? Let me show you.

If you want to take a closer look at the code, prog.c<br>is the obfuscated version of the code, prog.alt.c is<br>a version with indentation and newlines and without define compression<br>(which you can run with try.alt.sh), and prog.int contains<br>the original source code. prog.alt.c is also a quine, and is otherwise<br>identical to prog.c except for formatting, although it’s very long and<br>doesn’t fit well in terminal windows, so playing it is difficult. The quine<br>compiler is available at https://github.com/uellenberg/Insert, which<br>you can use to modify the program and create your own quines!

I’ve been informed that going into too much depth on how the obfuscated<br>code works can be considered condescending, and considering that I’ve<br>already directed you to the non-obfuscated source code, I have to assume<br>that any mention of functionality will cause you to implode under the<br>sheer rudeness of it all. So, I’ll instead be talking mostly about<br>the compiler, and some of the fun tricks that I’ve implemented to make<br>the output smaller. There are a lot of optimizations, so I’ll skip over<br>everything typical of a boring compiler (such as gcc, which you probably<br>used to run it - or maybe you’re a clang person, I don’t know).

The one thing I will go into more detail on is that the second jumping<br>game is actually a modified version of pong, and heavily uses its<br>code to save on size, including the collision, quine update/printing,<br>and display code (although I like to imagine that in the jumping game,<br>the ball is actually a dinosaur and the paddles are cacti).

This is inspired by the work of Yusuke Endoh, especially his self-similar<br>quine. The programs he’s created are magnificent, and are what originally<br>got me interested in quines.

Usage

I recommend running try.sh and try.alt.sh, as they allow you to play the<br>game in real-time. Once the game is running, just press “w” to go up<br>and “e” to go down. Note: I’ve only tested this under Linux, and your<br>terminal must be at least 70 characters wide and 60 characters tall,<br>otherwise the formatting won’t display correctly and/or you won’t have<br>the full game in frame. You can also remove the “cp prog.c prog.quine.c”<br>from try.sh, which will make it resume...

code prog pong game quine prog1

Related Articles