Fix and add alt code to 2006/night
Add alt code: since I'm a lost :-) vim user and the author provided how to add back support for arrow keys I made this in the alt version. Updated .gitignore for this. Format fix README.md. Fix link. Added link to Yusuke Endoh's analysis of the entry as he offers some fun commentary and especially fun is how to cheat. Perhaps I should not do that but since he provided some other fun comments and since the README.md files are no longer supposed to have spoilers as such why not.
This commit is contained in:
1 parent
69d530e978
commit
ae310f9372
6 files changed
+67
-39
No files matched your search
@@ -1 +1,2 @@
|
|||||||
night
|
night
|
||||||
|
night.alt
|
||||||
+5
-2
@@ -116,8 +116,8 @@ OBJ= ${PROG}.o
|
|||||||
DATA=
|
DATA=
|
||||||
TARGET= ${PROG}
|
TARGET= ${PROG}
|
||||||
#
|
#
|
||||||
ALT_OBJ=
|
ALT_OBJ= ${PROG}.alt.o
|
||||||
ALT_TARGET=
|
ALT_TARGET= ${PROG}.alt
|
||||||
|
|
||||||
|
|
||||||
#################
|
#################
|
||||||
@@ -139,6 +139,9 @@ ${PROG}: ${PROG}.c
|
|||||||
alt: data ${ALT_TARGET}
|
alt: data ${ALT_TARGET}
|
||||||
@${TRUE}
|
@${TRUE}
|
||||||
|
|
||||||
|
${PROG}.alt: ${PROG}.alt.c
|
||||||
|
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||||
|
|
||||||
# data files
|
# data files
|
||||||
#
|
#
|
||||||
data: ${DATA}
|
data: ${DATA}
|
||||||
|
|||||||
+59
-35
@@ -1,11 +1,8 @@
|
|||||||
# Best Abuse of Computation
|
# Best Abuse of Computation
|
||||||
|
|
||||||
Christopher Night
|
Christopher Night
|
||||||
Harvard University
|
US
|
||||||
Department of Astronomy
|
<https://web.archive.org/web/20090415070532/https://www.people.fas.harvard.edu/~night>
|
||||||
Cambrige MA 02238
|
|
||||||
US
|
|
||||||
<http://www.people.fas.harvard.edu/~night/>
|
|
||||||
|
|
||||||
## To build:
|
## To build:
|
||||||
|
|
||||||
@@ -19,18 +16,44 @@ make
|
|||||||
./night
|
./night
|
||||||
```
|
```
|
||||||
|
|
||||||
|
There is an alternate version that supports arrow keys. See the alternate code
|
||||||
|
section below.
|
||||||
|
|
||||||
## Try:
|
## Try:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
echo "Do or do not. There is no try."
|
echo "Do or do not. There is no try."
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Alternate code:
|
||||||
|
|
||||||
|
As [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) is a lost :-) `vim`
|
||||||
|
user he took the author's remarks to add support back for arrow keys. To use
|
||||||
|
compile like:
|
||||||
|
|
||||||
|
|
||||||
|
```sh
|
||||||
|
make alt
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `night.alt` as you would `night` above.
|
||||||
|
|
||||||
|
Thank you Cody!
|
||||||
|
|
||||||
|
|
||||||
## Judges' remarks:
|
## Judges' remarks:
|
||||||
|
|
||||||
You'd never guess, from looking at the code, that there is a
|
You'd never guess, from looking at the code, that there is a [genetic
|
||||||
genetic algorithm involved. Somewhere. But what does it do?
|
algorithm](https://towardsdatascience.com/introduction-to-genetic-algorithms-including-example-code-e396e98d8bf3)
|
||||||
Well, it might take you a while to navigate the results, let
|
involved. Somewhere. But what does it do? Well, it might take you a while to
|
||||||
alone the code.
|
navigate the results, let alone the code.
|
||||||
|
|
||||||
|
### Cheating
|
||||||
|
|
||||||
|
There is a nice way to cheat. If you don't want to figure it out you can look at
|
||||||
|
[Yusuke Endoh](/winners.html#Yusuke_Endoh)'s analysis of this entry at
|
||||||
|
(translation from Japanese so it's not perfect)
|
||||||
|
<https://mame-github-io.translate.goog/ioccc-ja-spoilers/2006/night.html?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-US&_x_tr_pto=wapp>.
|
||||||
|
|
||||||
## Author's remarks:
|
## Author's remarks:
|
||||||
|
|
||||||
@@ -42,29 +65,28 @@ Oh, wait a second... it is a maze-generating program. Oops!
|
|||||||
|
|
||||||
### What it does:
|
### What it does:
|
||||||
|
|
||||||
This program solves an optimization problem, namely, generating a
|
This program solves an optimization problem, namely, generating a challenging
|
||||||
challenging maze. It uses a very simple genetic algorithm: a maze
|
maze. It uses a very simple genetic algorithm: a maze layout's
|
||||||
layout's DNA is represented as a 32-bit integer, and mutations consist
|
[DNA](https://en.wikipedia.org/wiki/DNA) is represented as a 32-bit integer, and
|
||||||
of flipping three different bits. The algorithm is simple in that it
|
mutations consist of flipping three different bits. The algorithm is simple in
|
||||||
doesn't employ sexual reproduction, only mutations, and it has a
|
that it doesn't employ sexual reproduction, only mutations, and it has a
|
||||||
population size of 1. So much for diversity!
|
population size of 1. So much for diversity!
|
||||||
|
|
||||||
This particular optimization problem, I believe, has a unique maximum:
|
This particular optimization problem, I believe, has a unique maximum:
|
||||||
there is but one maze out of 2^32 that requires 64 moves to solve. The
|
there is but one maze out of `2^32` that requires 64 moves to solve. The
|
||||||
program will run until finding this global maximum, or if you get
|
program will run until finding this global maximum, or if you get
|
||||||
bored, you can accept a sub-optimal solution by pressing any key. On
|
bored, you can accept a sub-optimal solution by pressing any key. On
|
||||||
my system, it takes an average of 15 minutes to find the maximum,
|
my system, it takes an average of 15 minutes to find the maximum,
|
||||||
whereas a random search would take an average of 3.5 days.
|
whereas a random search would take an average of 3.5 days.
|
||||||
|
|
||||||
Should you take my word for it that the maze it generates requires as
|
Should you take my word for it that the maze it generates requires as many moves
|
||||||
many moves as I say it does? The answer is yes. But if you're not
|
as I say it does? The answer is yes. But if you're not convinced, you can try to
|
||||||
convinced, you can try to solve it yourself. The goal is to traverse
|
solve it yourself. The goal is to traverse from the upper-left to the
|
||||||
from the upper-left to the upper-right and out the top, where the
|
upper-right and out the top, where the number of moves remaining is printed. Use
|
||||||
number of moves remaining is printed. Use the arrow keys for suckers
|
the arrow keys for suckers (`w`, `a`, `s`, `d`) to move around. `q` quits and
|
||||||
(w, a, s, d) to move around. q quits and r restarts. Also, the maze
|
`r` restarts. Also, the maze changes as you move through it, in a predictable
|
||||||
changes as you move through it, in a predictable way. It should be
|
way. It should be easy enough to figure out the pattern. For best results, use a
|
||||||
easy enough to figure out the pattern. For best results, use a display
|
display with bold-text capabilities and color.
|
||||||
with bold-text capabilities and color.
|
|
||||||
|
|
||||||
Finally, in the world of DNA, the medium is truly the message. There's
|
Finally, in the world of DNA, the medium is truly the message. There's
|
||||||
a short message encoded in here that will only appear when you
|
a short message encoded in here that will only appear when you
|
||||||
@@ -76,37 +98,37 @@ These depend on your compiler, and they were all intentionally
|
|||||||
added for obfuscation purposes. No, really!
|
added for obfuscation purposes. No, really!
|
||||||
|
|
||||||
My compiler warns of nulls in a string literal, and the redefinition
|
My compiler warns of nulls in a string literal, and the redefinition
|
||||||
of the macro T.
|
of the macro `T`.
|
||||||
|
|
||||||
On one compiler, compilation took about two minutes.
|
On one compiler, compilation took about two minutes.
|
||||||
|
|
||||||
`sizeof(unsigned short)` must be 2, and `sizeof(unsigned long)` must be 4.
|
`sizeof(unsigned short)` must be 2, and `sizeof(unsigned long)` must be 4.
|
||||||
|
|
||||||
CLOCKS_PER_SEC is assumed to be 1000000. If it's a lot less than that,
|
`CLOCKS_PER_SEC` is assumed to be `1000000`. If it's a lot less than that,
|
||||||
expect delays.
|
expect delays.
|
||||||
|
|
||||||
### Algorithmic obfuscation:
|
### Algorithmic obfuscation:
|
||||||
|
|
||||||
The representation of the maze layout in a 32-bit integer type is
|
The representation of the maze layout in a 32-bit integer type is
|
||||||
pretty opaque. As a hint, the optimum layout's DNA is, in base 4,
|
pretty opaque. As a hint, the optimum layout's DNA is, in base 4,
|
||||||
2102231031201230. Try getting from there to the maze that appears on
|
`2102231031201230`. Try getting from there to the maze that appears on
|
||||||
screen.
|
screen.
|
||||||
|
|
||||||
The recursive function CGAC replaces a nested for loop in a handy way.
|
The recursive function `CGAC()` replaces a nested for loop in a handy way.
|
||||||
|
|
||||||
The maze-solving function TGA returns no solution both if no solution
|
The maze-solving function `TGA()` returns no solution both if no solution
|
||||||
exists, and if the search space grows too large, with a single test.
|
exists, and if the search space grows too large, with a single test.
|
||||||
|
|
||||||
### Stylistic obfuscation:
|
### Stylistic obfuscation:
|
||||||
|
|
||||||
Four-letter alphabets are confusing. I don't know how ribosomes
|
Four-letter alphabets are confusing. I don't know how
|
||||||
manage.
|
[ribosomes](https://en.wikipedia.org/wiki/Ribosome) manage.
|
||||||
|
|
||||||
Overloaded symbols, such as G and G().
|
Overloaded symbols, such as `G` and `G()`.
|
||||||
|
|
||||||
Who needs != when you've got ^?
|
Who needs `!=` when you've got `^`?
|
||||||
|
|
||||||
Who needs if when you've got while?
|
Who needs `if` when you've got `while`?
|
||||||
|
|
||||||
For that matter, who needs fixed-iteration-count for and while when
|
For that matter, who needs fixed-iteration-count for and while when
|
||||||
you can just duplicate code with the preprocessor? Duplication by this
|
you can just duplicate code with the preprocessor? Duplication by this
|
||||||
@@ -117,8 +139,10 @@ hindering the preprocessor's ability to deobfuscate.
|
|||||||
Keypad support was removed to save space. To restore, modify the
|
Keypad support was removed to save space. To restore, modify the
|
||||||
following two macros to:
|
following two macros to:
|
||||||
|
|
||||||
|
```c
|
||||||
#define ATG srand(time(0)); initscr(); cbreak(); noecho(); start_color(); keypad(stdscr,1);
|
#define ATG srand(time(0)); initscr(); cbreak(); noecho(); start_color(); keypad(stdscr,1);
|
||||||
#define AGG A&2?KEY_UP:KEY_DOWN:A&1?KEY_RIGHT:KEY_LEFT
|
#define AGG A&2?KEY_UP:KEY_DOWN:A&1?KEY_RIGHT:KEY_LEFT
|
||||||
|
```
|
||||||
|
|
||||||
Code on!
|
Code on!
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
+1
-1
@@ -36,7 +36,7 @@ Cel Skeggs,Cel_Skeggs,http://www.celskeggs.com,null,celskeggs@gmail.com,null,nul
|
|||||||
Chris King,Chris_King,null,null,ctk314@yahoo.com,null,null,null
|
Chris King,Chris_King,null,null,ctk314@yahoo.com,null,null,null
|
||||||
Christian Dupont,Christian_Dupont,null,null,christian.dupont@lemel.fr,null,null,null
|
Christian Dupont,Christian_Dupont,null,null,christian.dupont@lemel.fr,null,null,null
|
||||||
Christopher Mills,Christopher_Mills,null,null,mrxo@sonic.net,null,@MisterXopher,null
|
Christopher Mills,Christopher_Mills,null,null,mrxo@sonic.net,null,@MisterXopher,null
|
||||||
Christopher Night,Christopher_Night,http://www.people.fas.harvard.edu/~night/,null,null,US,null,null
|
Christopher Night,Christopher_Night,https://web.archive.org/web/20090415070532/https://www.people.fas.harvard.edu/~night/,null,null,US,null,null
|
||||||
Cody Boone Ferguson,Cody_Boone_Ferguson,https://xexyl.net,null,ioccc@xexyl.net,US,@xexyl@fosstodon.org,https://ioccc.xexyl.net
|
Cody Boone Ferguson,Cody_Boone_Ferguson,https://xexyl.net,null,ioccc@xexyl.net,US,@xexyl@fosstodon.org,https://ioccc.xexyl.net
|
||||||
Col. G. L. Sicherman,Col._G._L._Sicherman,http://www.monmouth.com/~colonel/,null,colonel@monmouth.com,null,null,null
|
Col. G. L. Sicherman,Col._G._L._Sicherman,http://www.monmouth.com/~colonel/,null,colonel@monmouth.com,null,null,null
|
||||||
Craig Schneiderwent,Craig_Schneiderwent,null,null,evilgenius@attglobal.net,null,null,null
|
Craig Schneiderwent,Craig_Schneiderwent,null,null,evilgenius@attglobal.net,null,null,null
|
||||||
|
|||||||
|
Can't render this file because it contains an unexpected character in line 23 and column 6.
|
+1
-1
@@ -897,7 +897,7 @@ Contest </I></FONT></CENTER><BR>
|
|||||||
<LI TYPE=square>Best Font Engine (<A HREF="years.html#2004_newbern">2004 newbern</A>)
|
<LI TYPE=square>Best Font Engine (<A HREF="years.html#2004_newbern">2004 newbern</A>)
|
||||||
</UL><BR>
|
</UL><BR>
|
||||||
|
|
||||||
<LI TYPE=none><A NAME="Christopher_Night"></A><B>Christopher Night</B> -- <A HREF="http://www.people.fas.harvard.edu/~night/">http://www.people.fas.harvard.edu/~night/</a>
|
<LI TYPE=none><A NAME="Christopher_Night"></A><B>Christopher Night</B> -- <A HREF="https://web.archive.org/web/20090415070532/https://www.people.fas.harvard.edu/~night/">https://web.archive.org/web/20090415070532/https://www.people.fas.harvard.edu/~night/</a>
|
||||||
<UL>
|
<UL>
|
||||||
<LI TYPE=square>Best Abuse of Computation (<A HREF="years.html#2006_night">2006 night</A>)
|
<LI TYPE=square>Best Abuse of Computation (<A HREF="years.html#2006_night">2006 night</A>)
|
||||||
</UL><BR>
|
</UL><BR>
|
||||||
|
|||||||
Reference in new issue
Block a user