Files
ioccc/2006/night
Landon Curt Noll c5848302e8 add new topbar, improve the look & feel of web pages
Thank you, @chris-sab, for your excellent work and for helping us
commit this alpha version of the topbar.

As part of this work, the following HTML sections were removed:

* begin-row
* begin-leftcolumn
* sidenav
* end-leftcolumn
* begin-rightcolumn
* before-content
* end-rightcolumn
* end-row.default

Also added a new HTML section, just above the "header" section:

* topbar

The web site now as a more modern looking topbar, thanks to the
work of the contractor (GitHub user @chris-sab) who is working on
issue #2273.

Performed `make www` to implement the above and test under macOS.

TODO: Fix the Responsive Web Design to deal with
      the new topbar system.

TODO: Improve the topbar.  What is there now is
      just an alpha version.

TODO: Decide what to do with `png/ioccc.png`.
      Remove it make selective use of the image on certain top level
      pages lower down?

TODO: The changes to `ioccc.css` causes some
      formatting problems with pages such as `location.html` (missing
      blank lines).  Fix formatting problems as needed.

TODO: Fix the "Nu HTML check this web page"
      links on things like the year level _YYYY/index.html_ pages.

TODO: Correct all HTML errors, warnings and perhaps
      informative messages from the Nu HTML check.

TODO: Consider adding color (colour) to the
      web pages in such a way that people with color perception
      challenges can still use the web site.

TODO: For those web browsers that have and allow
      JavaScript, make use of technology such as [Code
      Mirror](https://codemirror.net/) to directly render source
      code (C, shell, Makefile, etc.) with syntax coloring (colouring)
      directly in the browser.  For non-JavaScript browsers, fallback
      to the current use of GitHub source code viewing.
2024-04-16 17:28:39 -07:00
..
2023-04-30 09:38:23 -07:00
2020-12-30 16:57:03 -08:00
2023-07-06 21:49:38 -07:00

To build:

    make

There is an alternate version that supports arrow keys. See the alternate code section below.

To use:

    ./night

Alternate code:

This version allows you to use arrow keys instead of the more awkward wasd keys.

Alternate build:

    make alt

Alternate use:

Use night.alt as you would night above.

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.

Author's remarks:

Don't worry; this is not a self-reproducing program, as you might at first guess from the layout. I would never be so foolhardy as to submit an entry on an overused theme!

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 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 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.

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 complete the optimal maze in the required 64 moves.

Issues:

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.

With 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, 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 screen.

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 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.

Overloaded symbols, such as G and G().

Who needs != when you've got ^?

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 macro causes one particular graphics line to be replicated 512 times. On my system the preprocessed code is over 80KB in length, hindering the preprocessor's ability to deobfuscate.

Keypad support was removed to save space. To restore, modify the following two macros to:

    #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!