Daniel Barnes

a blog
Recent Posts View tags

Tag 'Perl':

Regolf, the Regular Expression game!

I think I first learned about regular expressions through xkcd comics.

Meanwhile, I like to spend time on EsperNet (IRC chat), where I am currently an operator under the name nasonfish.

Some people make bots in order to make social games possible over IRC-- for example, I used to like to play an implementation of a game called "Werewolf", the social detective game where the werewolves are trying to eat the people and the people are trying to kill the werewolves, and the only clues you have are the person who gets eaten every night by the wolves. There was a great bot set up which made the game really fun, and with enough people it added enough spice to the game with other roles like the seer, harlot, detective, etc.

So, a few years ago, I made Regolf -- an IRC bot which runs a social regex-golf game.

The bot comes up with a set of words, and players compete to come up with the shortest regular expression to match all the words in one set of words, but none of the words in another set. An example of this is the title-text of xkcd comic 1313:

/bu|[rn]t|[coy]e|[mtg]a|j|iso|n[hl]|[ae]d|lev|sh|[lnd]i|[po]o|ls/ matches the last names of elected US presidents but not their opponents.

The golf part comes in as you try to find the shortest possible solution for a problem (much like code golf, another fun activity!)

When you trigger the bot, it comes up with something like this:

[22:49:51] <@nasonfish> !start
[22:49:52] <regolf> Beginning new regex golf game.
[22:49:52] <regolf> Please match: Wheaties, cellulars, zippers, overseers, misrepresented, mindlessness, newsletters
[22:49:52] <regolf> Do not match: Dagwood, Weinberg, chairperson, hookworm, mummer, Fatimid, Bernini
[22:49:52] <regolf> You have 105 seconds; Private message me your regular expression(s) using /msg regolf expression!

The user would message the bot something like:

[22:52:16] <nasonfish> V|T|D|zz|ps|nn
[22:52:16] -regolf- V|T|D|zz|ps|nn (11/6/6): Positive: Velveeta, leprechauns, Triangulum, Diaghilev, fuzziness, sups, gunrunners | Negative: imprint, scrolled, deform, encapsulations, Algerian, unit, saxophonists

Once time is up, the user may no longer edit their regex, and points are awarded on accuracy and length of expression. Once you reach a certain amount of points, you win the game, so it's a race to consistently come up with the best regexes.

This bot has been out of service for quite a while, but on a whim, I brought it back on. So, feel free to join me in #regolf on the IRC network EsperNet for a game of regex golf sometime!


By Daniel, on June 15, 2018, 11:11 pm