Fix and improve 2014/sinon scripts
The try script now runs the demo mode if perl is installed. It also now prompts before running each script (the below noted ones) so that one can control the pace of the output a bit more. The glock.sh and hecate.sh scripts could only be run once successfully because the output of run.c overwrites it (with non code). First one has to do cp -f prog.c run.c which the scripts now do. This was not a problem in the try script because I added that step explicitly (and is now not needed or there).
This commit is contained in:
1 parent
691a901b55
commit
0903d9f3b9
5 files changed
+47
-16
No files matched your search
+12
-10
@@ -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.
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
@@ -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
|
||||
+24
-1
@@ -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
|
||||
|
||||
Reference in new issue
Block a user