Improve 2012/endoh1 alt code, add try.alt.sh
The alt code now has an option to use alarm(3) so that one need not hit ctrl-c/intr for each run (default 10 seconds, can be disabled or changed at compilation just like the other macros). This is used in try.alt.sh which shows the program (colour version) on the source code and then the text files provided by the author. The script does two 'versions' for each file: one with setting gravity factor to I (see author's remarks) and one without that. These changes make a nice demonstration of the entry. This commit also fixed a problem that the previous commit caused to do with the alt targets in the Makefile. This should complete the review of 2012/endoh1, leaving two more to go for 2012.
This commit is contained in:
1 parent
af3b4f5166
commit
c9503446e4
7 files changed
+106
-23
No files matched your search
@@ -2,6 +2,7 @@ endoh1
|
||||
endoh1.alt
|
||||
endoh1.alt2
|
||||
endoh1_color
|
||||
endoh1_color.alt2
|
||||
endoh1_color.alt
|
||||
configuration.txt
|
||||
endoh1.orig
|
||||
|
||||
@@ -57,7 +57,7 @@ ARCH=
|
||||
|
||||
# Defines that are needed to compile
|
||||
#
|
||||
CDEFINE= -DG="$G" -DP="$P" -DV="$V" -DS=12321
|
||||
CDEFINE= -DG="$G" -DP="$P" -DV="$V" -DS=12321 -DA=10
|
||||
|
||||
# Include files that are needed to compile
|
||||
#
|
||||
@@ -151,7 +151,7 @@ ${PROG}_color: ${PROG}_color.c
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
alt: data ${ALT_TARGET} ${PROG}.alt2
|
||||
alt: data ${ALT_TARGET}
|
||||
@${TRUE}
|
||||
|
||||
${PROG}.alt: ${PROG}.alt.c
|
||||
|
||||
+29
-14
@@ -4,11 +4,11 @@ make
|
||||
```
|
||||
|
||||
There are two alt versions that let you control the compile time variables that
|
||||
control the fluid behaviour and the added variable to speed up or slow down the
|
||||
fluid: one for the original black and white and the colour one added by the
|
||||
author at the request of the judges. Another version is the deobfuscated version
|
||||
provided by the author as well. See [alternate code](#alternate-code) below for
|
||||
more details.
|
||||
control the fluid behaviour and the added variables to speed up or slow down the
|
||||
fluid as well as setting a timeout (if not 0): one for the original black and
|
||||
white and the colour one added by the author at the request of the judges.
|
||||
Another version is the deobfuscated version provided by the author as well. See
|
||||
[alternate code](#alternate-code) below for more details.
|
||||
|
||||
|
||||
## To use:
|
||||
@@ -52,6 +52,10 @@ make alt alt2
|
||||
The `alt2` is only necessary if you wish to compile the deobfuscated version but
|
||||
it is equivalent in function to the original entry, [endoh1.c](endoh1.c).
|
||||
|
||||
In the `alt` versions a default time of 10 seconds is set as an alarm so that
|
||||
one can more easily go through the list of files to see them all in succession
|
||||
for fun. That is controlled by the variable `A`; 0 disables it.
|
||||
|
||||
If you wish to change the speed you should do:
|
||||
|
||||
```sh
|
||||
@@ -81,14 +85,13 @@ There is no restriction on what the number is because doing so prevents the
|
||||
macros from being defined to `I` which would prevent the author's remarks about
|
||||
it from being done.
|
||||
|
||||
If you want to disable the alarm time, set `A` to 0:
|
||||
|
||||
### Alternate use:
|
||||
```sh
|
||||
make clobber CDEFINE="-DA=0" alt
|
||||
```
|
||||
|
||||
Use `endoh1.alt`, `endoh1_color.alt` and `endoh1.alt2` as you would `endoh1`
|
||||
and `endoh1_color` above.
|
||||
|
||||
|
||||
### Alternate try:
|
||||
It cannot be < 0 or > 60 (arbitrarily selected).
|
||||
|
||||
Try slowing down the display by increasing the sleep time from `12321` to
|
||||
`50000`:
|
||||
@@ -125,13 +128,25 @@ You might try even:
|
||||
make clobber CDEFINE="-DG=I" alt
|
||||
```
|
||||
|
||||
and even:
|
||||
See the author's remarks for details on these macros.
|
||||
|
||||
|
||||
### Alternate use:
|
||||
|
||||
Use `endoh1.alt`, `endoh1_color.alt` and `endoh1.alt2` as you would `endoh1`
|
||||
and `endoh1_color` above.
|
||||
|
||||
|
||||
### Alternate try:
|
||||
|
||||
To see two different ways run on the source file and each of the text files,
|
||||
try:
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DG=I -DV=I" alt
|
||||
./try.alt.sh
|
||||
```
|
||||
|
||||
See the author's remarks for details on these macros.
|
||||
The second run of each will be with the gravity factor set to `I`.
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
@@ -16,7 +16,12 @@
|
||||
# ifndef V
|
||||
# define V 8
|
||||
# endif
|
||||
|
||||
# ifndef A
|
||||
# define A 10
|
||||
# elif A < 0 || A > 60
|
||||
# undef A
|
||||
# define A 10
|
||||
# endif
|
||||
|
||||
# define h for( x=011; 2012/* #
|
||||
# */-1>x ++;)b[ x]//-' winner #
|
||||
@@ -26,7 +31,7 @@
|
||||
## */[i]=e)f(q,w=cabs (d=*p- *q)/2- 1)if(0 <(x=1- w))p[i]+=w*/// ##
|
||||
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[/* ##
|
||||
## */alarm(A);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){z(p [1]*/* ##
|
||||
## */9,2) w;z(G, 3)(d*( 3-p[2] -q[2]) *P+p[4 ]*V-/* ##
|
||||
@@ -34,7 +39,7 @@
|
||||
## */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( S) ;}return 0;}/* ##
|
||||
## */%80- 9?x[b] :16];;usleep( S ) ;}return 0;}/* ##
|
||||
#### ####
|
||||
###############################################################################
|
||||
**###########################################################################*/
|
||||
@@ -16,6 +16,12 @@
|
||||
# ifndef V
|
||||
# define V 8
|
||||
# endif
|
||||
# ifndef A
|
||||
# define A 10
|
||||
# elif A < 0 || A > 60
|
||||
# undef A
|
||||
# define A 10
|
||||
# endif
|
||||
|
||||
# define c y+=( x=ctanh( -cabs/* #
|
||||
# */(4[t ]-=20) /2+9)* 3+3)*// #
|
||||
@@ -30,7 +36,7 @@
|
||||
## */?(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</* ##
|
||||
## */}int main() {alarm(A);for(;( x=getc (stdin))>0;)w=10</* ##
|
||||
## */x?32 <x?4[* r++=w,r]=w+1,*r= r[5]=x ==35,r+=9:0,w-I/* ##
|
||||
## */:(x= w+02); for(;;puts(o),o =b+6){ z(p[1]*9,2)w;z/* ##
|
||||
## */(G,3 )(d*(3 -p[2]-q[2])*P +p[4]* V-q[4]*V )/p/* ##
|
||||
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.alt.sh - demonstrate IOCCC winner 2012/endoh1 alt code
|
||||
#
|
||||
|
||||
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
|
||||
# this way allows us to have the user specify a different compiler in an easy
|
||||
# way.
|
||||
if [[ -z "$CC" ]]; then
|
||||
CC="cc"
|
||||
fi
|
||||
|
||||
|
||||
# unlike other try.sh/try.alt.sh scripts this one has two compiled binaries: one
|
||||
# which sets the gravity factor to I and the other that does not.
|
||||
make clobber CC="$CC" CDEFINE="-DA=10 -DG=I -DS=39000" alt >/dev/null || exit 1
|
||||
# we have to move the endoh1_color.alt to endoh1_color.alt3, not alt2, because
|
||||
# we have to use make clobber which would wipe out endoh1_color.alt2.
|
||||
mv endoh1_color.alt endoh1_color.alt3
|
||||
make clobber CC="$CC" CDEFINE="-DA=10 -DS=39000" alt >/dev/null || exit 1
|
||||
read -r -n 1 -p "Press any key run run slower fluid on endoh1_color.alt.c: "
|
||||
mv endoh1_color.alt3 endoh1_color.alt2
|
||||
# clear screen before continuing
|
||||
clear
|
||||
|
||||
|
||||
# now that we have both binaries we can run each one on the data files, first
|
||||
# the source file.
|
||||
./endoh1_color.alt < endoh1_color.alt.c 2>/dev/null
|
||||
./endoh1_color.alt2 < endoh1_color.alt.c 2>/dev/null
|
||||
clear
|
||||
|
||||
# for each of the supplied text files we will run both 'versions' on them, in
|
||||
# succession, prompting the user for each text file so they know the name.
|
||||
for i in clock.txt column.txt column2.txt column3.txt corners.txt \
|
||||
dripping-pan.txt evaporation.txt flat.txt fountain.txt funnel.txt \
|
||||
funnel2.txt funnel3.txt glass-half-empty.txt leidenfrost.txt logo.txt \
|
||||
pour-out.txt tanada.txt; do
|
||||
|
||||
# to make it more 'fluid' :-) we only prompt once per file even though the
|
||||
# second command is a different file in that the gravity factor is set to I.
|
||||
read -r -n 1 -p "Press any key to run: ./endoh1_color.alt < $i: "
|
||||
./endoh1_color.alt < "$i" 2>/dev/null
|
||||
clear
|
||||
./endoh1_color.alt2 < "$i" 2>/dev/null
|
||||
clear
|
||||
done
|
||||
+12
-3
@@ -3345,9 +3345,18 @@ implicitly (Linux doesn't seem to but macOS does).
|
||||
|
||||
Cody also added two [alt versions](2012/endoh1/README.md#alternate-code) that
|
||||
let one control how fast the fluid moves (how long to sleep in between writes)
|
||||
and also the gravity factor, the pressure factor and the viscosity factor, one
|
||||
for the original entry and one for the alternate colour version that was added
|
||||
by the author, [Yusuke](#yusuke), at the request of the judges.
|
||||
and also the gravity factor, the pressure factor and the viscosity factor as
|
||||
well as an alarm that lets one run it in a loop without having to hit
|
||||
ctrl-c/intr in between (the alarm can be disabled, however). The two different
|
||||
versions is because there are two versions: the original and the colour version
|
||||
added by the author, [Yusuke](#yusuke), at the request of the judges.
|
||||
|
||||
Cody also added the [try.alt.sh](2012/endoh1/try.alt.sh) script compiles the alt
|
||||
code in two ways, one with setting the gravity factor to `I` and another with
|
||||
the default, and which is run on the source file and each of the text files
|
||||
supplied by the author. This code has an alarm set at 10 seconds so that one
|
||||
need not hit ctrl-c/intr in between .. say to make it more fluid :-)
|
||||
|
||||
The [endoh1.alt2.c](2012/endoh1/endoh1.alt.c) was provided by Yusuke as a
|
||||
de-obfuscated version.
|
||||
|
||||
|
||||
Reference in new issue
Block a user