commit 96832aa52c8e79740bd29b9d484b78b6ba78d406 Author: Guillaume Date: Mon Nov 25 13:01:34 2013 -0800 Original content diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1bc95d9 --- /dev/null +++ b/Makefile @@ -0,0 +1,222 @@ +#!/usr/bin/env make +# +# 2012 makefile +# +# This work by Landon Curt Noll, Simon Cooper, and Leonid A. Broukhis +# is licensed under: +# +# Creative Commons Attribution-ShareAlike 3.0 Unported License. +# +# See: http://creativecommons.org/licenses/by-sa/3.0/ + + +################ +# tool locations +################ +# +SHELL= /bin/bash +CP= cp +CPP= cpp +GUNZIP= gunzip +LD= ld +MAKE= make +RM= rm +SED= sed +TAR= tar +TRUE= true + +# Set X11_LIBDIR to the directory where the X11 library resides +# +X11_LIBDIR= /usr/X11R6/lib + +# Set X11_INCLUDEDIR to the directory where the X11 include files reside +# +X11_INCDIR= /usr/X11R6/include + +# Compiler warnings +# +#CWARN= +#CWARN= -Wall -W +CWARN= -Wall -W -pedantic + +# compiler standard +# +#CSTD= +#CSTD= -ansi +CSTD= -std=c99 + +# compiler bit architecture +# +# Some entries require 32-bitness: +# ARCH= -m32 +# +# Some entries require 64-bitess: +# ARCH= -m64 +# +# By default we assume nothing: +# +ARCH= + +# optimization +# +# Most compiles will safely use -O2. Some can use only -O1 or -O. +# A few compilers have broken optimizers or this entry make break +# under those buggy optimizers and thus you may not want anything. +# +#OPT= +#OPT= -O +#OPT= -O1 +OPT= -O2 +#OPT= -O3 + +# Libraries needed to build +# +LIBS= -lm + +# default flags for ANSI C compilation +# +CFLAGS= ${CWARN} ${CSTD} ${ARCH} ${OPT} + +# ANSI compiler +# +# Set CC to the name of your ANSI compiler. +# +# Some entries seem to need gcc. If you have gcc, set +# both CC and MAY_NEED_GCC to gcc. +# +# If you do not have gcc, set CC to the name of your ANSI compiler, and +# set MAY_NEED_GCC to either ${CC} (and hope for the best) or to just : +# to disable such programs. +# +CC= cc +#CC=clang +MAY_NEED_GCC= gcc + + +############################## +# Special flags for this entry +############################## +# +ENTRY= endoh1 +DATA= column.txt column2.txt column3.txt corners.txt dripping-pan.txt \ + evaporation.txt flat.txt fountain.txt funnel.txt funnel2.txt \ + funnel3.txt leidenfrost.txt logo.txt pour-out.txt tanada.txt +ALT_OBJ= endoh1_color.o +ALT_ENTRY= endoh1_color + +# The factor of gravity +# +G=1 + +# The factor of pressure +# +P=4 + +# The factor of viscosity +# +V=8 + +################# +# build the entry +################# +# +all: ${ENTRY} ${DATA} + @${TRUE} + +${ENTRY}: ${ENTRY}.c + ${CC} ${CFLAGS} -DG=$G -DP=$P -DV=$P $< -o $@ ${LIBS} + +# alternative executable +# +alt: ${ALT_ENTRY} + @${TRUE} + +endoh1_deobfuscate: endoh1_deobfuscate.c + ${CC} ${CFLAGS} -DG=$G -DP=$P -DV=$P $< -o $@ ${LIBS} + +endoh1_color: endoh1_color.c + ${CC} ${CFLAGS} -DG=$G -DP=$P -DV=$P $< -o $@ ${LIBS} + +# data files +# +data: ${DATA} + @${TRUE} + + +############### +# utility rules +############### +# +everything: all alt + +clean: + ${RM} -f ${ENTRY}.o ${ALT_OBJ} + +clobber: clean + ${RM} -f ${ENTRY} ${ALT_ENTRY} + +nuke: clobber + @${TRUE} + +dist_clean: nuke + @${TRUE} + +install: + @echo "Surely you're joking Mr. Feynman!" + @${TRUE} + +# backwards compatibility +# +build: all + @${TRUE} + + +################## +# 133t hacker rulz +################## +# +love: + @echo 'not war?' + @${TRUE} + +haste: + $(MAKE) waste + @${TRUE} + +waste: + @echo 'waste' + @${TRUE} + +easter_egg: + @echo you expected to mis-understand this $${RANDOM} magic + @echo chongo '' "/\\oo/\\" + @echo Readers shall be disallowed from not being unable to partly misunderstand this partocular final echo. + +# Understand the history of "I Am the Walrus" and +# and in particular John Lennon's remarks on that +# song and you might be confused about these next +# rules in a different way. :-) +# +supernova: nuke + @-if [ -r .code_anal ]; then \ + ${RM} -f .code_anal_v3; \ + else \ + echo "You are not expected to understand this"; \ + fi + @${TRUE} + +deep_magic: + @-if [ -r .code_anal ]; then \ + ccode_analysis --deep_magic 1c2c85c7a02c55d1add91967eca491d53c101dc1 --FNV1a_hash 256-bit "${ENTRY}"; \ + else \ + echo "Understand different"; \ + fi + @${TRUE} + +magic: deep_magic + @-if [ -r .code_anal ]; then \ + ccode_analysis --mode 21701 --level 23209 --FNV1a_hash 256-bit "${ENTRY}"; \ + else \ + echo "These aren't the droids you're looking for Mr. Spock!"; \ + fi + @${TRUE} diff --git a/Makefile.orig b/Makefile.orig new file mode 100644 index 0000000..87467c8 --- /dev/null +++ b/Makefile.orig @@ -0,0 +1,22 @@ +# the factor of gravity +G=1 +# the factor of pressure +P=4 +# the factor of viscosity +V=8 +RM= rm +TRUE= true +CWARN= -Wall -W -Wextra -pedantic +CSTD= -std=c99 -D_BSD_SOURCE +CFLAGS= ${CWARN} ${CSTD} ${ARCH} ${OPT} +CC= gcc +ENTRY= prog + +all: ${ENTRY} + @${TRUE} + +${ENTRY}: ${ENTRY}.c + ${CC} ${CFLAGS} -DG=$G -DP=$P -DV=$P ${ENTRY}.c -o $@ -lm + +clean: + $(RM) -f ${ENTRY} diff --git a/clock.txt b/clock.txt new file mode 100644 index 0000000..13b94c9 --- /dev/null +++ b/clock.txt @@ -0,0 +1,24 @@ + ######################## + ##xxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxxxx## + ###xxxxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxx### + ### ### + ### ### + ### ### + ### ### + ### ### + ### ### + ### ### + ### ### + ## ## + ## ## + ## ## + ## ## + ## ## + ######################## + diff --git a/column.txt b/column.txt new file mode 100644 index 0000000..e7a5148 --- /dev/null +++ b/column.txt @@ -0,0 +1,23 @@ + + + + + +### ............... ### +### ................. ### +### ................. ### +### ................. ### +### ................. ### +### ................. ### +### ................. ### +### ................. ### +### ................. ### +### ................. ### +### ................. ### +### ................. ### +### ................. ### +### ................. ### +### ................. ### +### ............... ### +########################################################################## + ######################################################################## diff --git a/column2.txt b/column2.txt new file mode 100644 index 0000000..4e871d6 --- /dev/null +++ b/column2.txt @@ -0,0 +1,22 @@ + + + + +### .......... ### +### ........... ### +### ........... ### +### ........... ### +### ........... ### +### ........... ### +### ........... +### ........... +### ........... +### ........... ### +### ........... ### +### ........... ### +### ........... ### +### ........... ### +### ........... # ### +### .......... ### ### +############################################################################## + ############################################################################ diff --git a/column3.txt b/column3.txt new file mode 100644 index 0000000..2cded8a --- /dev/null +++ b/column3.txt @@ -0,0 +1,22 @@ + + + + +### .......... ### +### .................................................................### +### ........... ### +### ........... ### +### ........... ### +### ........... ### +### ........... +### ........... +### ........... +### ........... ### +### ........... ### +### ........... ### +### ........... ### +### ........... ### +### ........... # ### +### .......... ### ### +############################################################################## + ############################################################################ diff --git a/corners.txt b/corners.txt new file mode 100644 index 0000000..45e5dcc --- /dev/null +++ b/corners.txt @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + +# # +# # +# # +#@ @# +############################################################################### diff --git a/dripping-pan.txt b/dripping-pan.txt new file mode 100644 index 0000000..2ed702b --- /dev/null +++ b/dripping-pan.txt @@ -0,0 +1,23 @@ + + + + + + + + +# # +# # +# @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ # +#@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @# +##################################### ####################################### + + + + + + + + + + diff --git a/endoh1.c b/endoh1.c new file mode 100644 index 0000000..f4df520 --- /dev/null +++ b/endoh1.c @@ -0,0 +1,23 @@ +# include// .IOCCC Fluid- # +# include //2012 _Sim!_ # +# include //|||| ,____. IOCCC- # +# define h for( x=011; 2012/* # +# */-1>x ++;)b[ x]//-' winner # +# define f(p,e) for(/* # +# */p=a; e,p10?32< x?4[/* ## +## */*r++ =w,r]= w+1,*r =r[5]= x==35, r+=9:0 ,w-I/* ## +## */:(x= w+2);; for(;; puts(o ),o=b+ 4){z(p [1]*/* ## +## */9,2) w;z(G, 3)(d*( 3-p[2] -q[2]) *P+p[4 ]*V-/* ## +## */q[4] *V)/p[ 2];h=0 ;f(p,( t=b+10 +(x=*p *I)+/* ## +## */80*( y=*p/2 ),*p+=p [4]+=p [3]/10 *!p[1]) )x=0/* ## +## */ <=x &&x<79 &&0<=y&&y<23?1[1 [*t|=8 ,t]|=4,t+=80]=1/* ## +## */, *t |=2:0; h=" '`-.|//,\\" "|\\_" "\\/\x23\n"[x/** ## +## */%80- 9?x[b] :16];;usleep( 12321) ;}return 0;}/* ## +#### #### +############################################################################### +**###########################################################################*/ diff --git a/endoh1_color.c b/endoh1_color.c new file mode 100644 index 0000000..830a389 --- /dev/null +++ b/endoh1_color.c @@ -0,0 +1,30 @@ +# include// .IOCCC Fluid- # +# include //2012 _Sim!_ # +# include //|||| ,____. |||||| # +# define c y+=( x=ctanh( -cabs/* # +# */(4[t ]-=20) /2+9)* 3+3)*// # +# define f(p,e) for(p/* # +# */=a;e ,p (t+=12 );c 6, sprintf (t,/** ## +## */"%c" "[48%" "c5;%" "03dm" "%c",3 *9,e,c 36,e/* ## +## */?(t- b)%960 ?(15-t [11])[ "\x23" "/\\_" "\\"/* ## +## */"||" ",//|" ".-`' "]:10: 0)) y= 0020,c 01;}/* ## +## */void g( int i){7[t +=i]|= x/=2;* t+=y=p [2];/* ## +## */}int main() {for(;( x=getc (stdin ))>0;)w =10 x&& + 0<= y&& 23> y?x =16 ,g( 0),g(12), + g(+ 948 ),g (12 ),0 :0) ;h( 59) ;;; + usleep( 12321); }return 0;} /*IOCCC '12 **/ diff --git a/endoh1_deobfuscate.c b/endoh1_deobfuscate.c new file mode 100644 index 0000000..8eca189 --- /dev/null +++ b/endoh1_deobfuscate.c @@ -0,0 +1,31 @@ +#include // .IOCCC Fluid- # +#include //2012 _Sim!_ # +#include //|||| ,____. IOCCC- # +double complex a[97687], *p, *q, *r = a, w = 0, d; +int x , y; +char b [6856] = "\x1b[2J" "\x1b" "[1;1H ", *o = b, *t; +int +main() +{ + + for (; 0 < (x = getc(stdin));) + w = x > 10 ? 32 < x ? 4[*r++ = w, r] = w + 1, *r = r[5] = x == 35, r += 9 : 0, w - I : (x = w + 2);; + for (;; puts(o), o = b + 4) { + for (p = a; p[2] = p[1] * 9, p < r; p += 5) + for (q = a; w = cabs(d = *p - *q) / 2 - 1, q < r; q += 5) + if (0 < (x = 1 - w)) + p[2] += w * w; + for (p = a; p[3] = G, p < r; p += 5) + for (q = a; w = cabs(d = *p - *q) / 2 - 1, q < r; q += 5) + if (0 < (x = 1 - w)) + p[3] += w * (d * (3 - p[2] - q[2]) * P + p[4] * V - q[4] * V) / p[2]; + for (x = 011; 2012 - 1 > x++;) + b[x] = 0; + for (p = a; (t = b + 10 + (x = *p * I) + 80 * (y = *p / 2), *p += p[4] += p[3] / 10 * !p[1]), p < r; p += 5) + x = 0 <= x && x < 79 && 0 <= y && y < 23 ? 1[1[*t |= 8, t] |= 4, t += 80] = 1, *t |= 2 : 0; + for (x = 011; 2012 - 1 > x++;) + b[x] = " '`-.|//,\\" "|\\_" "\\/\x23\n"[x % 80 - 9 ? x[b] : 16];; + + usleep(12321); + } return 0; +} diff --git a/evaporation.txt b/evaporation.txt new file mode 100644 index 0000000..b2208d2 --- /dev/null +++ b/evaporation.txt @@ -0,0 +1,23 @@ + @ + + + + + + + + + + + + + + + + + +# # +# # +# # +# # +############################################################################### diff --git a/flat.txt b/flat.txt new file mode 100644 index 0000000..ad084da --- /dev/null +++ b/flat.txt @@ -0,0 +1,23 @@ + + + + + + + + +# # +# # +# # +#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@# +############################################################################### + + + + + + + + + + diff --git a/fountain.txt b/fountain.txt new file mode 100644 index 0000000..887f345 --- /dev/null +++ b/fountain.txt @@ -0,0 +1,23 @@ + + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + ### x ### + ### x ### + ### x ### + ############# diff --git a/funnel.txt b/funnel.txt new file mode 100644 index 0000000..5aac57e --- /dev/null +++ b/funnel.txt @@ -0,0 +1,23 @@ + # # + #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx# + #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx# + #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx# + #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx# + #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx# + #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx# + #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx# + #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx# + #xxxxxxxxxxxxxxxxxxxxxxxxxxxx# + #xxxxxxxxxxxxxxxxxxxxxxxxxx# + #xxxxxxxxxxxxxxxxxxxxxxxx# + #xxxxxxxxxxxxxxxxxxxxxx# + #xxxxxxxxxxxxxxxxxxxx# + #xxxxxxxxxxxxxxxxxx# + #xxxxxxxxxxxxxxxx# + #xxxxxxxxxxxxxx# + #xxxxxxxxxxxx# + #xxxxxxxxxx# + #xxxxxxxx# + #xxxxxx# + #xxxx# + #### diff --git a/funnel2.txt b/funnel2.txt new file mode 100644 index 0000000..2c3f54c --- /dev/null +++ b/funnel2.txt @@ -0,0 +1,23 @@ + ## ## + ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxxxx## + ##xxxxxxxxxxxxxx## + ##xxxxxxxxxxxx## + ##xxxxxxxxxx## + ##xxxxxxxx## + ##xxxxxx## + ##xxxx## + ###### diff --git a/funnel3.txt b/funnel3.txt new file mode 100644 index 0000000..0ad0284 --- /dev/null +++ b/funnel3.txt @@ -0,0 +1,24 @@ + ### ### + ###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxxxxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxxxxxx### + ###xxxxxxxxxxxxxx### + ###xxxxxxxxxxxx### + ###xxxxxxxxxx### + ###xxxxxxxx### + ###xxxxxx### + ###xxxx### + ######## + ######## diff --git a/glass-half-empty.txt b/glass-half-empty.txt new file mode 100644 index 0000000..a329915 --- /dev/null +++ b/glass-half-empty.txt @@ -0,0 +1,22 @@ + + + + ###.......................### + ###.......................### + ###.......................### + ###.......................### + ###.......................### + ###.......................### + ###.......................### + ###.......................### + ### ### + ### ### + ### ### + ### ### + ### ### + ### ### + ### ### + ### ### + ### ### + ############################# + ############################# diff --git a/hint.css b/hint.css new file mode 100644 index 0000000..ed0fc78 --- /dev/null +++ b/hint.css @@ -0,0 +1,78 @@ +* { + font-family: Helvetica Neue, Helvetica, Arial, sans-serif; +} +body { + max-width: 50em; + margin: 0 auto; + color: #111; +} + +pre, code { + font-family: Monaco, Courier New, monospace; + font-size: 12px; +} + +h1 { + font-size: 40px; + font-weight: bold; + letter-spacing: -1px; + margin-bottom: -5px; +} +h1 code { + font-size: 40px; +} + +h2 { + color: rgb(43,105,145); + font-weight: bold; + margin-bottom: -5px; +} +h2 code { + font-size: 22px; +} + +h3 { + /* color: rgb(43,105,145); */ + font-weight: bold; + margin-bottom: -5px; +} +h3 code { + font-size: 16px; +} + +a { + color: blue; + text-decoration: underline; +} +a:visited { + color: navy; +} +a:hover { + text-decoration: underline; +} + +pre { + border-radius: 10px; + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.3); + -webkit-box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.3); + -moz-box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.3); + border-width: 1px; + border-color: rgb(16,48,0); + border-style: solid; + padding: 0.6em; + padding-left: 1em; + margin-left: 5%; + margin-right: 8%; + background-color: rgb(16,48,0); + overflow: auto; + color: rgb(75,224,0); +} + +p, li { + font-size: 14px; + line-height: 18px; +} + + diff --git a/hint.html b/hint.html new file mode 100644 index 0000000..2064177 --- /dev/null +++ b/hint.html @@ -0,0 +1,211 @@ + + + + + + + Most complex ASCII fluid - Honorable mention + + +

