From ae310f9372b9403aefa394c42b8d473916c02382 Mon Sep 17 00:00:00 2001
From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com>
Date: Sun, 30 Apr 2023 09:38:23 -0700
Subject: [PATCH] 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.
---
2006/night/.gitignore | 1 +
2006/night/Makefile | 7 ++-
2006/night/README.md | 94 ++++++++++++++++++++++++++---------------
2006/night/night.alt.c | Bin 0 -> 3733 bytes
tmp/winners.csv | 2 +-
winners.html | 2 +-
6 files changed, 67 insertions(+), 39 deletions(-)
create mode 100644 2006/night/night.alt.c
diff --git a/2006/night/.gitignore b/2006/night/.gitignore
index 41feb5b6d..3ba331560 100644
--- a/2006/night/.gitignore
+++ b/2006/night/.gitignore
@@ -1 +1,2 @@
night
+night.alt
diff --git a/2006/night/Makefile b/2006/night/Makefile
index bc828b900..17dc0fcc2 100644
--- a/2006/night/Makefile
+++ b/2006/night/Makefile
@@ -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}
diff --git a/2006/night/README.md b/2006/night/README.md
index aed239822..a2449c481 100644
--- a/2006/night/README.md
+++ b/2006/night/README.md
@@ -1,11 +1,8 @@
# Best Abuse of Computation
- Christopher Night
- Harvard University
- Department of Astronomy
- Cambrige MA 02238
- US
-
+Christopher Night
+US
+
## 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)
+.
## 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!
diff --git a/2006/night/night.alt.c b/2006/night/night.alt.c
new file mode 100644
index 0000000000000000000000000000000000000000..fb67011e5b03b102dec09fd096aca43ba4b48904
GIT binary patch
literal 3733
zcma)9e|r)~5YFFxij6*;yLXFl2SH0%;=0yNpXM=XoEB@$QG~0(MzDbOvDNS1clHuO
zVq#pvv9~+3^W&YFo!p&FN2edgh3HO4ALff=_AhG=PzQBw4FkMXE
zOp9@a#OZAMM)+;a7ALd$QaIXPF&4FBTU
zbXJT`W;|Oghx6rNG&`LIlD~>i?}uZ#SdPJ?Q+08+_mZ?zVz^vF(WSJ5$NPIv;!R2F
zv)kX>KO7v`pAMy~W=RUU7dkoVRnTJaemI#+U(dAH)7iK<9ez3&Ea_U4D{^#
zk0+DU0+SVol~xHW{=@f6r2@~{qqN&i+sE6&3s2`S*m2fsJn$v21@Q#GK!PWDBZsdB
zkK3+{PKI+4Tj$N4-4`$DppoVK?(y#4t5+`${`iCPXHO0uHX6@=dEUp$qeqV#qqKSW
za&K?9+dmr{8~5M#H_Flf`~JqgA69P%_ck`(zTVjAW97k9{w>Gjw+H?H>sg-n`+5FD
zzkiSq2L1kE(AG~n`R?Il_S<&nw||!}?`RQw=X7j6X-{-?Y)Dor0)vgVew(Ma4KE0p
z2P$y5@8V!mP
z4F_p9+IhChOV=|N3G3yiRWMSzC;}SJ=SUegglR=$r0ZJM?PkGKWVjAAw5z7=xLIqq
zbhD8$oj3|hS+cGJKt0Au)>`;M1~L}kgRTloVL&oOB3i9<$r*`gYFkU8iV$odnak&svlhpsl$gmjv~BU*@Bjgt?3`@}
zQsmK5IEjw6^%`E#R&`1W-lO9v3T4u3tIGwY;NgG~%Ok|91r{7u{9;m$7vW3|kr!KQ
zY>4F8lWATbFkU8!%ZY7ce@X(+&A1=AV^z;0+z0TSk%-KdBd(pG&bZ?wZ7aAe-BKJC
zLZ96881?406zwm4kP^H@E?yu$R)t$nP!^
z6#39KI9PQFFBBWci4Q=;d4w~_@RUa;+(`lw^&pEVZ@1t&uKT&6daIftUaAkTVG%+oH$8X
z9=vre2Z#Vk1E_K9g&N^xD?qq;6L}zVcuFqdpwF288`L00xkOLJpl-Slm%MiE;CSM6
z#w8qFM>nc15Hj09lTBmS;*!BHk-1(KzElus;ZsUZl8~3CEZtYM$x#3(!ri2z=FZw)
z+CdbceYh&b5THSVqVySTSF^a8H*-vQ@w^gTVmd1e5T9coE<_|yjxGh&9jB?X;NoSC
zD~h;BOq;FFno3uvY4f38Q!r}iHa=)1uM%E<-)V@>mO2v_3~@5e9$qH;`t7q7Ft%jF
zMFjPlorX?R-P8>Q+Z6_PsUgxW*H`kKec=uZY`{$e!+I-9+uV@xHLU=vtEDMw7Z642
zaQ!^1pruD}{U+G|TA{C3jFG4ke6eLa)}x=ieQ*V;)wn4{O^;Gsfwv85bCcD$kXK+c
z{D+?F%;F7z=>jetkag83q~bAzi8L4rcT_h3RkMw-#3s*>|{
Ve0D2xzMqF`DW
literal 0
HcmV?d00001
diff --git a/tmp/winners.csv b/tmp/winners.csv
index f0cee256c..23e193b9b 100644
--- a/tmp/winners.csv
+++ b/tmp/winners.csv
@@ -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
diff --git a/winners.html b/winners.html
index 84dd47948..40d5ea90a 100644
--- a/winners.html
+++ b/winners.html
@@ -897,7 +897,7 @@ Contest
Best Font Engine (2004 newbern)
-Christopher Night -- http://www.people.fas.harvard.edu/~night/
+Christopher Night -- https://web.archive.org/web/20090415070532/https://www.people.fas.harvard.edu/~night/