diff --git a/2006/sloane/Makefile b/2006/sloane/Makefile index 32d78712a..d4bf0b5b8 100644 --- a/2006/sloane/Makefile +++ b/2006/sloane/Makefile @@ -58,11 +58,11 @@ ARCH= # Defines that are needed to compile # -CDEFINE= +CDEFINE= -DZ=65000 # Include files that are needed to compile # -CINCLUDE= +CINCLUDE= -include math.h -include stdio.h # Optimization # @@ -74,7 +74,7 @@ CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT} # Libraries needed to build # -LIBS= +LIBS= -lm # C compiler to use # @@ -115,8 +115,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} # -ALT_OBJ= -ALT_TARGET= +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# @@ -138,6 +138,9 @@ ${PROG}: ${PROG}.c alt: data ${ALT_TARGET} @${TRUE} +${PROG}.alt: ${PROG}.alt.c + ${CC} ${CFLAGS} $< -o $@ ${LIBS} + # data files # data: ${DATA} diff --git a/2006/sloane/README.md b/2006/sloane/README.md index b4a20c5e3..061e77b17 100644 --- a/2006/sloane/README.md +++ b/2006/sloane/README.md @@ -1,9 +1,7 @@ # Homer's Favorite - Andy Sloane - 1041 Seneca St. - Hartford, WI 53027 - US +Andy Sloane +US ## To build: @@ -15,7 +13,10 @@ make work with clang which is stricter on the type of args to main(). Curiously although clang requires the types of args to be strictly correct it allows for only one arg which he made it as the second arg was not used and this allows for -a closer match to the original format of the entry. Thank you Cody for your +a closer match to the original format of the entry. He also made sure that the +Makefile links in `libm` as not all systems do this by default. Since the author +suggested that the lack of certain `#include`s might break the program in some +systems he added `-include ...` to the Makefile as well. Thank you Cody for your assistance! @@ -28,6 +29,10 @@ assistance! WARNING: if you are easily overstimulated with fast movement or have photosensitivity please be careful running this entry! +An alternatively version of this entry exists so that one can actually see what +is going on. This is also more ideal for those who are overstimulated by fast +movements. See the alternate code section below. + ## Try: @@ -35,6 +40,30 @@ photosensitivity please be careful running this entry! echo "Do or do not. There is no try." ``` +### Alternate code: + +The alternate version, provided by [Cody Boone +Ferguson](/winners.html#Cody_Boone_Ferguson), uses `usleep()` so one can enjoy +the entry with modern systems and which will not be too stimulating for those +who have a problem with fast moving text (like himself). It uses the `Z` macro +as the parameter to `usleep()` which you can override. The default is +`-DZ=65000`. To compile with the default: + + +```sh +make alt +``` + +If you wish to override the sleep value try something like: + +```sh +make CDEFINE="-DZ=70000" clobber alt +``` + +Use `sloane.alt` as you would `sloane` above. + +Thank you Cody! + ## Judges' Comments: Looks almost good enough to eat, dunnit? I suppose you could argue that, @@ -43,13 +72,14 @@ at first blush, this looks like a self-reproducing program. ## Author's remarks: This program doesn't require any special build options, other than that it -uses sin and cos and hence requires the math library. +uses `sin()` and `cos()` and hence requires the math library. You will almost certainly get a compiler warning because I declared a bunch of global ints without types. The code looks better this way, though, I -think. There are also no #includes, so there may be warnings for -undeclared references to printf, etc. There's a chance that my failure to -include math.h or declare sin or cos will make the donut not render +think. There are also no `#include`s, so there may be warnings for +undeclared references to `printf()`, etc. There's a chance that my failure to +include `math.h` or declare `sin()` or `cos()` will make the +[donut](https://en.wikipedia.org/wiki/Doughnut) not render properly -- it's worked on every system I've tried so far though. You will need some kind of VT100-ish emulation; so while this compiles and @@ -59,12 +89,11 @@ The shape of the source gives a hint about its output: it's a little animation of a shaded donut rotating over an infinite checkerboard. Like many IOCCC entries, it is thus self-documenting. -I wanted to create something as "pure" as I could - meaning that the -entire source code is shaped into a work of art, without being prefixed -by any #define hacks, or even #includes, _and_ is portable enough to not -require any special libraries to do the animating. I achieved this with -two standard escape codes for clearing the screen and moving the cursor -back to the top-left. +I wanted to create something as "pure" as I could - meaning that the entire +source code is shaped into a work of art, without being prefixed by any +`#define` hacks, or even `#includes`, _and_ is portable enough to not require +any special libraries to do the animating. I achieved this with two standard +escape codes for clearing the screen and moving the cursor back to the top-left. The donut isn't raytraced. It's much simpler than that. diff --git a/2006/sloane/sloane.alt.c b/2006/sloane/sloane.alt.c new file mode 100644 index 000000000..3a0c6362f --- /dev/null +++ b/2006/sloane/sloane.alt.c @@ -0,0 +1,32 @@ +_,x,y,o ,N;char b[1920] ;p(n,c) +{for(;n --;x++) c==10?y +=80,x= +o-1:x>= 0?80>x? c !='~'?b +[y+x]=c :0: 0:0;}c( + q,l,r) char*l,*r;{while (q>=0)q + =("E" "?yYrIxC{e^}KhE>[|LXbj}" "dOVsJ" + "@" "idOV{Yab[bW}[bW}\\qFywyv{D" "ma\\A" + "" "Ztq?Lyw>e{|Zq>Y\\gq\\qI[tYBe{w" "yvDZE\ +vBA[`_" "Lo>}KcqdYrWqKxzKtW]|DXRwsfcUaT\\\ +KXw{Y" "RsFwsFwsFw{zaqyaz|FmMpyaoyI\\]cuUw{J" +[_/6] -62>>_++%6&1?r[q]:l[q])-99;return q;}E(a +){for (o=x=a,y=0,_=0;_ <1006;)a=" /\\\n" + "~|_."[c(6,"b" "cd\\a[g","^`" "_e" + "]fh")+8], p( "#$%" "&'()*+,-.1"[ c(11 + ,"_ac[]\\YZi" "jkm", "`bd^efghXWlV" )+13 + ]-34,a);}main (k ){ float z[1920] ,A=0 +,B=0 ,i,j; puts("" "\x1b" "[2J");for(;; +) { float e=sin(A ), n= sin(B),g=cos( +A),m =cos(B);for(k =0;k< 1840;k++)y=-k +/80- 10,o=41+(k%80- 40)*1.3/y+n,N= + A-100.0/y, b[k]= ".#"[o+N&1],z[k] =0;E( + 80-(int)(9*B)%250);for(j=0;6.28>j;j+=0.07 )for( + i=0;6.28>i;i+=0.02) { float c=sin(i),d =cos(j + ),f=sin(j),h=d+2,D=15/(c*h*e+f*g+5 ),l=cos +(i),t=c *h*g-f*e;x=40+2*D*(l*h*m-t*n),y= 12 ++D*(l*h *n+t*m),o=x+80*y,N=8*((f*e-c *d* +g)*m-c* d*e-f*g-l*d*n);if(D>z[o] )z[o] +=D,b[o] =" ..,,-++=#$@"[ N>0?N:0 + ] ; } printf( + "\x1b[" "H" );usleep(Z);for(k =1;1841 + >k;k++) putchar (k%80?b [k]:10) + ; A += 0.053;B +=0.037 ; } }