More README.md files updated in 2015/
Fix formatting. Spelling / typo errors fixed. Possibly other changes as well. I still have to check 2015/muth and 2015/schweikhardt and 2015/yang.
This commit is contained in:
1 parent
a23d24f803
commit
35fb326b37
7 files changed
+126
-61
No files matched your search
+59
-25
@@ -1,11 +1,11 @@
|
||||
# Most Diffused Reaction
|
||||
|
||||
Someone Anonymous
|
||||
Twitter: @hirekoke
|
||||
Someone Anonymous
|
||||
Twitter: @hirekoke
|
||||
|
||||
Yusuke Endoh
|
||||
<https://github.com/mame/>
|
||||
Twitter: @mametter
|
||||
Yusuke Endoh
|
||||
<https://github.com/mame/>
|
||||
Twitter: @mametter
|
||||
|
||||
# To build:
|
||||
|
||||
@@ -21,6 +21,11 @@ make
|
||||
|
||||
Connect to port http://localhost:10333 with your browser.
|
||||
|
||||
The author said he had no recent version of macOS to test to see if this works
|
||||
but in 2023 [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) did this
|
||||
and reported that it works well. He also said he really loved it! Thank you
|
||||
Cody!
|
||||
|
||||
### Try:
|
||||
|
||||
```sh
|
||||
@@ -55,40 +60,55 @@ cc -O3 -std=c99 \
|
||||
```
|
||||
|
||||
Then, run it under `tcpserver` command in
|
||||
[ucspi-tcp](http://cr.yp.to/ucspi-tcp.html) package, which was created by Daniel
|
||||
J. Bernstein, IOCCC 1989 "Best of Show" winner.
|
||||
[ucspi-tcp](http://cr.yp.to/ucspi-tcp.html) package, which was created by
|
||||
[Daniel J. Bernstein](/winners.html#Daniel_J._Bernstein), [IOCCC 1991 "Best of
|
||||
Show"](../../1991/brnstnd/brnstnd.c) ([README.md](../../1991/brnstnd/README.md)).
|
||||
|
||||
$ tcpserver -v 127.0.0.1 10333 ./prog ioccc.txt
|
||||
|
||||
Finally, open `http://127.0.0.1:10333/` by a modern browser supporting HTML5. You can use the mouse cursor to place drops into the Petri dish interactively.
|
||||
Finally, open `http://127.0.0.1:10333/` by a modern browser supporting HTML5.
|
||||
You can use the mouse cursor to place drops into the Petri dish interactively.
|
||||
|
||||
|
||||
### Description
|
||||
|
||||
This is a simulator of *reaction-diffusion systems*.
|
||||
|
||||
Reaction-diffusion systems, proposed by Alan Turing in [1], are mathematical models in which two chemical substances are transformed into each other (*local chemical reactions*) and spread out (*diffusion*). Their interactions sometimes form non-trivial patterns, such as spots, spiral, dappling, and labyrinths.
|
||||
Reaction-diffusion systems, proposed by Alan Turing in [1], are mathematical
|
||||
models in which two chemical substances are transformed into each other (*local
|
||||
chemical reactions*) and spread out (*diffusion*). Their interactions sometimes
|
||||
form non-trivial patterns, such as spots, spiral, dappling, and labyrinths.
|
||||
|
||||
The systems are generally formulated as follows:
|
||||
|
||||
du/dt = F(u, v) + Du * laplacian(u)
|
||||
dv/dt = G(u, v) + Dv * laplacian(v)
|
||||
|
||||
The functions `F(u, v)` and `G(u, v)` represent reactions of each substance, and the parameters `Du` and `Dv` are diffusion coefficients. By changing the functions and parameters, you can see a wide range of behaviors.
|
||||
The functions `F(u, v)` and `G(u, v)` represent reactions of each substance, and
|
||||
the parameters `Du` and `Dv` are diffusion coefficients. By changing the
|
||||
functions and parameters, you can see a wide range of behaviors.
|
||||
|
||||
See [the Wikipedia article of "Reaction-diffusion system"](https://en.wikipedia.org/wiki/Reaction%E2%80%93diffusion_system) in detail.
|
||||
See [the Wikipedia article of "Reaction-diffusion
|
||||
system"](https://en.wikipedia.org/wiki/Reaction%E2%80%93diffusion_system) in
|
||||
detail.
|
||||
|
||||
This program simulates the systems. The field consists of 128 x 128 cells. Each cell includes infomration of an amount of the two substances, and interacts with neighbor cells (in terms of von Neumann neighborhood) in each frame.
|
||||
This program simulates the systems. The field consists of 128 x 128 cells.
|
||||
Each cell includes information of an amount of the two substances, and interacts
|
||||
with neighbor cells (in terms of von Neumann neighborhood) in each frame.
|
||||
|
||||
|
||||
### Configuration
|
||||
|
||||
You can change the model, initial pattern, simulation speed, and color via macro definition.
|
||||
You can change the model, initial pattern, simulation speed, and color via macro
|
||||
definition.
|
||||
|
||||
|
||||
#### Model: `-Delta_u=<expression> -Delta_v=<expression>`
|
||||
|
||||
The definitions represent the equations of reaction-diffusion system. For example, the following is [the Gray-Scott model](http://groups.csail.mit.edu/mac/projects/amorphous/GrayScott/) in TeX notation.
|
||||
The definitions represent the equations of reaction-diffusion system. For
|
||||
example, the following is [the Gray-Scott
|
||||
model](http://groups.csail.mit.edu/mac/projects/amorphous/GrayScott/) in TeX
|
||||
notation.
|
||||
|
||||
\frac{\partial u}{\partial t} = D_u \Delta u - u v^2 + F (1 - u)
|
||||
\frac{\partial v}{\partial t} = D_v \Delta v + u v^2 - v (F + K)
|
||||
@@ -102,9 +122,13 @@ You can specify this model as follows:
|
||||
|
||||
#### Initial pattern: `-DUV_BACKGROUND=<u0>,<v0> -DUV_DROP=<u1>,<v1>`
|
||||
|
||||
The definitions specifies the initial amount of the two substances u and v. All cells have `(u0, v0)` by default.
|
||||
The definitions specifies the initial amount of the two substances u and v. All
|
||||
cells have `(u0, v0)` by default.
|
||||
|
||||
You can specify a pattern file when the executable is invoked (not compile-time). The file should include a sequence of points, see `ioccc.txt`, `center.txt`, or `line.txt` as examples. Each amount in cells near to the point included in the file, will be added by `(u1, v1)`.
|
||||
You can specify a pattern file when the executable is invoked (not
|
||||
compile-time). The file should include a sequence of points, see `ioccc.txt`,
|
||||
`center.txt`, or `line.txt` as examples. Each amount in cells near to the point
|
||||
included in the file, will be added by `(u1, v1)`.
|
||||
|
||||
#### Simulation speed: `-DTIMESTEP=ts -DSPEED=spd`
|
||||
|
||||
@@ -121,7 +145,8 @@ This specifies a color used for rendering.
|
||||
|
||||
### Examples
|
||||
|
||||
Some interesting parameters are included in `Makefile`. Do one of the following command and open `http://127.0.0.1:10333`.
|
||||
Some interesting parameters are included in `Makefile`. Do one of the following
|
||||
command and open `http://127.0.0.1:10333`.
|
||||
|
||||
$ make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 ioccc.txt
|
||||
$ make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 center.txt
|
||||
@@ -133,27 +158,32 @@ Some interesting parameters are included in `Makefile`. Do one of the following
|
||||
$ make fitzhugh-nagumo-2 && tcpserver -v 127.0.0.1 10333 ./fitzhugh-nagumo-2 ioccc.txt
|
||||
$ make oregonator && tcpserver -v 127.0.0.1 10333 ./oregonator ioccc.txt
|
||||
|
||||
These examples are created by drawing (and modifying) the pattern files of [Ready](https://github.com/GollyGang/ready), a cross-platform implementation of various reaction-diffusion systems [2].
|
||||
These examples are created by drawing (and modifying) the pattern files of
|
||||
[Ready](https://github.com/GollyGang/ready), a cross-platform implementation of
|
||||
various reaction-diffusion systems [2].
|
||||
|
||||
### Compatibility
|
||||
|
||||
#### C part
|
||||
|
||||
This program compiles clean with no warnings under `-std=c99 -Wall -Wextra -pedantic`. Since it uses `long long` for 64bit integers, C99 is required.
|
||||
This program compiles clean with no warnings under `-std=c99 -Wall -Wextra
|
||||
-pedantic`. Since it uses `long long` for 64bit integers, C99 is required.
|
||||
|
||||
#### Browser part
|
||||
|
||||
You must use a modern browser that supports the latest specification of WebSocket [3]. All the following browsers worked for me:
|
||||
You must use a modern browser that supports the latest specification of
|
||||
WebSocket [3]. All the following browsers worked for me:
|
||||
|
||||
* Google Chrome 45
|
||||
* Mozilla Firefox 39
|
||||
* Microsoft Internet Explorer 11 (works but sluggish)
|
||||
|
||||
I think Safari 6 will work but I haven't tested. (I have no recent os x.)
|
||||
I think Safari 6 will work but I haven't tested. (I have no recent macOS.)
|
||||
|
||||
#### tcpserver alternatives
|
||||
|
||||
I think you may use `inetd` and `xinetd` instead of `tcpserver`. Here is an example of inetd configuration.
|
||||
I think you may use `inetd` and `xinetd` instead of `tcpserver`. Here is an
|
||||
example of inetd configuration.
|
||||
|
||||
10333 stream tcp nowait nobody /path/to/prog /path/to/prog /path/to/initial-pattern.txt
|
||||
|
||||
@@ -161,10 +191,14 @@ But note that I didn't test well.
|
||||
|
||||
### Internal
|
||||
|
||||
1. The C program accepts HTTP connection from the browser, and sends a HTML document.
|
||||
1. The C program accepts HTTP connection from the browser, and sends a HTML
|
||||
document.
|
||||
2. The browser tries to upgrade the connection to WebSocket.
|
||||
3. The C program accepts WebSocket upgrade. This negotiation process requires SHA1 hash [4] and Base64 encoding [5]. The C program calculates them without the aid of any external libraries.
|
||||
4. The C program simulates the reaction-diffusion system, and then send the field data to the browser on each frame.
|
||||
3. The C program accepts WebSocket upgrade. This negotiation process requires
|
||||
SHA1 hash [4] and Base64 encoding [5]. The C program calculates them without
|
||||
the aid of any external libraries.
|
||||
4. The C program simulates the reaction-diffusion system, and then send the
|
||||
field data to the browser on each frame.
|
||||
4. The browser receives and renders the field data onto the HTML5 canvas.
|
||||
|
||||
|
||||
|
||||
@@ -57,7 +57,8 @@ If you are still puzzled, look at prog.c with your favorite text editor.
|
||||
|
||||
You will do a double take.
|
||||
|
||||
Hint 1: Do `less prog.c`. You will see an **emphasized** string if your terminal supports bold.
|
||||
Hint 1: Do `less prog.c`. You will see an **emphasized** string if your
|
||||
terminal supports bold.
|
||||
|
||||
Hint 2: Do `wc -c prog.c`. This is very long one-liner.
|
||||
|
||||
|
||||
+11
-6
@@ -1,8 +1,8 @@
|
||||
# Best One-liner
|
||||
|
||||
Yusuke Endoh
|
||||
<https://github.com/mame/>
|
||||
Twitter: @mametter
|
||||
Yusuke Endoh
|
||||
<https://github.com/mame/>
|
||||
Twitter: @mametter
|
||||
|
||||
# To build:
|
||||
|
||||
@@ -31,7 +31,9 @@ make
|
||||
### Alternate code
|
||||
|
||||
An alternate version of this entry, `prog.alt.c`, is provided.
|
||||
This alternate code does not contain improvements suggested by Gil Dogon.
|
||||
This alternate code does not contain improvements suggested by [Gil
|
||||
Dogon](/winners.html#Gil_Dogon); it is
|
||||
the author's original entry.
|
||||
|
||||
To compile this alternate version:
|
||||
|
||||
@@ -61,9 +63,12 @@ Visual factorization 1-liner. Try:
|
||||
./prog @ @ @ @ @ @ @ @
|
||||
./prog @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
|
||||
|
||||
Inspired by [Animated Factorization Diagrams](http://www.datapointed.net/visualizations/math/factorization/animated-diagrams/).
|
||||
Inspired by [Animated Factorization
|
||||
Diagrams](http://www.datapointed.net/visualizations/math/factorization/animated-diagrams/).
|
||||
|
||||
EDIT: `prog.alt.c` is the original version that I submitted. Gil Dogon kindly improved it during the review. Thank you!
|
||||
`prog.alt.c` is the original version that I submitted. [Gil
|
||||
Dogon](/winners.html#Gil_Dogon) kindly improved it during the review. Thank
|
||||
you!
|
||||
|
||||
## Copyright:
|
||||
|
||||
|
||||
+22
-9
@@ -53,7 +53,8 @@ This looks like a normal C program.
|
||||
|
||||
Almost everything is a double.
|
||||
|
||||
There are tell-tale signs like `pow(2,(?/12))` and `exp(-?*?)` (names redacted). You can also find a bunch of cosines and polynomial evaluations.
|
||||
There are tell-tale signs like `pow(2,(?/12))` and `exp(-?*?)` (names redacted).
|
||||
You can also find a bunch of cosines and polynomial evaluations.
|
||||
|
||||
It looks like a ????? ???????????, right?
|
||||
|
||||
@@ -61,29 +62,41 @@ Run and find out.
|
||||
|
||||
### Why obfuscated
|
||||
|
||||
Some poor scripting folks only have access to doubles (Jav?script, L?a, BA?IC, etc.).
|
||||
Some poor scripting folks only have access to doubles (Jav?script, L?a, BA?IC,
|
||||
etc.).
|
||||
|
||||
As a C programmer, I feel obliged to show a gesture of sympathy, to experience their pain and provide an answer.
|
||||
As a C programmer, I feel obliged to show a gesture of sympathy, to experience
|
||||
their pain and provide an answer.
|
||||
|
||||
Except when absolutely necessary (`printf`, `int main()`, array indexing), there isn't a single integer. Even `getchar()` and `EOF` are immediately converted.
|
||||
Except when absolutely necessary (`printf`, `int main()`, array indexing), there
|
||||
isn't a single integer. Even `getchar()` and `EOF` are immediately converted.
|
||||
|
||||
Since `bool` counts as an integer type too, there is no boolean either. No comparison, no `if`, no `?:`, no `||` `&&`. Everything is done in a single loop that terminates on printf. Straight up arithmetic.
|
||||
Since `bool` counts as an integer type too, there is no boolean either. No
|
||||
comparison, no `if`, no `?:`, no `||` `&&`. Everything is done in a single loop
|
||||
that terminates on printf. Straight up arithmetic.
|
||||
|
||||
`floor` and `ceil` are technically double-to-double functions, but they feel like cheating. Yes `cos`, no `floor`.
|
||||
`floor` and `ceil` are technically double-to-double functions, but they feel
|
||||
like cheating. Yes `cos`, no `floor`.
|
||||
|
||||
### Limitations
|
||||
|
||||
Hard requirements:
|
||||
|
||||
* The platform must implement the `double` type as IEEE754-compliant 64-bit floating point numbers. The 80-bit intermediate format used by x87 is considered as an violation of this. The code should print an error message on such platforms.
|
||||
* The platform must implement the `double` type as IEEE754-compliant 64-bit
|
||||
floating point numbers. The 80-bit intermediate format used by x87 is
|
||||
considered as an violation of this. The code should print an error message on
|
||||
such platforms.
|
||||
|
||||
* The program must start with the CPU / FPU in round-to-nearest mode.
|
||||
|
||||
Soft requirements:
|
||||
|
||||
* The compiler must respect `volatile`. The code is formatted to warn about that, though.
|
||||
* The compiler must respect `volatile`. The code is formatted to warn about
|
||||
that, though.
|
||||
|
||||
* The printed result is only correct on little-endian machines. The program takes care to warn about this issue after printing an incorrect big-endian result. Error messages become garbled, though.
|
||||
* The printed result is only correct on little-endian machines. The program
|
||||
takes care to warn about this issue after printing an incorrect big-endian
|
||||
result. Error messages become garbled, though.
|
||||
|
||||
Tested platforms:
|
||||
|
||||
|
||||
+18
-7
@@ -1,9 +1,9 @@
|
||||
# Most Different
|
||||
|
||||
Anthony Howe <achowe@snert.com>
|
||||
Montreal, Quebec, Canada
|
||||
<http://www.snert.com/>
|
||||
Twitter: @SirWumpus
|
||||
Anthony Howe <achowe@snert.com>
|
||||
Montreal, Quebec, Canada
|
||||
<http://www.snert.com/>
|
||||
Twitter: @SirWumpus
|
||||
|
||||
# To build:
|
||||
|
||||
@@ -94,15 +94,26 @@ NOTE: Unlike the original entry source, prog.alt.c, prog.c uses a
|
||||
|
||||
### Description
|
||||
|
||||
This is a functioning micro diff tool using an [O(NP) algorithm][Wu+89], compared to the older [O(ND) difference algorithm][Mye86] used by some versions of diff. Its output is based on the default diff(1) output described by POSIX and [The Open Group Base Specifications][SUSV7]. The output is suitable for use with patch(1).
|
||||
This is a functioning micro diff tool using an [O(NP) algorithm][Wu+89],
|
||||
compared to the older [O(ND) difference algorithm][Mye86] used by some versions
|
||||
of diff. Its output is based on the default diff(1) output described by POSIX
|
||||
and [The Open Group Base Specifications][SUSV7]. The output is suitable for use
|
||||
with patch(1).
|
||||
|
||||
The -d option simply writes the edit distance between file1 and file2.
|
||||
|
||||
### Observations
|
||||
|
||||
The FNV1a hash is a little slow compared to the trival hash GNU Diff uses. I downloaded a plain text copy of "War And Peace" from Project Gutenberg, used ``makeholes.c`` to make 1000 random changes, then profiled and timed the program verses GNU Diff. The bottle neck appears to be in the file I/O and line hashing with an average +0.05s slower. Using a huge file like "War And Peace" for testing offsets the diff(1) optimised file I/O.
|
||||
The FNV1a hash is a little slow compared to the trivial hash GNU Diff uses. I
|
||||
downloaded a plain text copy of "War And Peace" from Project Gutenberg, used
|
||||
``makeholes.c`` to make 1000 random changes, then profiled and timed the program
|
||||
verses GNU Diff. The bottleneck appears to be in the file I/O and line hashing
|
||||
with an average +0.05s slower. Using a huge file like "War And Peace" for
|
||||
testing offsets the diff(1) optimised file I/O.
|
||||
|
||||
There is no hash collision checking, partly because FNV1a appears to generate very [few collisions][HshCmp] and an assumption that localised collisions within a region of edits are highly unlikely.
|
||||
There is no hash collision checking, partly because FNV1a appears to generate
|
||||
very [few collisions][HshCmp] and an assumption that localised collisions within
|
||||
a region of edits are highly unlikely.
|
||||
|
||||
### Support Files
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# "For the Birds!" Award
|
||||
|
||||
Chris Mills
|
||||
Twitter: @MisterXopher
|
||||
Chris Mills
|
||||
Twitter: @MisterXopher
|
||||
|
||||
# To build:
|
||||
|
||||
@@ -21,7 +21,7 @@ make
|
||||
./prog
|
||||
```
|
||||
|
||||
Pressing the up arrow and the down arrow at the right time.
|
||||
Press the up arrow and the down arrow at the right time.
|
||||
|
||||
## Judges' comments:
|
||||
|
||||
@@ -33,7 +33,8 @@ bit easier for you:
|
||||
make clobber all DW=199999 DW=22 DH=16 DA=50 DI=-150
|
||||
```
|
||||
|
||||
From the makefile:
|
||||
From the Makefile:
|
||||
|
||||
|
||||
# Game parameters
|
||||
#
|
||||
@@ -117,7 +118,7 @@ command line:
|
||||
* `-DF`: Sprite for player when flapping.
|
||||
* `-DG`: Instruction text. Change to your native tongue.
|
||||
|
||||
Feel free to try out physics or playfield options to make the game more
|
||||
Feel free to try out physics or play field options to make the game more
|
||||
interesting. Try setting the player sprites to change the game completely --
|
||||
maybe you can be a fish, or a pig -- the options are limitless! Try using
|
||||
emoji -- you can be a flying beer mug!
|
||||
@@ -139,9 +140,9 @@ make EMOJI=globe
|
||||
```
|
||||
|
||||
for some examples (the full list of options is in the `Makefile`). Don't
|
||||
forget to `make clean` first. If the output doesn't look right, you may need
|
||||
forget to `make clobber` first. If the output doesn't look right, you may need
|
||||
to link with the "wide" version of `ncurses`. On MacOSX 10.11, it should work
|
||||
with the current `-lcurses`; on Linux, you probably need `-lncursesw`.
|
||||
with the current `-lcurses`; on Linux, you might need `-lncursesw`.
|
||||
See the `Makefile` to make this change if you need to. Or buy a Mac.
|
||||
|
||||
You will also need a UTF-8 compatible terminal and an emoji font installed,
|
||||
|
||||
@@ -32,10 +32,10 @@ time ./prog test2.Z | cmp - test2
|
||||
|
||||
## Judges' comments:
|
||||
|
||||
Without ASCII art, the source code of this entry would have been exactly 256 bytes.
|
||||
Compared to [1990/jaw](http://ioccc.org/years.html#1990_jaw), it is very impressive,
|
||||
even taking into account the missing atob functionality. Now we wish for a compress(1)-like compressor
|
||||
using a similar idea.
|
||||
Without ASCII art, the source code of this entry would have been exactly 256
|
||||
bytes. Compared to [1990/jaw](http://ioccc.org/years.html#1990_jaw), it is very
|
||||
impressive, even taking into account the missing atob functionality. Now we wish
|
||||
for a compress(1)-like compressor using a similar idea.
|
||||
|
||||
Why is the sad smiley on line 12 in that particular place?
|
||||
|
||||
@@ -43,7 +43,7 @@ Why is the sad smiley on line 12 in that particular place?
|
||||
|
||||
### The Program
|
||||
|
||||
This program is in implementation of the unix `zcat(1)` command for printing
|
||||
This program is an implementation of the unix `zcat(1)` command for printing
|
||||
compressed files that have been created by the `compress(1)` command.
|
||||
|
||||
The adaptive [LZW](https://en.wikipedia.org/wiki/Lempel–Ziv–Welch) compression
|
||||
@@ -122,7 +122,7 @@ In the event that you don't supply an argument, or that argument doesn't name
|
||||
a readable file, the program will just silently exit. This is a feature.
|
||||
|
||||
The program depends on having a little-endian system. On a big-endian system
|
||||
you will get a wierd big-endian version of `compress`, which might have come to
|
||||
you will get a weird big-endian version of `compress`, which might have come to
|
||||
pass in an alternate universe where the vax on which `compress` was authored
|
||||
had been big-endian. Luckily for us, it wasn't, and neither are most of the
|
||||
systems you might want to compile this for.
|
||||
|
||||
Reference in new issue
Block a user