News for hackers. Stuff that matters.
Re:A random dungeon generator in C, small enough to fit on a... by packetpirate on Tuesday March 05, 2019 @08:51AM (#19310466)
Fucking black magic obfuscation. Is it possible to learn this power?

I want to see someone try to rewrite C++'s entire syntax in the form of another language (I just have to assume it has already been done.)

Re:A random dungeon generator in C, small enough to fit on a... by cdata on Tuesday March 05, 2019 @09:22AM (#19310657)
I'm no expert, but in this case there are a few strategic definitions that help a lot to both conserve space and obfuscate:

  #define r return
  #define l(a, b, c, d) for (i y = a; y < b; y++) for (int x = c; x < d; x++)
  typedef int i;
Re:A random dungeon generator in C, small enough to fit on a... by munificent on Tuesday March 05, 2019 @01:49PM (#19313039)
My goal was less to obfuscate than it was to compress the code. I kept it as clear as I could within the limits of trying to get the code really small. There weren't any deliberate obfuscations like using misleading variable names.

The "l" macro cut the code down significantly and is one of the tricks I'm most proud of.

"r" and "i" aren't that impactful in terms of length. Their main benefit is that they make it easier to split the code where I need to in order to render the big ASCII art "@" sign. That's a lot harder when you have multiple-letter identifiers that can't be split in the middle.

Re:A random dungeon generator in C, small enough to fit on a... by woodrowbarlow on Tuesday March 05, 2019 @09:22AM (#19310663)
you may enjoy this article, where the author of a really clever bit of obfuscated C breaks down everything the code is doing.

https://www.a1k0n.net/2011/07/20/donut-math.html

Re:A random dungeon generator in C, small enough to fit on a... by tromp on Tuesday March 05, 2019 @10:48AM (#19311264)
The maze generator at http://tromp.github.io/pearls.html#maze is similarly accompanied by a link to a book chapter documenting the obfuscation.
Re:A random dungeon generator in C, small enough to fit on a... by theoh on Tuesday March 05, 2019 @10:07AM (#19310953)
There are a lot of examples to read through here: http://ioccc.org

C is used rather than C++, because C++ is a car crash before you even start trying to obfuscate.