Most complex ASCII fluid - Honorable mention

+ +

Yusuke Endoh
+mame@tsg.ne.jp

+ +

Judges' comments:

+ +

To build:

+ +
make endoh1
+
+ +

To run:

+ +
./endoh1 < configuration.txt
+
+ +

Try:

+ +
./endoh1 < endoh1.c
+
+./endoh1 < pour-out.txt
+
+./endoh1 < fountain.txt
+
+ +

Selected Judges Remarks:

+ +

Let’s play Jeopardy!

+ +
    +
  • A: An obfuscated program that deals with complex numbers and produces animated ASCII graphics.
  • +
  • Q: What is a Mandelbrot simulator?
  • +
+ + +

Bzzzt!

+ +

Such heavily squeezed fluid simulation (this is parsed uniquely +as fluids are not squeezable) has a few quirks that the judges were +happy to experiment with.

+ +

One configuration file was inspired by an XKCD what if? entry.

+ +

Author’s comments:

+ +

Synopsis

+ +

DO NOT FORGET “-DG=1 -DP=4 -DV=8” and make your terminal window larger +than 80 x 25.

+ +
gcc endoh1.c -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -o endoh1 -lm
+./endoh1 < endoh1.c
+./endoh1 < logo.txt
+./endoh1 < column.txt
+./endoh1 < pour-out.txt
+./endoh1 < tanada.txt
+
+ +

