Programming Quirks: Moon Phases and Easter Eggs in Code | May 26 2024, 11:19

Two fun stories about the daily life of programmers.

The first one:

Researchers (@maciejwolczyk, @CupiaBart) trained a neural network to play NetHack, an old role-playing game where everything is represented by text characters. It’s a very old RPG from the days (1987) when there were no normal user interfaces, and everything happened in the console. The player goes through levels, collects items and rewards, participates in battles, and scores points — all expressed through the simplest characters.

In general, they trained it. The model consistently scored 5000 points. However, suddenly something went wrong — the model started scoring only 3000 points. That is, it showed a significantly worse result. Debugging solutions is always fun, so the thread author tried:

— to find a problem in the agent model loading code

— to roll back the code a few days ago

— to roll back the code several weeks ago (well, surely everything works there?)

— to rebuild the environment

— to change the version of CUDA (drivers for running neural networks on a video card)

— to run the code on a personal laptop, not a server

Nothing helped — the model consistently showed 3000 points.

In desperation, the author wrote to the creator of the model @JensTuyls, and received an unexpected response:

— Maybe it’s a full moon today 🌕

What?? 😑

Upon checking the lunar calendar, it turned out that indeed it was a full moon that day. The author launched the game and saw the message: “You’re lucky! It’s a full moon today.”

In NetHack, there is a mechanic that changes the gameplay during a full moon, based on the system time. The character becomes luckier, werewolves appear in their beastly guise, and dogs start howling. The model was not trained with data from the full moon, so its scores dropped to 3000 points. By changing the system time, the author confirmed that the model again scored 5000 points.

This did not make the game more difficult, but the model simply did not understand how the rules had changed and tried to play as usual — hence the drop in points. To check, you can change the time on your computer — and the model again scores 5000 points.

Moral: When faced with an unexpected error, don’t forget to check the lunar calendar.

* * *

The second story is about the ‘man’ command in the console.

This is a command that outputs documentation about what is entered as the second parameter. For example, “man ls” provides documentation on ls, which shows a list of files and subdirectories of the current directory, and “man man” provides documentation about itself.

On StackExchange, someone was wondering why their tests were failing. Answers

Marnanel Thurman:

Uh, that’s my fault, I suggested it. Sorry. Almost the entire story is outlined in the commit. The programmer maintaining the ‘man’, a good friend of mine, and one day, six years ago, I jokingly told him that if you called ‘man’ after midnight, it should print “gimme gimme gimme”, because of the Abba song “Gimme gimme gimme a man after midnight”:

Well, he actually added it. It was fun for someone to discover this, and we mostly forgot about it until today.

I can’t speak for Cola, of course, but I never expected that it would ever cause any issues: what test would break down parsing man output with no specified page? I suppose I shouldn’t have been surprised that such a test was eventually found, but it took six years.”

Leave a comment