Files
ioccc/2014/sinon
Landon Curt Noll 96e0f2b966 move some rules into 1337.mk
A number of rules have been moved from entry `Makefile`s into the
`1337.mk` include file to make it easier for these common rules to be
updated or modified globally (by modifying the `1337.mk` include file).

The entry level `Makefile`s are now similar in form to the
/Makefile.example](https://github.com/ioccc-src/mkiocccentry/blob/master/Makefile.example)
file from the other repo.

The following make rules were moved into the `1337.mk` include file:

- `make indent.c`
- `make install`
- `make diff_orig_prog`
- `make diff_prog_orig`
- `make diff_alt_prog`
- `make diff_prog_alt`

This simplifies the entry level `Makefile`s so that they mostly reflect
the specifics of the particular entry.

Mentioned in FAQ 4.2, that the make diff rules are in the `1337.mk` include file.

Fixed invalid TAB character in `faq.md`.

Removed `make clean` directives that removed `indent.c`.  This file is now
removed via `make indent_clean`, a clean rule that also removes `indent.c`.

Removed `make clobber` directives that removed sandwich,  This file is now
removed via `make indent_clobber`, a clean rule that also removes `sandwich`.

Added `make indent_clean` and `make indent_clobber` rules into the top level
`Makefile` and the year level `YYYY/Makefile`.

Performed `make quick_www` to accomplish the above and to test under macOS.
2024-08-21 23:42:28 -07:00
..
2024-01-28 12:42:07 -08:00
2024-01-28 12:42:07 -08:00
2024-08-21 23:42:28 -07:00
2023-07-06 21:49:38 -07:00

To build:

    make

To use:

    ./hecate.sh

    ./glock.sh

Try:

    ./try.sh

This script will ask you if you wish to try again after each run. Type in any character other than y or Y to exit at this point.

Judges' remarks:

Try to figure out how this entry determines the optimization level with which it had been compiled. Is this an example of undefined behavior or unspecified behavior?

Author's remarks:

Summary

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 output repeatedly until you have won/lost the game. For example:

    cp prog.c run.c
    gcc -O0 run.c -o run && ./run | tee run.c
    gcc -O2 run.c -o run && ./run | tee run.c
    ...

Details

Sinon is played by compiling and running the output repeatedly. Two factors determine what actions are taken:

  • Time since last compilation.
  • Whether compiler optimizations are enabled or not.

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 level:

  • "gcc -O2" or "clang -O2" will fire Hecate II, a powerful rifle that requires longer time to cool off.

  • "gcc -O0" or "clang -O0" will fire Glock 18C, a less powerful pistol that requires less time to cool off.

Because the weapons cool off independently, the best strategy is to alternate between the two weapons. It is fairly easy to win the game with this strategy even with occasional jams.

If your compiler does not have the right optimizations, only Glock 18C would be available. It is still possible to win, but your timing will need to be more precise. This is effectively playing the game on "hard" mode. It is worth trying this mode even if you have the right compilers.

Compatibility

Sinon has been tested and verified to work on these platforms:

  • gcc 4.4.3 on Linux.
  • gcc 4.4.5 on Linux.
  • gcc 4.8.2 on Linux.
  • gcc 4.8.3 on Cygwin/MingW.
  • clang 3.4-1 on Linux.
  • clang 3.4.2 on Cygwin.
  • gcc 4.3.5 on JS/Linux (playable but likely unwinnable, because it takes too long to compile).
  • 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.

Miscellaneous features

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 that there are no files named "run" and "run.c" in current directory (they will be overwritten) and run:

    perl prog.c | bash

File size and CRC32 of prog.c are embedded in line 7.

Process for making Sinon is included in obfuscation.html.

Layout of this code is based on Asada Shino, also known as "Sinon", from Sword Art Online.