diff --git a/2014/sinon/README.md b/2014/sinon/README.md index 786e5be72..60a9b21e2 100644 --- a/2014/sinon/README.md +++ b/2014/sinon/README.md @@ -8,7 +8,9 @@ make ## To use: ```sh -cp -f prog.c run.c; ./hecate.sh +./hecate.sh + +./glock.sh ``` @@ -33,7 +35,7 @@ or unspecified behavior? ### Summary -Sinon is a game of timing, the goal is to eliminate all enemies in +`Sinon` is a game of timing, the goal is to eliminate all enemies in under one minute. To start, compile and run the program. To resume, compile and run the @@ -48,7 +50,7 @@ gcc -O2 run.c -o run && ./run | tee run.c ### Details -Sinon is played by compiling and running the output repeatedly. Two +`Sinon` is played by compiling and running the output repeatedly. Two factors determine what actions are taken: + Time since last compilation. @@ -58,7 +60,7 @@ If you fire too quickly, the weapon will jam. If you fire too slowly, you will not be able to eliminate all the enemies in time. Thus the primary objective of the game is to time your compilations just right. -Sinon has two weapons that are selected based on compiler optimization +`Sinon` has two weapons that are selected based on compiler optimization level: + "gcc -O2" or "clang -O2" will fire Hecate II, a powerful rifle that @@ -80,7 +82,7 @@ compilers. ### Compatibility -Sinon has been tested and verified to work on these platforms: +`Sinon` has been tested and verified to work on these platforms: + gcc 4.4.3 on Linux. + gcc 4.4.5 on Linux. @@ -93,14 +95,14 @@ Sinon has been tested and verified to work on these platforms: + tcc 0.9.25 on JS/Linux (no optimization, so only "hard" mode is available). -Sinon is intended to be played in a 80x25 terminal. +`Sinon` is intended to be played in a 80x25 terminal. ### Miscellaneous features -Sinon might be the first game that uses compiler optimization level as +`Sinon` might be the first game that uses compiler optimization level as a primary input. -Sinon has a demo mode that plays the game automatically. Make sure +`Sinon` has a demo mode that plays the game automatically. Make sure that there are no files named "run" and "run.c" in current directory (they will be overwritten) and run: @@ -110,9 +112,9 @@ perl prog.c | bash File size and CRC32 of [prog.c](prog.c) are embedded in line 7. -Process for making Sinon is included in [spoiler.html](spoiler.html). +Process for making `Sinon` is included in [spoiler.html](spoiler.html). -Layout of this code is based on Asada Shino, also known as "Sinon", +Layout of this code is based on Asada Shino, also known as "`Sinon`", from Sword Art Online. diff --git a/2014/sinon/glock.sh b/2014/sinon/glock.sh index 4e32ed664..ae96f52e6 100755 --- a/2014/sinon/glock.sh +++ b/2014/sinon/glock.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -cc -O0 run.c -o run > /dev/null && ./run | tee run.c +cp -f prog.c run.c && cc -O0 run.c -o run > /dev/null && ./run | tee run.c diff --git a/2014/sinon/hecate.sh b/2014/sinon/hecate.sh index 3f1ff87db..f9e1ab390 100755 --- a/2014/sinon/hecate.sh +++ b/2014/sinon/hecate.sh @@ -1,2 +1,2 @@ #!/usr/bin/env bash -cc -O2 run.c -o run > /dev/null && ./run | tee run.c +cp -f prog.c run.c && cc -O2 run.c -o run > /dev/null && ./run | tee run.c diff --git a/2014/sinon/try.sh b/2014/sinon/try.sh index a29de9df2..0a63aa266 100755 --- a/2014/sinon/try.sh +++ b/2014/sinon/try.sh @@ -15,9 +15,32 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear +# find out if perl is installed +PERL="$(type -P perl)" +if [[ -n "$PERL" ]]; then + read -r -n 1 -p "Press any key to play the game automatically ($PERL prog.c | bash): " + echo 1>&2 + "$PERL" prog.c | bash + echo 1>&2 +fi + while :; do - cp -f prog.c run.c; ./hecate.sh; ./glock.sh; sleep 3; ./glock.sh; sleep 1; ./hecate.sh + read -r -n 1 -p "Press any key to run: ./hecate.sh: " + echo 1>&2 + ./hecate.sh + + read -r -n 1 -p "Press any key to run: ./glock.sh: " + echo 1>&2 + ./glock.sh + + read -r -n 1 -p "Press any key to run: ./glock.sh: " + echo 1>&2 + ./glock.sh + + read -r -n 1 -p "Press any key to run: ./hecate.sh: " + echo 1>&2 + ./hecate.sh read -r -p "Do you want to try again (Y/N)? " if [[ "$REPLY" != "y" && "$REPLY" != "Y" ]]; then diff --git a/thanks-for-help.md b/thanks-for-help.md index 68ed2718c..3ee1fb2fe 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -4151,9 +4151,15 @@ provided by the author. once did. The problem is that it expects a certain file name which was `sinon.c`. The code now refers to `prog.c`. -Cody also added the [try.sh](/2014/sinon/try.sh) script which is an improvement -over what was once suggested in that when it's over it will ask you if you wish -to try again, say because of a jam (see the README.md file for details). +Cody also fixed the scripts [glock.sh](/2014/sinon/glock.sh) and +[hecate.sh](/2014/sinon/hecate.sh) which did not work after running either once +as they compile `run.c` and then do `./run | tee run.c` which overwrites it with +output that is not code. + +Cody also added the [try.sh](/2014/sinon/try.sh) script that will first (if perl +is installed) run the demo mode and then after that it will run the above noted +scripts in a loop until the user says they do not want to try again (or they +kill it). This is done this way in case it jams (see README.md for details). ## [2014/skeggs](/2014/skeggs/prog.c) ([README.md](/2014/skeggs/README.md))