I am a computer scientist by both occupation and interest. When I'm not coding something boring at work, then I'll sure be coding something boring at home. Whenever I get an idea about something cool, I generally do that cool thing until it's done (by which I mean I get bored of it).

One thing I made was Topolife, which I conjured up about a year ago with a desire to implement Conway's Life on various interesting topological surfaces. Topolife gave me hours of math-based entertainment when I first made it. Unfortunately no one else I know shares enough of my particular brand of quirks to see Topolife as the incredible feat of mathemathical majesty that it is. So that project was left to fester deep inside my web server so that only I would ever find it again. But if you want to know how a Conway glider behaves on a real projective plane, then just give Topolife a go! Who wouldn't want to see that?

Back in autumn 2003 when I was a second-year CS student at the University of Waterloo, I was enrolled in CS246 (C++ and software engineering). The final part of the course involved a group assignment designed to apply lots of C++ and software engineering knowledge we as students should have acquired over the course of the term. My group included me, gharbad and qedi. Qedi, being the huge nerd that he is, founded an IRC channel for the three of us. (This channel, #keveX on irc.slashnet.org, is still in use to this day.)

A little backstory: at around this time, a rival Java developer, the Torb, was building an IRC bot designed to take and deliver messages to users even if they were offline. In my opinion, he made the bot a lot less efficiently than it should have been done. I sought to one-up the Torb and produce a faster Java IRC bot.

And so KevBot, the Kevin Immitation Bot, was born.

Initially, KevBot's only reason to be was to be better than the Torb's bot, and also to facilitate sending messages between qedi, gharbad and me. Over time, though, I kept strapping features onto it. After five years, KevBot can now store and play back messages, do floating-point arithmetic, record things people say to play them back later at annoying times, monitor user activity and a whole lot more. KevBot's primary purpose nowadays is to store what I call "factoids". A factoid is any sentence containing either the word "is" or "are". This sentence, for example, is a factoid. KevBot, at the time of this writing, has 66132 factoids stored.

At some point earlier this month I decided that KevBot was not annoying enough, so I decided to use its database of over 66000 factoids as a seed for a Markov chain. For those of us who aren't me and don't remember back to that CS486 (intro to artificial intelligence) lecture on Markov chains, here is a rough explanation:

Suppose you have the book Dune, by Frank Herbert (which is a great book, by the way) and a list of randomly generated numbers. Using the first random number on your list, turn to that page of Dune. Pick a word out of the chosen page. I picked the word "his". Then pick the word after "his", which in this case is "voice". Now, turn to a new random page and look for the word "voice". Make note of the word following "voice" on that page, which in my case is "on". Then look for "on" on a new page and make note of its following word. Continue this until you feel like stopping. You'll end up with a "sentence" like "his voice on to the Baron snapped". The words that appear in the sentence vary with respect to the frequencies of the words used in the source. So sentences generated from the book Dune will resemble the book Dune on a superficial level. Sentences generated from a cookbook will resemble cooking instructions. Any two words go together, but the sentence as a whole doesn't make any sense at all.

Because of this, when KevBot executes its Markov chain algorithm on its database of things people said, the resulting sentences are often uncannily relevent to the conversation at hand, often including the names of regular chatters and their interests. The results can be eerily poetic:

Let's us apart,
under a GO,
crazy and now
23 at the real things
is using your GOD
to be seen;

Sometimes they're kinda deep-sounding:

is the people use the irony, if I live and hunter.

And sometimes they make no sense whatsoever:

it has to baby is so stupid connection reset

Every once in a while, though, KevBot emits a perfectly valid sentence (or close enough) that no one would have expected:

I don't deserve to be retarded

Maybe not, KevBot. Maybe not.

"So long EMAIL program, spread is face in the only available where I gotta do work. And I interviewed with Rip. Until you that are quite normal. Fun in fact so you want. Only works and like a stupid vampires eating your name are right the guys and generally really deadly. Again from the same!"

I enjoy reading output like the above in games like TF2 as a way to help people loosen up. Not many people can continue taking things too seriously in the presence of a Markov chain. And so applied computer science has done its part to make the world a better (and funnier) place!