regular expression game Nov 17, 2010

This game is based on the Icehouse game called Zendo (itself based on other similar inductive logic games), adapted for play with computers instead of plastic pyramids.

Wtf are regular expressions?! You can play this game with any type of objects---Flickr photos (or images in general), lines of natural language, book or song titles, physical objects, etc. As long as you can make a rule and people can ask whether particular objects fit your rule, then you are essentially playing this game.

So. Learn about regular expressions. Not the theoretical kind---the kind implemented in programming languages and system utilities. Regular expressions are a super handy way to search for patterns within strings.

Find some friends who know regular expressions too. This may or may not be the hardest part, depending on your social circle(s).

Agree on a string representation and regular expression standard. I suggest Python or Perl. You could also use POSIX extended regular expressions, if you don't mind expressing strings shell-style. (What, you want to use Perl strings with POSIX regexen?!) If finding a bunch of regex-grokking friends was easy for you, then this may be the most difficult step; try to avoid a holy war.

Come up with a regular expression. You will begin to get a feel for this after a few games. Watching your players struggle with (or quickly guess) your regular expressions will give you a sense of what the right difficulty level is.

Come up with two strings: one which your expression matches and one which it does not. Tell the players what the strings are and which is which.

You may play turnless or in turns, but either way the players guess their own strings and ask you whether they match or not. (If assisted by a computer, this step may be automatic.)

A player may instead try to guess your regular expression. You must then provide a string which either your regular expression matches but theirs doesn't, or their regular expression matches but yours doesn't. Make it clear to the players which regular expressions match the string, but don't tell them your expression. If you cannot come up with such a string, then your regular expression is equivalent to their guess and they win the game and become the master for the next game. (Many, if not all, regular expressions have multiple ways of being written: consider /[ab]/ and /a|b/.)

Rave Reviews!

Glowing Fish says re regular expression game: I am 31 and have never kissed a girl. I don't know if this game will help me do so.

Example Game

I secretly chose the expression [DFSR].

<raincomplex> 'aba777' matches and '777aba' doesn't. What's the regex?
<locke baron> fwee
<raincomplex> 'fwee' doesn't match
<OldMiner> m/^777/
<OldMiner> Oh, wait, reversed, m/777$/
<raincomplex> my regex matches 'b777a', so it can't be /777$/
<raincomplex> (on a pedantic side-note---do string match regexes or do regexes match strings? or both?)
<OldMiner> Does it match c777a?
<raincomplex> OM: my regex doesn't match 'c777a'
<OldMiner> Does it match b777bbbba?
<lizardinlaw> ???
<raincomplex> OM: yes
<OldMiner> Does it match somethingsomethingb...777....asomethingsomething ?
<raincomplex> OM: 'somethingsomethingb...777....asomethingsomething' doesn't match
<eritain> does your regex match aba77?
<raincomplex> it does not!
game in progress, join or die! Well, you probably won't die, but you won't win!

Guess my secret regular expression. You can:

- ask whether a string matches
- guess at the regular expression (I'll give a string counterexample if the guess is wrong)

Matching strings:

Non-matching strings:

Guessed regular expressions:

special thanks to eritain, who has been playing this example game on and off since i posted this node.—rc, july 2012

See Also

Zendo-Tao---Also adaptable to regular expressions. A twist on the above game, but probably not as satisfying.

Nomic and Dvorak. Not directly related, but this game reminds me of them---games in which rule-changing is part of the game.