What it is

+ +
,___. ,.       ,.    ,.   ,___. ,.              ,.       ,.
+|/--' ||       `'    ||   |/--' `'              ||       |\_.
+|\__. || ,. ,. ,. ,__/|   |\__. ,. ,____. ,. ,. ||  ,_.  |/-'  ,_.  ,__.
+|/--' || || || || |/-\|   `--\| || |/\/\| || || || ,/-\. ||   ,/-\. |/-\.
+||    || `\_/| || |\_/|   ,__/| || |||||| `\_/| || `\_/\.`\_. `\_/' || `'
+`'    `'  `--' `' `---'   `---' `' `'`'`'  `--' `'  `-'`' `-'  `-'  `'
+
+
+ ,.,.                      ,.,.
+,/\/\. ,.       ,.    ,.  ,/\/\. ,.              ,.      ,__.
+|||#/' ||       `' ,_.||  |||#/' `',_.,__.       ||      ||\\.        ,.
+|||#\. || ,. ,. ,.,/#|||  |\//\. ,.|#||##| ,. ,. || ,.,. |\/-' ,.,. ,.|\.
+|\/--' ||,/\.|| |||#/\/|  `\#||| |||#||/\|,/\.|| ||,/'`\.|#|  ,/'`\.|\/-\.
+`\|    ||`\#||| |||#||\|  ,//\/| ||`\|||||`\#||| ||`\.,/\/\|,.`\.,/'`\| `'
+ `'    `' `-'`' `'`-'`-'  `-'`-' `' `'`'`' `-'`' `' `'`--'`'`' `'`'  `'
+
+
+,_.,_. ,.       ,.    ,.  ,_.,_. ,.              ,.      ,.
+|#||#| ||       `'    ||  |#||#| `'              ||      ||,_.
+||\/#| ||,.  ,. ,.,_.,/|  |\||#| ,.,_.,__.,.  ,. || ,.,. |||#| ,.,. ,.,_.
+|||##| ||||  || |||#||#|  |#||#| |||#||##|||  || ||,/||\.||`-',/||\.|||#\.
+||`--' ||`\_.|| |||\||#|  |#||#| ||||'||\|`\_.|| ||`\||#|`\.,.`\||/'||`--'
+`'     `' |#||| `'|#||#|  |#||#| `'`' `'`' |#||| `' |||/' |||| |||| `'
+          `-'`'   `-'`-'  `-'`-'           `-'`'    `'`'  `'`' `'`'
+
+ +

