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 000000000..fb67011e5 Binary files /dev/null and b/2006/night/night.alt.c differ 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/