Note: This was originally posted as a thread on Twitter. It has been lightly edited and reformatted here for convenience.

In the early 90s, when I was in elementary school, I got assigned to write a report on a topic of my choosing. I decided to write about computer viruses. There weren’t many books at the time I could use as sources, but I found Levy’s “Hackers: Heroes of the Computer Revolution”

One thing from the book that stuck with me was “You can create art and beauty on a computer”.

This wasn’t just about audio/visual aesthetic, though the demoscene does make some amazing things there, but also that a clever bit of code could be considered art in its own right.

Code golf, perl poetry, obfuscated programs, esoteric languages, they’re all expressions of human skill and creativity, and when executed well they can evoke emotion.

I think the first thing I made that someone called “art” was a bot I wrote to play “rock, paper, scissors”.

You can see that bot here: http://rpscontest.com/entry/614005

1from hashlib import sha256
2
3# The constant used here came to me in a dream.
4state = input and state + input or 'e+4sk5jfPPON3muIQJPM-KBCJPyYHgkkgXgpprL2'
5output = 'RPS'[int(sha256(state).hexdigest(),16)%3]

It’s two lines of code, not counting the import and comment, and yet it has an almost 60% win rate. How is that possible? The comment says “The constant used here came to me in a dream”, which only raises further questions.

A bot playing randomly, for reference, can be expected to win about half of the time, and the best bots on the site did around 80-85% - all this of being against other bots.

Two lines of Python with a seemingly random constant shouldn’t be able to do so well, should it?

The trick was, since all the bots had their code available on the site, I simply downloaded them all, and ran simulations for days, generating a random constant and seeing how it did against the existing bots. Eventually I picked one.

Not at all magic, but the goal of this code really was just to make people who saw it go “What the... What.... How!?”, and that it does. Knowing how it works removes some of the wonder, but replaces it with appreciation (or perhaps something else) for “hack value”.

I like making things that serve no practical purpose, but have that “hack value” that others can enjoy. Someone once posted on a discussion about another of my projects something to the effect of “I can’t hear you over the sound of how awesome this is”.

The simple process of discovery - challenging myself to do something, going into it unsure as to whether it’s possible, figuring it out, and implementing it is rewarding on its own. Seeing the reactions, though, is some pretty amazing icing on top of that already delicious cake.