Implementation notes C-star generator and C dialect detector. ---------------------------------------------------------------------- 0. Concept I just wanted something that generated lots of pointer dereferences. This seem especially appropriate in the contest of IOCCC, since unlike many other languages, C give you raw pointers and lets you do whatever you want. It made total sense to me that a C-orientated contest should see lots of pointers. Having decided to fill output with pointers, the connection to C-stars and sea stars and eventually Ibuki Fuuko wasn't too far away ("it made total sense to me"). Once the theme and character had been decided, the rest is just a simple matter of actually writing the code. ---------------------------------------------------------------------- 1. Text to pointer encoder To fill output with pointers, we build a text encoder that builds characters using pointer arithmetic. This involves: 0. Build a ring of addresses. 1. Have one pointer point at one of the addresses. 2. Dereference that pointer some number of times to get a different address. 3. Output character that is the difference of those two addresses. This ring is built with a simple linear congruential generator to make the number of dereferences more random. Because of this, 512 addresses are needed to account for all 255 differences. If it had been a straightforward ring where every address[N+1] = address[N]+1, 510 entries would be sufficient. Writing all these wasn't too hard, in fact it was too easy and too short. Short programs do not make good ASCII art, and my goal is mostly the ASCII art. ---------------------------------------------------------------------- 2. Sea star generator and C dialect detector Since I now have a program that generate pages and pages of asterisks, the most appropriate thing to do was to shape the output into ASCII art. Adding this support should make the original program long enough for interesting ASCII art there. Except it wasn't *quite* long enough, and honestly just generating ASCII art with pointers didn't seem to have enough of a kick. Then I recalled I wrote Yoshino in the previous year: http://uguu.org/src_yoshino_c.html Not too long after I did that, the dates for 2014 IOCCC was announced, so I entered the 2014 contest with something different. Nobody won IOCCC with a C-dialect detector as of yet (shinh tried in 2012 but didn't win: http://shinh.hatenablog.com/entry/20121021/1350829903 ). I thought, this is the year a C-dialect detector wins. Except this one is better than all previous ones, detecting *five* dialects. Truth be told, the reason why I got to 5 instead of just 3 or 4 was due to creeping features needed to enlarge my ASCII art, but in the end it worked out well. ---------------------------------------------------------------------- 3. Testing Fuuko was tested and verified to work on these compiler/platform combinations: - gcc 4.9.3 on Cygwin - gcc 4.9.2 on Linux - gcc 4.8.4 on Linux - gcc 4.6.3 on Linux[1] - gcc 4.3.5 on JS/Linux - clang 3.5.2 on Cygwin[2] - clang 3.5.0 on Linux - clang 3.4.1 on Linux - tcc 0.9.25 on JS/Linux[3] [1] Doesn't support -std=c11 and -std=c++11. [2] Doesn't work with optimization enabled: https://llvm.org/bugs/show_bug.cgi?id=25045 [3] C99 only, really slow floating point math. Cygwin is really disappointing these days. ---------------------------------------------------------------------- 4. Finally... Fuuko was awarded "Most Pointed Reaction" for IOCCC 2015. I wanted to say this was exactly as planned, except I couldn't have predicted the award title, that was rather cute. Incidentally, it has been more than 15 years since Clannad the game was released, but I still find the characters memorable. Maybe it's time to play it again.