From a046311811831f7ea58f82a880635977c1de7784 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 23 Jan 2024 10:59:09 -0800 Subject: [PATCH] Add 1994/westley alt code (for easier use) As 1994/westley requires (for good display) 80 columns, 8 character tabs and wraparound it makes it harder to run the entry to enjoy it with modern systems. Also because it generates messages through error messages (of the compiler line) different compilers will show it differently and it can end up being harder to follow. The alt code uses the same logic but instead of using #includes (of files that don't exist) it uses printf(3). Everything else is the same. The try.alt.sh is just like the try.sh but for the alt code. Since the alt code is ideal for modern systems the original code is suggested second. This can be changed of course. --- 1994/westley/.gitignore | 2 + 1994/westley/Makefile | 8 ++- 1994/westley/README.md | 70 ++++++++++++++++++---- 1994/westley/try.alt.sh | 63 ++++++++++++++++++++ 1994/westley/try.sh | 2 - 1994/westley/westley.alt.c | 119 +++++++++++++++++++++++++++++++++++++ thanks-for-help.md | 4 ++ 7 files changed, 254 insertions(+), 14 deletions(-) create mode 100755 1994/westley/try.alt.sh create mode 100644 1994/westley/westley.alt.c diff --git a/1994/westley/.gitignore b/1994/westley/.gitignore index c95388e36..8c43a732c 100644 --- a/1994/westley/.gitignore +++ b/1994/westley/.gitignore @@ -1,9 +1,11 @@ # # sort with: sort -d -u +a.out *.dSYM indent indent.c indent.o prog.orig westley +westley.alt westley.orig diff --git a/1994/westley/Makefile b/1994/westley/Makefile index 51e819ef0..051910be9 100644 --- a/1994/westley/Makefile +++ b/1994/westley/Makefile @@ -111,8 +111,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} # -ALT_OBJ= -ALT_TARGET= +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# @@ -140,6 +140,10 @@ ${PROG}: ${PROG}.c alt: data ${ALT_TARGET} @${TRUE} + +${PROG}.alt: ${PROG}.alt.c + ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} + # data files # data: ${DATA} diff --git a/1994/westley/README.md b/1994/westley/README.md index 767d5cc34..8af4e9ddd 100644 --- a/1994/westley/README.md +++ b/1994/westley/README.md @@ -1,16 +1,16 @@ ## To build: ```sh -make all +make alt ``` -NOTE: the purpose of this entry is to escape the dungeon via the compiler line -where you **get messages as compiler errors**. Depending on the compiler line you -will get different error messages and one compiler line will make you win the -game! - -NOTE: your terminal should be set to 80 columns, 8 character tabs, and -wraparound. +We recommend that you try the alternate version first as the original entry +requires (for good display) 80 columns and 8 character tabs with wraparound. The +alt code is the same as the original except that the original code used +`#include`s of files that do not exist to generate the messages (as compiler +errors) whereas the alt code uses `printf(3)`. The purpose of the game is to +escape the dungeon. For the original entry see [Original code](#original-code) +below. ## To use: @@ -18,9 +18,53 @@ wraparound. There is no running as such. See below. -## Try: +### Try: -But for something more interesting try compiling it with +For something more interesting try compiling it with +different cc arguments and then run the program each time. For example: + +```sh +cc -Describe -Door westley.alt.c && ./a.out +cc -Describe -Drain westley.alt.c && ./a.out +``` + +To see the game from start to finish, try: + +```sh +./try.alt.sh +``` + + +## Original code: + +NOTE: the purpose of this entry is to escape the dungeon via the compiler line +where you **get messages as compiler errors**. Depending on the compiler line you +will get different error messages and one compiler line will make you win the +game! + +NOTE: your terminal should be set to 80 columns, 8 character tabs, and +wraparound. The alternate code does not have this limitation and it is for this +reason that we recommend you try it first. + + +### Original build: + +```sh +make all +``` + +Depending on the compilation line you will get different messages (as errors) +which let you play the game. + + +## Original use: + +There is no running as such. See below. + + +## Original try: + +For something more interesting try compiling it with different cc arguments. For example: ```sh @@ -28,6 +72,12 @@ cc -Describe -Door westley.c cc -Describe -Drain westley.c ``` +To see the game from start to complete, try: + +```sh +./try.sh +``` + ## Judges' remarks: diff --git a/1994/westley/try.alt.sh b/1994/westley/try.alt.sh new file mode 100755 index 000000000..4ff548f14 --- /dev/null +++ b/1994/westley/try.alt.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +# +# try.alt.sh - demonstrate IOCCC winner 1994/westley alt code +# + +# make sure CC is set so that one can control what compiler to use in an easy +# way. +if [[ -z "$CC" ]]; then + CC="cc" +fi + +rm -f a.out +"${CC}" -Describe -Door westley.alt.c && ./a.out +sleep 1 +echo 1>&2 +"${CC}" -Describe -Drain westley.alt.c && ./a.out +sleep 1 +echo 1>&2 +"${CC}" -Describe -Dwarf westley.alt.c && ./a.out +sleep 1 +echo 1>&2 +"${CC}" -Describe -Debris westley.alt.c && ./a.out # or -Dungeon +sleep 1 +echo 1>&2 +"${CC}" -Describe -Desk westley.alt.c && ./a.out +sleep 1 +echo 1>&2 +"${CC}" -Describe -Dime westley.alt.c && ./a.out +sleep 1 +echo 1>&2 +"${CC}" -Describe -Directory westley.alt.c && ./a.out +sleep 1 +echo 1>&2 +"${CC}" -Dial -DUNgeon0614 westley.alt.c && ./a.out +sleep 1 +echo 1>&2 +"${CC}" -Drink -Daiquiri westley.alt.c && ./a.out +sleep 1 +echo 1>&2 +"${CC}" -Drop -Daiquiri westley.alt.c && ./a.out +sleep 1 +echo 1>&2 +"${CC}" -Drop -Dwarf -Daiquiri westley.alt.c && ./a.out # or -Drop -Down -Daiquiri +sleep 1 +echo 1>&2 +"${CC}" -Describe -Document westley.alt.c && ./a.out +sleep 1 +echo 1>&2 +"${CC}" -Depress -Dotted -Dog westley.alt.c && ./a.out +sleep 1 +echo 1>&2 +"${CC}" -Depress -Dalmatian westley.alt.c && ./a.out # also accepts "Dalmation" [sic] +sleep 1 +echo 1>&2 +"${CC}" -Deposit -Dime westley.alt.c && ./a.out +sleep 1 +echo 1>&2 +"${CC}" -Drop -Donut westley.alt.c && ./a.out +sleep 1 +echo 1>&2 +"${CC}" -Drop -Donut -Down -Drain westley.alt.c && ./a.out # or -Drop -Dwarf -Donut +echo 1>&2 +rm -f a.out diff --git a/1994/westley/try.sh b/1994/westley/try.sh index 137604e73..5b17de9ea 100755 --- a/1994/westley/try.sh +++ b/1994/westley/try.sh @@ -23,8 +23,6 @@ fi clear - - "${CC}" -Describe -Door westley.c "${CC}" -Describe -Drain westley.c "${CC}" -Describe -Dwarf westley.c diff --git a/1994/westley/westley.alt.c b/1994/westley/westley.alt.c new file mode 100644 index 000000000..7efcf6438 --- /dev/null +++ b/1994/westley/westley.alt.c @@ -0,0 +1,119 @@ +#include +int main() +{ +#if rop&onut&((own&rain)|warf) +printf("The orc scrambles to the drain,\n" +"trying to get the donut; you\n" +"run out the door and escape!\n" +"\n" +" The End\n"); +return 0; +#else +#if escribe +#if ocument +printf("It reads:\n" +" Depress Dotted Dog\n"); +return 0; +#else +#if oor +printf("The door is decorated with relief\n" +"figures of various dog breeds.\n"); +return 0; +#else +#if rain +printf("Through the drain you see a dwarf\n" +"in another cell.\n"); +return 0; +#else +#if warf +printf("The gnarled dwarf looks thirsty.\n"); +return 0; +#else +#if ungeon|ebris +printf("You notice a desk, a phone, and\n" +"a phone directory among the clutter.\n"); +return 0; +#else +#if esk +printf("There are some dimes on the desk.\n"); +return 0; +#else +#if irectory +printf("It reads:\n" +" Pixie's Pub -\n" +" instant service -\n" +" Dial DUNgeon0614\n"); +return 0; +#else +printf("You notice nothing unusual.\n"); +return 0; +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#else +#if ial&UNgeon0614 +printf("Pixie takes your order, and\n" +"magically, the room is filled\n" +"with banana daiquiris.\n"); +return 0; +#endif +#if rink&aiquiri +printf("As you drink, a voice from\n" +"below says 'Could you drop\n" +"one down here?'\n"); +return 0; +#endif +#if rop&aiquiri +#if warf|own +printf("The dwarf eagerly accepts\n" +"the drink. 'Thanks! Here,\n" +"I found this, but I can't\n" +"understand it.' He hands\n" +"you a document.\n"); +return 0; +#else +printf("You drop the drink\n" +"on the floor.\n"); +return 0; +#endif +#endif +#if epress&(almatian|almation) +printf("As you press the dalmatian\n" +"figure, the door opens - only\n" +"to reveal a menacing orc by\n" +"a vending machine (with a\n" +"sign reading 'DEPOSIT MONEY').\n"); +return 0; +#endif +#if eposit&(ime|imes) +printf("Donuts spill out; you get\n" +"some, the orc hungrily eats\n" +"the rest.\n"); +return 0; + +#endif +#if rop&onut + +printf("The orc quickly eats the\n" +"donut; he still bars the\n" +"way.\n"); + +return 0; +#endif +#if rop+epress+ime+eposit+rink+aiquiri+onut==1 + +printf("Be more specific.\n"); +return 0; +#endif +printf("You are in a debris-filled\n" +"dungeon; a door bars the\n" +"way, and sludge trickles into\n" +"a floor drain.\n"); +return 0; +#endif +#endif +} diff --git a/thanks-for-help.md b/thanks-for-help.md index 17135538a..f2194b9bf 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -2001,6 +2001,10 @@ compiler commands and added a script [try.sh](/1994/westley/try.sh) to automate the spoiler commands to make it easier to see the game in action from start to finish. +Cody also added the alternate version that will look fine on terminals not set +to 80 columns and the [try.alt.sh](/1994/westley/try.alt.sh) script to automate +the play along the lines of the [try.sh](/1994/westley/try.sh) script. + # 1995