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:
Cody Boone Ferguson committed 2023-04-30 09:38:23 -07:00
1 parent 69d530e978
commit ae310f9372
6 files changed
+67 -39

No files matched your search

+1
View File
@@ -1 +1,2 @@
night
night.alt
+5 -2
View File
@@ -116,8 +116,8 @@ OBJ= ${PROG}.o
DATA=
TARGET= ${PROG}
#
ALT_OBJ=
ALT_TARGET=
ALT_OBJ= ${PROG}.alt.o
ALT_TARGET= ${PROG}.alt
#################
@@ -139,6 +139,9 @@ ${PROG}: ${PROG}.c
alt: data ${ALT_TARGET}
@${TRUE}
${PROG}.alt: ${PROG}.alt.c
${CC} ${CFLAGS} $< -o $@ ${LIBS}
# data files
#
data: ${DATA}
+59 -35
View File
@@ -1,11 +1,8 @@
# Best Abuse of Computation
Christopher Night
Harvard University
Department of Astronomy
Cambrige MA 02238
US
<http://www.people.fas.harvard.edu/~night/>
Christopher Night
US
<https://web.archive.org/web/20090415070532/https://www.people.fas.harvard.edu/~night>
## To build:
@@ -19,18 +16,44 @@ make
./night
```
There is an alternate version that supports arrow keys. See the alternate code
section below.
## Try:
```sh
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:
You'd never guess, from looking at the code, that there is a
genetic algorithm involved. Somewhere. But what does it do?
Well, it might take you a while to navigate the results, let
alone the code.
You'd never guess, from looking at the code, that there is a [genetic
algorithm](https://towardsdatascience.com/introduction-to-genetic-algorithms-including-example-code-e396e98d8bf3)
involved. Somewhere. But what does it do? Well, it might take you a while to
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:
@@ -42,29 +65,28 @@ Oh, wait a second... it is a maze-generating program. Oops!
### What it does:
This program solves an optimization problem, namely, generating a
challenging maze. It uses a very simple genetic algorithm: a maze
layout's DNA is represented as a 32-bit integer, and mutations consist
of flipping three different bits. The algorithm is simple in that it
doesn't employ sexual reproduction, only mutations, and it has a
This program solves an optimization problem, namely, generating a challenging
maze. It uses a very simple genetic algorithm: a maze layout's
[DNA](https://en.wikipedia.org/wiki/DNA) is represented as a 32-bit integer, and
mutations consist of flipping three different bits. The algorithm is simple in
that it doesn't employ sexual reproduction, only mutations, and it has a
population size of 1. So much for diversity!
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
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,
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
many moves as I say it does? The answer is yes. But if you're not
convinced, you can try to solve it yourself. The goal is to traverse
from the upper-left to the upper-right and out the top, where the
number of moves remaining is printed. Use the arrow keys for suckers
(w, a, s, d) to move around. q quits and r restarts. Also, the maze
changes as you move through it, in a predictable way. It should be
easy enough to figure out the pattern. For best results, use a display
with bold-text capabilities and color.
Should you take my word for it that the maze it generates requires as many moves
as I say it does? The answer is yes. But if you're not convinced, you can try to
solve it yourself. The goal is to traverse from the upper-left to the
upper-right and out the top, where the number of moves remaining is printed. Use
the arrow keys for suckers (`w`, `a`, `s`, `d`) to move around. `q` quits and
`r` restarts. Also, the maze changes as you move through it, in a predictable
way. It should be easy enough to figure out the pattern. For best results, use a
display with bold-text capabilities and color.
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
@@ -76,37 +98,37 @@ These depend on your compiler, and they were all intentionally
added for obfuscation purposes. No, really!
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.
`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.
### Algorithmic obfuscation:
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,
2102231031201230. Try getting from there to the maze that appears on
`2102231031201230`. Try getting from there to the maze that appears on
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.
### Stylistic obfuscation:
Four-letter alphabets are confusing. I don't know how ribosomes
manage.
Four-letter alphabets are confusing. I don't know how
[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
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
following two macros to:
```c
#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
```
Code on!
Binary file not shown.
+1 -1
View File
@@ -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
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 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
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
Can't render this file because it contains an unexpected character in line 23 and column 6.
+1 -1
View File
@@ -897,7 +897,7 @@ Contest </I></FONT></CENTER><BR>
<LI TYPE=square>Best Font Engine (<A HREF="years.html#2004_newbern">2004 newbern</A>)
</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>
<LI TYPE=square>Best Abuse of Computation (<A HREF="years.html#2006_night">2006 night</A>)
</UL><BR>