Merge pull request #1696 from xexyl/giles2018
This commit is contained in:
11 files changed
+87
-159
No files matched your search
+11
-2
@@ -59,10 +59,19 @@ CSTD= -std=gnu11
|
||||
#
|
||||
ARCH=
|
||||
|
||||
# Variables to help simplify defining the defines
|
||||
#
|
||||
FIRE= XK_BackSpace:XK_Tab
|
||||
FORWARD= XK_Up:XK_w
|
||||
BACKWARD= XK_Down:XK_s
|
||||
LEFT= XK_Left:XK_a
|
||||
RIGHT= XK_Right:XK_d
|
||||
WIDTH= 512
|
||||
HEIGHT= 288
|
||||
# Defines that are needed to compile
|
||||
#
|
||||
CDEFINE= -DA=XK_Up:XK_w -DB=XK_Left:XK_a -DC=XK_Right:XK_d -DD=XK_Down:XK_s \
|
||||
-DE=XK_BackSpace:XK_Tab "-DQ=XFillRectangle(W,X,Y,"
|
||||
CDEFINE= -DA=${FORWARD} -DB=${LEFT} -DC=${RIGHT} -DD=${BACKWARD} \
|
||||
-DE=${FIRE} "-DQ=XFillRectangle(W,X,Y," -DM=${WIDTH} -DN=${HEIGHT}
|
||||
|
||||
# Include files that are needed to compile
|
||||
#
|
||||
|
||||
+22
-20
@@ -24,40 +24,42 @@ The first alt version, [toledo.alt.c](toledo.alt.c), allows you to reconfigure
|
||||
the controls and the dimensions more easily.
|
||||
|
||||
The second version, [toledo.alt2.c](toledo.alt2.c), should work for Windows but
|
||||
does not allow you to reconfigure the keys or dimensions.
|
||||
does not allow you to reconfigure the keys or dimensions. This is because it
|
||||
cannot be tested by us.
|
||||
|
||||
|
||||
### Alternate build:
|
||||
|
||||
For the one that lets you reconfigure the keys you will want to look at the
|
||||
included header file, [keysym.h](keysym.h), to find the correct macros. Once you
|
||||
have the right names you can define the macros `A`, `B`, `C`, `D` and/or `E`. It
|
||||
will use the default for any you do not specify. For instance, to swap what `A`
|
||||
and `B` are (see below for defaults of all keys):
|
||||
have the right names you can define the macros `FIRE`, `FORWARD`, `BACKWARD`,
|
||||
`LEFT`, `RIGHT`, `WIDTH` and `HEIGHT`. Here are the defaults:
|
||||
|
||||
```
|
||||
FIRE= XK_BackSpace:XK_Tab
|
||||
FORWARD= XK_Up:XK_w
|
||||
BACKWARD= XK_Down:XK_s
|
||||
LEFT= XK_Left:XK_a
|
||||
RIGHT= XK_Right:XK_d
|
||||
WIDTH= 512
|
||||
HEIGHT= 288
|
||||
```
|
||||
|
||||
but you can change them about however you like, even with other keys. For
|
||||
instance to swap `LEFT` and `RIGHT`:
|
||||
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DA=XK_Left:XK_a -DB=XK_Up:XK_w" alt
|
||||
make clobber LEFT=XK_Right:XK_d RIGHT=XK_Left:XK_a alt
|
||||
```
|
||||
|
||||
but you can specify something completely else and you can pick and choose which
|
||||
controls you wish to redefine. You might also wish to change the dimensions of
|
||||
the game, `M` and `N` which have an arbitrarily selected lower limit as well as
|
||||
the default values.
|
||||
the game, `WIDTH` and `HEIGHT` which have an arbitrarily selected lower limit as
|
||||
well as the default values.
|
||||
|
||||
Here are the defaults:
|
||||
|
||||
```c
|
||||
#define A XK_Up:XK_w
|
||||
#define B XK_Left:XK_a
|
||||
#define C XK_Right:XK_d
|
||||
#define D XK_Down:XK_s
|
||||
#define E XK_BackSpace:XK_Tab
|
||||
#define M 512
|
||||
#define N 288
|
||||
```
|
||||
|
||||
Observe that each of the controls are a pair in the form of `player2:player1`.
|
||||
Observe that each of the controls are a pair in the form of `player2:player1`
|
||||
(yes, player 2 comes first!).
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
Executable → Regular
File mode changed.
+11
-6
@@ -57,7 +57,7 @@ ARCH=
|
||||
|
||||
# Defines that are needed to compile
|
||||
#
|
||||
CDEFINE= -DG="$G" -DP="$P" -DV="$V" -DS=12321 -DA=10
|
||||
CDEFINE= -DG="${GRAVITY}" -DP="${PRESSURE}" -DV="${VISCOSITY}"
|
||||
|
||||
# Include files that are needed to compile
|
||||
#
|
||||
@@ -120,15 +120,15 @@ ALT_TARGET= ${PROG}.alt ${PROG}_color.alt
|
||||
|
||||
# The factor of gravity
|
||||
#
|
||||
G=1
|
||||
GRAVITY=1
|
||||
|
||||
# The factor of pressure
|
||||
#
|
||||
P=4
|
||||
PRESSURE=4
|
||||
|
||||
# The factor of viscosity
|
||||
#
|
||||
V=8
|
||||
VISCOSITY=8
|
||||
|
||||
|
||||
#################
|
||||
@@ -154,13 +154,18 @@ ${PROG}_color: ${PROG}_color.c
|
||||
alt: data ${ALT_TARGET}
|
||||
@${TRUE}
|
||||
|
||||
# Variables that control the alarm(3) timer and how much to sleep for alt code
|
||||
#
|
||||
TIMER= 10
|
||||
SLEEP= 12321
|
||||
|
||||
${PROG}.alt: ${PROG}.alt.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||
${CC} ${CFLAGS} -DS=${SLEEP} -DA=${TIMER} $< -o $@ ${LDFLAGS}
|
||||
|
||||
# this does NOT correspond to endoh1.alt2.c but rather endoh1.alt.c: it is NOT
|
||||
# deobfuscated.
|
||||
${PROG}_color.alt: ${PROG}_color.alt.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||
${CC} ${CFLAGS} -DS=${SLEEP} -DA=${TIMER} $< -o $@ ${LDFLAGS}
|
||||
|
||||
alt2: ${PROG}.alt2
|
||||
@${TRUE}
|
||||
|
||||
@@ -59,7 +59,7 @@ for fun. That is controlled by the variable `A`; 0 disables it.
|
||||
If you wish to change the speed you should do:
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DS=N" alt
|
||||
make clobber SLEEP=N alt
|
||||
```
|
||||
|
||||
where `N` is number or the letter `I`.
|
||||
@@ -75,7 +75,7 @@ you wish to change the viscosity and pressure factors but leave the other macros
|
||||
alone:
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DV=X -DP=Y" alt
|
||||
make clobber VISCOSITY=X PRESSURE=Y alt
|
||||
```
|
||||
|
||||
where `X` and `Y` are numbers or the letter `I` and which are, respectively, the
|
||||
@@ -88,7 +88,7 @@ it from being done.
|
||||
If you want to disable the alarm time, set `A` to 0:
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DA=0" alt
|
||||
make clobber TIMER=0 alt
|
||||
```
|
||||
|
||||
It cannot be < 0 or > 60 (arbitrarily selected).
|
||||
@@ -97,7 +97,7 @@ Try slowing down the display by increasing the sleep time from `12321` to
|
||||
`50000`:
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DS=50000" alt
|
||||
make clobber SLEEP=50000 alt
|
||||
```
|
||||
|
||||
Now try using both `endoh1.alt` and `endoh1_color.alt` as you would `endoh1` above.
|
||||
@@ -106,7 +106,7 @@ Also try speeding up the display by decreasing the sleep time from `12321` to
|
||||
`9999`:
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DS=9999" alt2
|
||||
make clobber SLEEP=9999 alt2
|
||||
```
|
||||
|
||||
WARNING: again, be careful with too low a value if you're sensitive to flashing
|
||||
@@ -119,13 +119,13 @@ instance:
|
||||
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DG=5 -DP=5 -DV=5" alt
|
||||
make clobber GRAVITY=5 PRESSURE=5 VISCOSITY=5 alt
|
||||
```
|
||||
|
||||
You might try even:
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE="-DG=I" alt
|
||||
make clobber GRAVITY=I alt
|
||||
```
|
||||
|
||||
See the author's remarks for details on these macros.
|
||||
|
||||
@@ -13,11 +13,11 @@ fi
|
||||
|
||||
# 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" CDEFINE="-DA=10 -DG=I -DS=39000" alt >/dev/null || exit 1
|
||||
make clobber CC="$CC" TIMER=10 GRAVITY=I SLEEP=39000 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" CDEFINE="-DA=10 -DS=39000" alt >/dev/null || exit 1
|
||||
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
|
||||
# clear screen before continuing
|
||||
|
||||
@@ -57,7 +57,7 @@ ARCH=
|
||||
|
||||
# Defines that are needed to compile
|
||||
#
|
||||
CDEFINE= -DZ=15000
|
||||
CDEFINE=
|
||||
|
||||
# Include files that are needed to compile
|
||||
#
|
||||
@@ -139,13 +139,18 @@ all: data ${TARGET}
|
||||
${PROG}: ${PROG}.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||
|
||||
${PROG}.alt: ${PROG}.alt.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||
# alternative executable
|
||||
#
|
||||
alt: data ${ALT_TARGET}
|
||||
@${TRUE}
|
||||
|
||||
# Variable to control how to redefine sleep time in alt code
|
||||
#
|
||||
SLEEP= 15000
|
||||
|
||||
${PROG}.alt: ${PROG}.alt.c
|
||||
${CC} ${CFLAGS} -DZ=${SLEEP} $< -o $@ ${LDFLAGS}
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
|
||||
@@ -40,7 +40,7 @@ compile time. If you wish to speed it up by 100% you can instead do:
|
||||
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE=-DZ=7500 alt
|
||||
make clobber SLEEP=7500 alt
|
||||
```
|
||||
|
||||
and then try `birken.alt` as above.
|
||||
|
||||
+8
-84
@@ -1,82 +1,13 @@
|
||||
## To build:
|
||||
|
||||
This entry requires SDL2 to be installed.
|
||||
This entry requires SDL2 to be installed. See [FAQ 3.8: How do I compile an
|
||||
IOCCC winner that requires SDL1 or SDL2?](/faq.md#SDL) if you don't have it
|
||||
installed and don't know how to do so.
|
||||
|
||||
```sh
|
||||
make
|
||||
```
|
||||
|
||||
### To install SDL and SDL2:
|
||||
|
||||
#### macOS users (Homebrew)
|
||||
|
||||
If you have not already done so, install [Homebrew](https://brew.sh).
|
||||
|
||||
Then to install SDL and SDL2, execute the following command:
|
||||
|
||||
```sh
|
||||
brew install sdl2 sdl12-compat
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
```
|
||||
|
||||
#### macOS users (MacPorts)
|
||||
|
||||
Install [MacPorts](https://www.macports.org/install.php).
|
||||
|
||||
Then to install SDL and SDL2:
|
||||
|
||||
```sh
|
||||
sudo port install libsdl libsdl2
|
||||
```
|
||||
|
||||
#### Red Hat Linux users:
|
||||
|
||||
To install SDL and SDL2, execute the following command as root:
|
||||
|
||||
```sh
|
||||
dnf install SDL2 SDL2-devel sdl12-compat sdl12-compat-devel
|
||||
```
|
||||
|
||||
It was once possibly necessary to use `make` like:
|
||||
|
||||
```sh
|
||||
make ... SDL2_INCLUDE_ROOT=/usr
|
||||
```
|
||||
|
||||
or set the following environment variable:
|
||||
|
||||
```sh
|
||||
export SDL2_INCLUDE_ROOT=/usr
|
||||
```
|
||||
|
||||
but this is most likely unneeded as we use `sdl-config` and `sdl2-config` in the
|
||||
Makefiles.
|
||||
|
||||
#### Debian users
|
||||
|
||||
To install SDL and SDL2, execute the following command as root:
|
||||
|
||||
```sh
|
||||
apt install libsdl1.2debian libsdl1.2-dev libsdl2-dev
|
||||
```
|
||||
|
||||
It was once possibly necessary to use `make` like:
|
||||
|
||||
```sh
|
||||
make ... SDL2_INCLUDE_ROOT=/usr
|
||||
```
|
||||
|
||||
or set the following environment variable:
|
||||
|
||||
```sh
|
||||
export SDL2_INCLUDE_ROOT=/usr
|
||||
```
|
||||
|
||||
but this is most likely unneeded as we use `sdl-config` and `sdl2-config` in the
|
||||
Makefiles.
|
||||
|
||||
See also the judges' remarks below.
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
@@ -97,20 +28,12 @@ See also the judges' remarks below.
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
Can you explain the behavior of the program when ioccc.txt is given to it as input?
|
||||
Can you explain the behavior of the program when [ioccc.txt](ioccc.txt) is given
|
||||
to it as input?
|
||||
|
||||
How would the description of the state machine look like when translated from
|
||||
Polynomish to English?
|
||||
|
||||
You may have to install libsdl2-dev on your system to compile and use this code:
|
||||
|
||||
```sh
|
||||
sudo dnf install SDL2 SDL2-devel # Linux
|
||||
sudo apt install libsdl2-dev # Debian
|
||||
brew install sdl2 # macOS via Homebrew
|
||||
sudo port install libsdl2 # macOS via MacPorts
|
||||
```
|
||||
|
||||
|
||||
## Author's remarks:
|
||||
|
||||
@@ -121,7 +44,8 @@ It uses SDL to draw the interface.
|
||||
|
||||
The code makes the following assumptions about the underlying system:
|
||||
|
||||
* SDL2 is installed from [https://libsdl.org](https://libsdl.org).
|
||||
* SDL2 is installed from [https://libsdl.org](https://libsdl.org) or your
|
||||
package manager.
|
||||
* `double` is an IEEE 754 floating-point type and `sizeof(double)==8`.
|
||||
* The compiler supports the C99 standard.
|
||||
|
||||
@@ -129,7 +53,7 @@ In order to simulate the motion of the sand, a cellular automaton is used. The
|
||||
state transition table is not stored directly. Instead, the program stores the
|
||||
coefficients of a polynomial that map each state to the correct one. These
|
||||
coefficients are stored as raw hexadecimal in the `V[]` array, and they are
|
||||
reinterpreted as doubles when used. This allows more numeric precision in fewer
|
||||
reinterpreted as `double`s when used. This allows more numeric precision in fewer
|
||||
characters (base 16 > base 10), and makes the purpose of the array less clear.
|
||||
|
||||
The code is laid out graphically as a bucket pouring sand, and it is far easier
|
||||
|
||||
+16
-8
@@ -3315,6 +3315,9 @@ lets one reconfigure the controls and also the size of the game and another
|
||||
version that should work in Windows, based on the author's remarks and support
|
||||
file, `layer.c`.
|
||||
|
||||
The Makefile was also modified by Cody to make it simpler to redefine the
|
||||
controls, width and height.
|
||||
|
||||
|
||||
## <a name="2011_vik"></a>[2011/vik](/2011/vik/vik.c) ([README.md](/2011/vik/README.md]))
|
||||
|
||||
@@ -3359,13 +3362,16 @@ Cody also added two [alt versions](/2012/endoh1/README.md#alternate-code) that
|
||||
let one control how fast the fluid moves (how long to sleep in between writes)
|
||||
and also the gravity factor, the pressure factor and the viscosity factor as
|
||||
well as an alarm that lets one run it in a loop without having to hit
|
||||
ctrl-c/intr in between (the alarm can be disabled, however). The two different
|
||||
versions is because there are two versions: the original and the colour version
|
||||
added by the author, [Yusuke](#yusuke), at the request of the judges.
|
||||
ctrl-c/intr in between (the alarm can be disabled, however). The Makefile allows
|
||||
one to easily do this with variable names rather than redefining `CDEFINE`.
|
||||
|
||||
Cody also added the [try.alt.sh](/2012/endoh1/try.alt.sh) script compiles the alt
|
||||
code in two ways, one with setting the gravity factor to `I` and another with
|
||||
the default, and which is run on the source file and each of the text files
|
||||
The two different alt versions is because there are two versions: the original
|
||||
and the colour version added by the author, [Yusuke](#yusuke), at the request of
|
||||
the judges.
|
||||
|
||||
Cody also added the [try.alt.sh](/2012/endoh1/try.alt.sh) script that compiles
|
||||
the alt code in two ways, one with setting the gravity factor to `I` and another
|
||||
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 :-)
|
||||
|
||||
@@ -3491,11 +3497,13 @@ pairs though that should be obvious) and also some that are correct including
|
||||
system("reset");` (via redefining `exit(3)` so that the column ending would be
|
||||
the same) so that as long as it runs to completion the terminal will be sane and
|
||||
the cursor will be visible. Using `atexit(3)` will not work if the program is
|
||||
killed and signals are ugly so this was not done.
|
||||
killed, signals are ugly and these would be messing with the entry too much so
|
||||
these were not done.
|
||||
|
||||
Cody also added the alt version that lets one control how fast the painting is
|
||||
done, based on the author's recommendations, except that Cody made it
|
||||
configurable at compile time.
|
||||
configurable at compile time. The Makefile was modified in such a way as to make
|
||||
it very easy to redefine them at compile time.
|
||||
|
||||
Cody also added the [try.sh](/2013/birken/try.sh) script for the entry and the
|
||||
[try.alt.sh](/2013/birken/try.alt.sh) script for the alt code.
|
||||
|
||||
+1
-26
@@ -1,5 +1,5 @@
|
||||
# A todo list of known things to check and/or do
|
||||
*Last updated: Fri 08 Dec 2023 12:46:49 UTC*
|
||||
*Last updated: Tue 12 Dec 2023 14:00:37 UTC*
|
||||
|
||||
This document is primarily for [Cody Boone
|
||||
Ferguson](/winners.html#Cody_Boone_Ferguson) as he (that is I :-) ) wanted a way
|
||||
@@ -169,28 +169,3 @@ the rest of the entries are done, assuming that it's possible.
|
||||
- Although I will have to do this when another issue is opened up I am aware of
|
||||
some issues in 2020/ferguson1/.winner.json. I do not want to forget this,
|
||||
however, so I am noting it here.
|
||||
|
||||
- Finish going through entries (Makefile and README.md files) that have the
|
||||
ability to redefine macros but only in an awkward way like `make clobber
|
||||
CDEFINE="-D.."`. To find entries that were done by me: `git grep -c 'CDEFINE'
|
||||
'*README.md'` but the `2000/thadgavin` is already done. The reference to
|
||||
`CDEFINE` might want to be removed but that can be decided when this is done
|
||||
too. The entries done as of 7 Dec 2023 are:
|
||||
- 2006/sloane
|
||||
- 2006/monge
|
||||
- 2004/jdalbec
|
||||
- 2004/gavare
|
||||
- 2001/kev
|
||||
- 2000/thadgavin
|
||||
- 1998/schweikh3
|
||||
- 1998/banks
|
||||
- 1994/dodsond2
|
||||
- 1993/rince
|
||||
- 1993/plummer
|
||||
- 1993/cmills
|
||||
- 1992/kivinen
|
||||
- 1991/rince
|
||||
- 1985/shapiro
|
||||
- 1985/lycklama
|
||||
... and a couple or few involved updating the thanks file as it helps with
|
||||
the entry itself. Ones not yet done might also have this need.
|
||||
Reference in new issue
Block a user