diff --git a/2012/endoh1/.gitignore b/2012/endoh1/.gitignore index 11c2f090c..2bf7c2e2b 100644 --- a/2012/endoh1/.gitignore +++ b/2012/endoh1/.gitignore @@ -5,7 +5,9 @@ configuration.txt endoh1 endoh1.alt endoh1.alt2 +endoh1.alt3 endoh1_color +endoh1_color2 endoh1_color.alt endoh1_color.alt2 endoh1.orig diff --git a/2012/endoh1/Makefile b/2012/endoh1/Makefile index 2b40032f6..d64d108d8 100644 --- a/2012/endoh1/Makefile +++ b/2012/endoh1/Makefile @@ -115,8 +115,8 @@ DATA= column.txt column2.txt column3.txt corners.txt dripping-pan.txt \ funnel3.txt leidenfrost.txt logo.txt pour-out.txt tanada.txt TARGET= ${PROG} ${PROG}_color # -ALT_OBJ= ${PROG}.alt.o ${PROG}_color.alt.o -ALT_TARGET= ${PROG}.alt ${PROG}_color.alt +ALT_OBJ= ${PROG}.alt.o ${PROG}_color.alt.o ${PROG}.alt2.o +ALT_TARGET= ${PROG}.alt ${PROG}_color.alt ${PROG}.alt2 # The factor of gravity # @@ -167,9 +167,7 @@ ${PROG}.alt: ${PROG}.alt.c ${PROG}_color.alt: ${PROG}_color.alt.c ${CC} ${CFLAGS} -DS=${SLEEP} -DA=${TIMER} $< -o $@ ${LDFLAGS} -alt2: ${PROG}.alt2 - @${TRUE} - +# deobfuscated version: ${PROG}.alt2: ${PROG}.alt2.c ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} diff --git a/2012/endoh1/README.md b/2012/endoh1/README.md index 31a206162..6331c1a17 100644 --- a/2012/endoh1/README.md +++ b/2012/endoh1/README.md @@ -6,31 +6,36 @@ make There are two alt versions that let you control the compile time variables that 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. +white and one for the colour one added by the author (at the request of the +judges at the time of the contest). Another version is the deobfuscated version +provided by the author as well. See the [Alternate code](#alternate-code) +section below for more details. ## To use: ```sh -./endoh1 < configuration.txt +./endoh1 < file ``` +WARNING: if you're sensitive to/don't like flashing colours/text or just want to +see what this looks like not going so fast then you might wish to try the +[Alternate code](#alternate-code) instead. + ## Try: ```sh -./endoh1 < endoh1.c +./try.bw.sh endoh1.c +./try.sh endoh1.c -./endoh1 < pour-out.txt +./try.bw.sh pour-out.txt +./try.sh pour-out.txt -./endoh1 < fountain.txt +./try.bw.sh fountain.txt +./try.sh fountain.txt ``` -Also try using `endoh1_color` as you would `endoh1` above. `make` will compile -this by default. - ## Alternate code: @@ -46,46 +51,19 @@ the fluid and change the behaviour of the fluid. The file For the default values, try: ```sh -make alt alt2 +make alt ``` -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: +one can more easily go through the list of files to see them all in succession, +for fun. That is controlled by the variable `TIMER` at compilation. +For instance if you wish to change the value to 5: ```sh -make clobber SLEEP=N alt +make clobber TIMER=5 alt ``` -where `N` is number or the letter `I`. - -WARNING: if you're sensitive to flashing colours or any flashing at all do make -sure you don't decrease the value of `S`, the sleep time passed to `usleep(3)`, -too much. - -If however you wish to change the gravity factor, pressure factor and/or -viscosity factor, you should redefine the values `G`, `P` and/or `V` macros, -respectively, with the same caveat about numbers for `S` above. For instance if -you wish to change the viscosity and pressure factors but leave the other macros -alone: - -```sh -make clobber VISCOSITY=X PRESSURE=Y alt -``` - -where `X` and `Y` are numbers or the letter `I` and which are, respectively, the -viscosity and pressure factors. - -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: +If you want to disable the alarm time, set it to 0: ```sh make clobber TIMER=0 alt @@ -93,26 +71,41 @@ make clobber TIMER=0 alt It cannot be < 0 or > 60 (arbitrarily selected). -Try slowing down the display by increasing the sleep time from `12321` to -`50000`: +The `SLEEP` variable is to delay the time between updates to make it easier to +see and to not flash too quickly. The code protects against a value < 0 and +defaults to 12321 but you can change it to. For instance to slow it down you +could increase the sleep time from `12321` to `50000`: ```sh make clobber SLEEP=50000 alt ``` -Now try using both `endoh1.alt` and `endoh1_color.alt` as you would `endoh1` above. -Also try speeding up the display by decreasing the sleep time from `12321` to +If you wish to speed it up you might decrease the sleep time from `12321` to `9999`: ```sh -make clobber SLEEP=9999 alt2 +make clobber SLEEP=9999 alt ``` -WARNING: again, be careful with too low a value if you're sensitive to flashing -colours or anything at all. +WARNING: the lower the value the faster it will flash so be careful if you're +sensitive to this. + + +If you wish to change the gravity factor, pressure factor and/or +viscosity factor, you should redefine the values `GRAVITY`, `PRESSURE` and/or +`VISCOSITY` macros, respectively. For instance if you wish to change the +viscosity and pressure factors but leave the other values alone: + +```sh +make clobber VISCOSITY=X PRESSURE=Y alt +``` + +where `X` and `Y` are numbers or the letter `I` and which are, respectively, the +viscosity and pressure factors. There is no attempt to check the value or type +because doing so prevents the macros from being defined to `I` which would +prevent the author's remarks about it from being done. -Now try using both `endoh1.alt` and `endoh1_color.alt` as you would `endoh1` above. You might also wish to try redefining the macros `G`, `P` and/or `V`. For instance: @@ -128,7 +121,13 @@ You might try even: make clobber GRAVITY=I alt ``` -See the author's remarks for details on these macros. +See the author's remarks for details on these macros where: + +``` +G = GRAVITY +P = PRESSURE +V = VISCOSITY +``` ### Alternate use: @@ -148,6 +147,12 @@ try: The second run of each will be with the gravity factor set to `I`. +To see the same thing but in the original uncoloured version, try: + +```sh +./try.alt.bw.sh +``` + ## Judges' remarks: diff --git a/2012/endoh1/endoh1.alt.c b/2012/endoh1/endoh1.alt.c index 465ab5f4b..31ba020c2 100644 --- a/2012/endoh1/endoh1.alt.c +++ b/2012/endoh1/endoh1.alt.c @@ -3,7 +3,7 @@ # include //|||| ,____. IOCCC- # # ifndef S # define S 12321 -# elif S < 1 +# elif S < 0 # undef S # define S 12321 # endif diff --git a/2012/endoh1/try.alt.bw.sh b/2012/endoh1/try.alt.bw.sh new file mode 100755 index 000000000..041acfb48 --- /dev/null +++ b/2012/endoh1/try.alt.bw.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +# +# try.alt.bw.sh - demonstrate IOCCC winner 2012/endoh1 alt code w/o colour +# + +# 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. +[[ -z "$CC" ]] && CC="cc" + +# We will use a timer (alarm(3) value) of 10 (the default) but we will allow the +# user to redefine it. The code protects against negative values and values > 60 +# (arbitrary) but if the user is silly enough to specify a value that is not a +# number that's on them. +[[ -z "$TIMER" ]] && TIMER=10 + +# We will use a sleep value of 39000 but just like the others we will let the +# user override it if they so wish. The code protects against values < 0 but if +# someone chooses a value that's not a number that's on them. +[[ -z "$SLEEP" ]] && SLEEP=39000 + +# We will let users redefine GRAVITY but only for the version that is NOT I +# (letter I not digit 1). Just like the others we do not protect against input +# that is not a number and in the case of GRAVITY it is even documented that +# some non number values (I) are good to try. +[[ -z "$GRAVITY" ]] && GRAVITY=1 + +# We will use the default 8 for VISCOSITY but we'll allow the user to redefine +# it. We don't protect against < 0 as it doesn't seem to break the program to +# have < 0 but if they set it to a non number value that's on them. +[[ -z "$VISCOSITY" ]] && VISCOSITY=8 + +# We will use the default PRESSURE of 4 but like the other variables we will let +# the user redefine it. We do not protect against any value, even non-numbers. +# If someone wants to set it to something else that's on them. +[[ -z "$PRESSURE" ]] && PRESSURE=4 + +# unlike other try.sh/try.alt.sh scripts this one has two compiled binaries: one +# which sets the gravity factor to I (letter I, not digit 1) and the other that +# does not. Thus we do not compile it like the others. +echo "$ make clobber CC=$CC TIMER=$TIMER SLEEP=$SLEEP GRAVITY=I VISCOSITY=$VISCOSITY PRESSURE=$PRESSURE alt" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +make clobber CC="$CC" TIMER="$TIMER" SLEEP="$SLEEP" GRAVITY=I VISCOSITY="$VISCOSITY" PRESSURE="$PRESSURE" alt >/dev/null || exit 1 +# we have to move the endoh1.alt to endoh1.alt3, not alt2, because +# we have to use make clobber which would wipe out endoh1.alt2. +read -r -n 1 -p "Press any key to move endoh1.alt to endoh1.alt3: " +echo 1>&2 +mv -v endoh1.alt endoh1.alt3 +echo 1>&2 +echo "$ make clobber CC=$CC TIMER=$TIMER SLEEP=$SLEEP GRAVITY=$GRAVITY VISCOSITY=$VISCOSITY PRESSURE=$PRESSURE alt" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +make clobber CC="$CC" TIMER="$TIMER" SLEEP="$SLEEP" GRAVITY="$GRAVITY" VISCOSITY="$VISCOSITY" PRESSURE="$PRESSURE" alt >/dev/null || exit 1 +read -r -n 1 -p "Press any key to move endoh1.alt3 to endoh1.alt2: " +echo 1>&2 +mv -v endoh1.alt3 endoh1.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. +read -r -n 1 -p "Press any key to run: ./endoh1.alt < endoh1.alt.c 2>/dev/null: " +echo 1>&2 +./endoh1.alt < endoh1.alt.c 2>/dev/null +echo 1>&2 +# reset terminal sanity +reset +read -r -n 1 -p "Press any key to run: ./endoh1.alt2 < endoh1.alt.c 2>/dev/null: " +echo 1>&2 +./endoh1.alt2 < endoh1.alt.c 2>/dev/null +# reset terminal sanity +reset + +# 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.alt < $i: " + clear + ./endoh1.alt < "$i" 2>/dev/null + clear + ./endoh1.alt2 < "$i" 2>/dev/null + # reset terminal sanity + reset +done diff --git a/2012/endoh1/try.alt.sh b/2012/endoh1/try.alt.sh index 56a48d044..8e5b869ae 100755 --- a/2012/endoh1/try.alt.sh +++ b/2012/endoh1/try.alt.sh @@ -1,34 +1,76 @@ #!/usr/bin/env bash # -# try.alt.sh - demonstrate IOCCC winner 2012/endoh1 alt code +# try.alt.sh - demonstrate IOCCC winner 2012/endoh1 alt code with colour # # 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 +[[ -z "$CC" ]] && CC="cc" +# We will use a timer (alarm(3) value) of 10 (the default) but we will allow the +# user to redefine it. The code protects against negative values and values > 60 +# (arbitrary) but if the user is silly enough to specify a value that is not a +# number that's on them. +[[ -z "$TIMER" ]] && TIMER=10 + +# We will use a sleep value of 39000 but just like the others we will let the +# user override it if they so wish. The code protects against values < 0 but if +# someone chooses a value that's not a number that's on them. +[[ -z "$SLEEP" ]] && SLEEP=39000 + +# We will let users redefine GRAVITY but only for the version that is NOT I +# (letter I not digit 1). Just like the others we do not protect against input +# that is not a number and in the case of GRAVITY it is even documented that +# some non number values (I) are good to try. +[[ -z "$GRAVITY" ]] && GRAVITY=1 + +# We will use the default 8 for VISCOSITY but we'll allow the user to redefine +# it. We don't protect against < 0 as it doesn't seem to break the program to +# have < 0 but if they set it to a non number value that's on them. +[[ -z "$VISCOSITY" ]] && VISCOSITY=8 + +# We will use the default PRESSURE of 4 but like the other variables we will let +# the user redefine it. We do not protect against any value, even non-numbers. +# If someone wants to set it to something else that's on them. +[[ -z "$PRESSURE" ]] && PRESSURE=4 # 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" TIMER=10 GRAVITY=I SLEEP=39000 alt >/dev/null || exit 1 +# which sets the gravity factor to I (letter I, not digit 1) and the other that +# does not. Thus we do not compile it like the others. +echo "$ make clobber CC=$CC TIMER=$TIMER SLEEP=$SLEEP GRAVITY=I VISCOSITY=$VISCOSITY PRESSURE=$PRESSURE alt" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +make clobber CC="$CC" TIMER="$TIMER" SLEEP="$SLEEP" GRAVITY=I VISCOSITY="$VISCOSITY" PRESSURE="$PRESSURE" 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" TIMER=10 SLEEP=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 +read -r -n 1 -p "Press any key to move endoh1_color.alt to endoh1_color.alt3: " +echo 1>&2 +mv -v endoh1_color.alt endoh1_color.alt3 +echo 1>&2 +echo "$ make clobber CC=$CC TIMER=$TIMER SLEEP=$SLEEP GRAVITY=$GRAVITY VISCOSITY=$VISCOSITY PRESSURE=$PRESSURE alt" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +make clobber CC="$CC" TIMER="$TIMER" SLEEP="$SLEEP" GRAVITY="$GRAVITY" VISCOSITY="$VISCOSITY" PRESSURE="$PRESSURE" alt >/dev/null || exit 1 +read -r -n 1 -p "Press any key to move endoh1_color.alt3 to endoh1_color.alt2: " +echo 1>&2 +mv -v 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. +read -r -n 1 -p "Press any key to run: ./endoh1_color.alt < endoh1_color.alt.c 2>/dev/null: " +echo 1>&2 ./endoh1_color.alt < endoh1_color.alt.c 2>/dev/null +echo 1>&2 +# reset terminal sanity +reset +read -r -n 1 -p "Press any key to run: ./endoh1_color.alt2 < endoh1_color.alt.c 2>/dev/null: " +echo 1>&2 ./endoh1_color.alt2 < endoh1_color.alt.c 2>/dev/null -clear +# reset terminal sanity +reset # 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. @@ -40,8 +82,10 @@ for i in clock.txt column.txt column2.txt column3.txt corners.txt \ # 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: " + clear ./endoh1_color.alt < "$i" 2>/dev/null clear ./endoh1_color.alt2 < "$i" 2>/dev/null - clear + # reset terminal sanity + reset done diff --git a/2012/endoh1/try.bw.sh b/2012/endoh1/try.bw.sh new file mode 100755 index 000000000..81609887a --- /dev/null +++ b/2012/endoh1/try.bw.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# +# try.bw.sh - demonstrate IOCCC winner 2012/endoh1 w/o colour +# + +# 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 + +make CC="$CC" all >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear + +if [[ "$#" -ne 1 ]]; then + echo "usage: $0 file" 1>&2 + exit 1 +fi + +read -r -n 1 -p "Press any key to run: ./endoh1 < $1 (ctrl-c/intr to end program): " +./endoh1 < "$1" diff --git a/2012/endoh1/try.sh b/2012/endoh1/try.sh new file mode 100755 index 000000000..4c211c98a --- /dev/null +++ b/2012/endoh1/try.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2012/endoh1 with colour +# + +# 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 + +make CC="$CC" all >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear + +if [[ "$#" -ne 1 ]]; then + echo "usage: $0 file" 1>&2 + exit 1 +fi + +read -r -n 1 -p "Press any key to run: ./endoh1_color < $1 (ctrl-c/intr to end program): " +./endoh1_color < "$1" diff --git a/thanks-for-help.md b/thanks-for-help.md index 035241a8b..b82898c5b 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -3727,8 +3727,16 @@ 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. +Cody also added the [try.alt.bw.sh](/2012/endoh1/try.alt.bw.sh) which is the +same as the `try.alt.sh` except it does not use the coloured version. + +Finally Cody added the [try.sh](/2012/endoh1/try.sh) and +[try.bw.sh](/2012/endoh1/try.bw.sh) which correspond to the coloured version +[endoh1_color.c](/2012/endoh1/endoh1_color.c) and the original submitted +version without colour, [endoh1.c](/2012/endoh1/endoh1.c). + +The [endoh1.alt2.c](/2012/endoh1/endoh1.alt2.c) was provided by the author, +[Yusuke](#yusuke), at the time of the contest as a de-obfuscated version. ## [2012/endoh2](/2012/endoh2/endoh2.c) ([README.md](/2012/endoh2/README.md))