This program is a fluid simulator using “Smoothed-particle hydrodynamics (SPH)” +method.

+ +

http://en.wikipedia.org/wiki/Smoothed-particle_hydrodynamics

+ +

The SPH particles represent the fluid flow. Particles have information about +the position, density, and velocity. In every simulation step, they are +changed by pressure force, viscosity force, and external force (i.e., gravity).

+ +

This program reads a text from standard input, and uses it as an initial +configuration of the particles. The character # represents “wall particle” (a +particle with fixed position), and any other non-space characters represent +free particles.

+ +

The compilation options -DG=1 -DP=4 -DV=8 represent, respectively, the factor +of gravity, pressure, and viscosity. By changing their values, you can see +different fluid behavior.

+ +

“Marching square”-like algorithm is used to render the particles.

+ +

http://en.wikipedia.org/wiki/Marching_squares

+ +

Portability

+ +

The program requires a C99 compiler; it uses complex types and one-line +comments. It also uses usleep, which may require -D_BSD_SOURCE or somewhat +to build with no warning. Under these conditions, it should be portable. +At least, recent compilers with -std=c99 -Wall -W -Wextra -pedantic says +nothing.

+ +
gcc -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -std=c99 -Wall -W -Wextra -pedantic endoh1.c
+clang -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -std=c99 -Wall -W -Wextra -pedantic endoh1.c
+
+ +

I expect it to work in any Unix-like environment. VTxxx/ANSI sequences are +used to clear screen and move cursor to home.

+ +

I’ve tested with gcc-4.6.3 and clang-3.0 on Linux (Ubuntu 12.04) +and gcc-4.5.3 and clang-3.1 on Cygwin. On Cygwin, gcc and clang complain about +a usage of I (complex’s imaginary unit), but I bet this is cygwin’s issue; +it is surely a C99 feature.

+ +

Obfuscation w/ Spoiler

+ +

First of all, the source code itself serves as an initial configuration. +Preprocessing directives (such as #include)’s # serve as walls.

+ +

This program uses double complex to represent any 2D vector. But, note that +x-axis and y-axis is swapped (real axis = y-axis, imaginary axis = x-axis). +The purpose of swapping is not only obfuscation, but also short coding: for +example, to add gravity to total force, force += G suffices, rather than +force += G*I. +(Incidentally, you can exert horizontal gravity by using, such as, -DG=I)

+ +

Every five entries of double complex a[] contain information of one particle: +position, wall-flag, density, force, and velocity, in turn.

+ +

You can use G, P, and V as a guide to find the calculation code of +gravity, pressure, and viscosity forces.

+ +

Though some assignments may look meaningless, it is actually meaningful; it +extracts “integer part of real part” from a complex value by assigning (and +casting) it to an integer-type variable.

+ +

Notes about Additional Files

+ +

“logo.txt” is a source of the logo in this remark file.

+ +

“column.txt” is a water column collapse, which is a popular demo of SPH.

+ +

“pour-out.txt” pours you a cup of tea.

+ +

“tanada.txt” simulates “Terrace farming”. (“Tanada” means a “terraced rice +fields” in Japanese.)

+ +

“clock.txt” is a “water” clock created by HAMANO Tsukasa.

+ +

Other *.txt files are due to the judges.

+ +

“endoh1_color.c” is a variant that shows the density by using terminal 256 +colors.

+ +

Acknowledgment

+ +

I would like to thank my wife @hirekoke for her teaching me the SPH method.

+ +

The judges ordered suggested creating a color version +after the judgment.

+ +

The judges and HAMANO Tsukasa (The silver medalist at this IOCCC) kindly +provided many configuration files.

+ +
+ + + + + + + +
Creative Commons License

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

 
+ + + diff --git a/hint.text b/hint.text new file mode 100644 index 0000000..44399de --- /dev/null +++ b/hint.text @@ -0,0 +1,184 @@ +# Most complex ASCII fluid - Honorable mention + +Yusuke Endoh + + + +## Judges' comments: +### To build: + + make endoh1 + +### To run: + + ./endoh1 < configuration.txt + +### Try: + + ./endoh1 < endoh1.c + + ./endoh1 < pour-out.txt + + ./endoh1 < fountain.txt + +### Selected Judges Remarks: + +Let's play Jeopardy! + +* A: An obfuscated program that deals with complex numbers and produces animated ASCII graphics. +* Q: What is a Mandelbrot simulator? + +Bzzzt! + +Such heavily squeezed fluid simulation (this is parsed uniquely +as fluids are not squeezable) has a few quirks that the judges were +happy to experiment with. + +One configuration file was inspired by an [XKCD what if? entry](http://whatif.xkcd.com/6/). + +## Author's comments: +### Synopsis + +**DO NOT FORGET "-DG=1 -DP=4 -DV=8"** and make your terminal window larger +than 80 x 25. + + gcc endoh1.c -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -o endoh1 -lm + ./endoh1 < endoh1.c + ./endoh1 < logo.txt + ./endoh1 < column.txt + ./endoh1 < pour-out.txt + ./endoh1 < tanada.txt + + +### What it is + + ,___. ,. ,. ,. ,___. ,. ,. ,. + |/--' || `' || |/--' `' || |\_. + |\__. || ,. ,. ,. ,__/| |\__. ,. ,____. ,. ,. || ,_. |/-' ,_. ,__. + |/--' || || || || |/-\| `--\| || |/\/\| || || || ,/-\. || ,/-\. |/-\. + || || `\_/| || |\_/| ,__/| || |||||| `\_/| || `\_/\.`\_. `\_/' || `' + `' `' `--' `' `---' `---' `' `'`'`' `--' `' `-'`' `-' `-' `' + + + ,.,. ,.,. + ,/\/\. ,. ,. ,. ,/\/\. ,. ,. ,__. + |||#/' || `' ,_.|| |||#/' `',_.,__. || ||\\. ,. + |||#\. || ,. ,. ,.,/#||| |\//\. ,.|#||##| ,. ,. || ,.,. |\/-' ,.,. ,.|\. + |\/--' ||,/\.|| |||#/\/| `\#||| |||#||/\|,/\.|| ||,/'`\.|#| ,/'`\.|\/-\. + `\| ||`\#||| |||#||\| ,//\/| ||`\|||||`\#||| ||`\.,/\/\|,.`\.,/'`\| `' + `' `' `-'`' `'`-'`-' `-'`-' `' `'`'`' `-'`' `' `'`--'`'`' `'`' `' + + + ,_.,_. ,. ,. ,. ,_.,_. ,. ,. ,. + |#||#| || `' || |#||#| `' || ||,_. + ||\/#| ||,. ,. ,.,_.,/| |\||#| ,.,_.,__.,. ,. || ,.,. |||#| ,.,. ,.,_. + |||##| |||| || |||#||#| |#||#| |||#||##||| || ||,/||\.||`-',/||\.|||#\. + ||`--' ||`\_.|| |||\||#| |#||#| ||||'||\|`\_.|| ||`\||#|`\.,.`\||/'||`--' + `' `' |#||| `'|#||#| |#||#| `'`' `'`' |#||| `' |||/' |||| |||| `' + `-'`' `-'`-' `-'`-' `-'`' `'`' `'`' `'`' + + +This program is a fluid simulator using "Smoothed-particle hydrodynamics (SPH)" +method. + + + +The SPH particles represent the fluid flow. Particles have information about +the position, density, and velocity. In every simulation step, they are +changed by pressure force, viscosity force, and external force (i.e., gravity). + +This program reads a text from standard input, and uses it as an initial +configuration of the particles. The character `#` represents "wall particle" (a +particle with fixed position), and any other non-space characters represent +free particles. + +The compilation options `-DG=1 -DP=4 -DV=8` represent, respectively, the factor +of gravity, pressure, and viscosity. By changing their values, you can see +different fluid behavior. + +"Marching square"-like algorithm is used to render the particles. + + + + +### Portability + +The program requires a C99 compiler; it uses `complex` types and one-line +comments. It also uses `usleep`, which may require `-D_BSD_SOURCE` or somewhat +to build with no warning. Under these conditions, it should be portable. +At least, recent compilers with `-std=c99 -Wall -W -Wextra -pedantic` says +nothing. + + gcc -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -std=c99 -Wall -W -Wextra -pedantic endoh1.c + clang -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -std=c99 -Wall -W -Wextra -pedantic endoh1.c + +I expect it to work in any Unix-like environment. VTxxx/ANSI sequences are +used to clear screen and move cursor to home. + +I've tested with gcc-4.6.3 and clang-3.0 on Linux (Ubuntu 12.04) +and gcc-4.5.3 and clang-3.1 on Cygwin. On Cygwin, gcc and clang complain about +a usage of `I` (complex's imaginary unit), but I bet this is cygwin's issue; +it is surely a C99 feature. + + +### Obfuscation w/ Spoiler + +First of all, the source code itself serves as an initial configuration. +Preprocessing directives (such as `#include`)'s `#` serve as walls. + +This program uses `double complex` to represent any 2D vector. But, note that +x-axis and y-axis is swapped (real axis = y-axis, imaginary axis = x-axis). +The purpose of swapping is not only obfuscation, but also short coding: for +example, to add gravity to total force, `force += G` suffices, rather than +`force += G*I`. +(Incidentally, you can exert horizontal gravity by using, such as, `-DG=I`) + +Every five entries of `double complex a[]` contain information of one particle: +position, wall-flag, density, force, and velocity, in turn. + +You can use `G`, `P`, and `V` as a guide to find the calculation code of +gravity, pressure, and viscosity forces. + +Though some assignments may look meaningless, it is actually meaningful; it +extracts "integer part of real part" from a complex value by assigning (and +casting) it to an integer-type variable. + + +### Notes about Additional Files + +"logo.txt" is a source of the logo in this remark file. + +"column.txt" is a water column collapse, which is a popular demo of SPH. + +"pour-out.txt" pours you a cup of tea. + +"tanada.txt" simulates "Terrace farming". ("Tanada" means a "terraced rice +fields" in Japanese.) + +"clock.txt" is a "water" clock created by HAMANO Tsukasa. + +Other \*.txt files are due to the judges. + + +"endoh1\_color.c" is a variant that shows the density by using terminal 256 +colors. + + +### Acknowledgment + +I would like to thank my wife @hirekoke for her teaching me the SPH method. + +The judges ordered suggested creating a color version +after the judgment. + +The judges and HAMANO Tsukasa (The silver medalist at this IOCCC) kindly +provided many configuration files. + +-------------------------------------------------------------------------------- + diff --git a/leidenfrost.txt b/leidenfrost.txt new file mode 100644 index 0000000..c0a365e --- /dev/null +++ b/leidenfrost.txt @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + +# # +# # +# # +# @ # +############################################################################### diff --git a/logo.txt b/logo.txt new file mode 100644 index 0000000..d52d541 --- /dev/null +++ b/logo.txt @@ -0,0 +1,19 @@ + + @@@@ @ @ @ @@@@ @ @ @ + @ @ @ @ @ @@@ + @@@@ @ @ @ @ @@@@ @@@@ @ @@@@@ @ @ @ @@ @ @@ @@@ + @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ + @ @ @@@ @ @@@@ @@@@ @ @ @ @ @@@ @ @@ @ @@ @@ @ + + + + + +# # +##### ##### + ###### ###### + ####### ####### + ######## ######## + ######### ######### + ########## ########## + ## ## diff --git a/pour-out.txt b/pour-out.txt new file mode 100644 index 0000000..7c9745a --- /dev/null +++ b/pour-out.txt @@ -0,0 +1,19 @@ + + ### . . . . . . . . . . . ### + ###.......................### + ### . . . . . . . . . . . ### + ###.......................### + ### . . . . . . . . . . . ### + ###.......................### + ### . . . . . . . . . . . ### + ###.......................### + ### . . . . . . . . . . . ### + ###.......................### + ### . . . . . . . . . . . ### + ###.......................## + ### . . . . . . . . . . . ## + ###....................... ### + ################################# ## ## + ############################### ## ## + ## ## + ########### diff --git a/tanada.txt b/tanada.txt new file mode 100644 index 0000000..62b08f2 --- /dev/null +++ b/tanada.txt @@ -0,0 +1,19 @@ + + + ## + ##. . . . . . . . + ##.................. + ##. . . . . . . . . . .. + ##....................... + ##. . . . . . . . . . . .. + ##........................## + ##. . . . . . . . . . . ..## + ############################ ## + ## ## + ############ ## + ## ## + ############ ## + ## ## + ############ ## + ## ## + ############