RegEx Express
From WorkCDN
This is for Pyweek7 game from Steveth45 and HanClinto.
The theme is "The length of a piece of string", and one idea we like is to make a regular expressions pattern matching game.
Contents |
Abstract
To teach people how to use regular expressions, and provide a series of puzzles that progressively challenge them through randomly generated puzzles.
Additionally, multiplayer would be a lot of fun, but is not necessary.
Game Components
The components of the game are broken up into multiple
Regex Tutorials
Task: Create a series of regular expressions and sample sets that walk a new player through the task of creating a regular expression.
Must provide a key regular expression, a sample set, and description / interaction text to walk a player through. Focusing on and tuning this learning curve is VERY important.
Problem Types
- Lists Simple Match : regex must match somewhere for each in the first list, and not in the each element of the second list
- Lists Full Match : like the first one, but regex must match each element in first list fully
- Subselection : regex must exactly match highlighted areas of a single, monolithic string.
Tutorial Format
For simple match puzzles, there are a few field that go into defining a tutorial:
- Title -- this is < 20 characters to give the tutorial a heading in the menus.
- Description -- this is the main body of the tutorial text, that teaches the lesson, introduces new concepts, and lays out the challenge.
- Good words -- this is a list of words that the user is supposed to match
- Bad words -- this is a list of words that the user cannot match.
- Base / Par Regex -- this is a regex that is guaranteed to solve the puzzle the way it was intended to be solved.
- Hint -- if the user asks for help during a puzzle, this hint will be displayed to give the user another boost in the right direction.
Regex Generator
Task: Create an algorithm that generates regular expressions of varying difficulty.
getRegex( difficulty )
A sample call of:
getRegex( 1 )
Should return a regex that looks something like:
"t$"
A sample call of:
getRegex( 4 )
Should return a regex that looks something like:
"^\c.\v.\c.$"
Sample Set Generator
Task: Given a regular expression and dictionary identifier, generates a list of x-number matches, and y-number non-matches.
getSampleSet( regex, dictionary, numPositive, numNegative )
A sample call of (where \c matches on a consonant and \v matches on a vowel):
getSampleSet( "^\c.\v.\c.$", EnglishWords, 5, 5 )
Should return a tuple that looks something like:
[["dog","cram","court","group","rat"],["create","erode","and","merit","be"]]
In the event that the there are not enough matches in either category, it should return an error in some way.
Interactive Regex Shell
Task: Given a regular expression and a sample set, it should present the sample-set to the user and provide dynamic feedback similar to "live find" capability for hilighting matches and non-matches, as a way of helping the player visualize what regex matches with the desired strings, and the undesired strings.
Should have two columns of text, one of strings intended to match, one of strings intended to not match. Hilight them as good if they match/don't-match as they should, or hilight them as bad if they match counter to their category.
Should have an input box at the bottom of the screen.
When they press enter, the current regex should be added to a history list, and clear the box so that they can refer back to previous things that they attempted.
When all samples properly match, the shell returns with a win state, and statistics regarding:
- player's regex solution (which may or may not match the regex key, as there are many ways to skin this cat)
- length of solved regex
- length of time from presentation to solving
- number of keystrokes
- number of times backspace was pressed
From these statistics, a score can be generated.
Game UI Structure
Should have menus, with selections to set options/preferences, setting difficulty, viewing statistics/scores, quitting, and starting new games.
Main Menu Mockup
The current thought is to use a standard 40x24 VT102 terminal window size.
12345678901234567890123456789012345678901234567890123456789012345678901234567890 1+------------------------------------------------------------------------------+ 2| | 3| +-------------------+ | 4| | [T]utorial | | 5| | [N]ew Game | | 6| | [D]ifficulty: 3 | | 7| | | | 8| | [H]elp | | 9| | [Q]uit | | 0| | | | 1| +-------------------+ | 2| | 3| | 4| | 5| o o | 6| O Oo o O | 7| o o o | 8| ooo | 9| Oo ___ __________ ___________ ___________ __-----__ | 0| _\/__|_|_ _,o+-o.,_ | |.\/.| | | REGEX | | EXPRESS | ||_| |_|| | 1| (=R.E.X._|--|_______|--|_|_/\_|_|--|_________|--|_________|--|_______| | 2| //o--=OOO- `O` `O` `O` `O` `O` `O` `O` `O` `O` `O` | 3+------------------------------------------------------------------------------+
The train at the bottom will be animated, with billowing smoke as it loops across the bottom of the screen.
Multiplayer
Put thoughts relating to multiplayer here. Multiplayer may be accounted for from the beginning (I.E., modularize the game to assist in making multiplayer later), but we should not put much/any work in on it in specific until we have a working minimum-shippable game that works in single-player.
SVN
Subversion Repository (requires hc.com login/password)
Name Brainstorm
Having a really hard time coming up with a good name for the game.
Note: There are a lot of entries this year. If we pick a name that is closer to the beginning of the alphabet, we are more likely to be played.
Possible words to build off of:
cut slice string reg regular express expression knot curses cursed
Possible names
Regexpert String Expressions Express-string Expression Express (maybe do an ascii train theme?) (We could make it sortof as a "Conjunction Junction" parody, with lots of rhyme, hominym and alliteration) Regular Express Slicing Pie Slicing String
Top Choices
Expression Express Regular Expression Express Regular Express (sounds like a name for a laxative) RegEx Express
Theme
If we do go with an "Expression Express" or something, we could go with an ascii train theme, with lots of cheesy puns, rhymes, and humor.
Frame 1
o o
o Oo o o
oO O O
oO
OO ___ __________ ___________ ___________ __-----__
_\/__|_|_ _,o+-o.,_ | |.\/.| | | REGEX | | EXPRESS | ||_| |_||
(=R.E.X._|--|_______|--|_|_/\_|_|--|_________|--|_________|--|_______|
//o--=OOO- `O` `O` `O` `O` `O` `O` `O` `O` `O` `O`
Frame 2
o o o
O o o
o oO o
OoO
oOo ___ __________ ___________ ___________ __-----__
_\/__|_|_ _,o+-o.,_ | |.\/.| | | REGEX | | EXPRESS | ||_| |_||
(=R.E.X._|--|_______|--|_|_/\_|_|--|_________|--|_________|--|_______|
//o--=OOO- `O` `O` `O` `O` `O` `O` `O` `O` `O` `O`
Frame 3
o o o
o o o o
o O Oo o
o oO
ooO ___ __________ ___________ ___________ __-----__
_\/__|_|_ _,o+-o.,_ | |.\/.| | | REGEX | | EXPRESS | ||_| |_||
(=R.E.X._|--|_______|--|_|_/\_|_|--|_________|--|_________|--|_______|
//o--=OOO- `O` `O` `O` `O` `O` `O` `O` `O` `O` `O`
Frame 4
o o
O Oo o O
o o o
ooo
Oo ___ __________ ___________ ___________ __-----__
_\/__|_|_ _,o+-o.,_ | |.\/.| | | REGEX | | EXPRESS | ||_| |_||
(=R.E.X._|--|_______|--|_|_/\_|_|--|_________|--|_________|--|_______|
//o--=OOO- `O` `O` `O` `O` `O` `O` `O` `O` `O` `O`
This page has some great ones.
This page also has some ascii art trains. (warning: midi)
Please note that the above train is an original creation, that was only loosely inspired by some of the elements of other ascii trains.
Resources
Case sensitive regex for consonants: [B-DF-HJ-NP-TV-XZb-df-hj-np-tv-xz] Case sensitive regex for vowels: [AEIOUaeiou]
Non-case-sensitive regex for consonants: [b-df-hj-np-tv-xz] Non-case-sensitive regex for vowels: [aeiou]
TODO
Improvements
From the comments:
- Change the "pass" - "no pass" headers to "match" - "not match" headers
- If fail, dont erase the regex candidate
- Add on another F key a quick reference chart for the special characters.
- Allow remap certain characters: in keyboards where '^' is a dead key, like spanish and probably other europeans, you cant type '^'
- Allow cursor keys (left - right)
- On win condition show a small ascii art, not need to be animated.
- Add an option to go back to using pure curses. In particular, on non-English keyboards, people were unable to enter the "^" character.
- It might help if there were some kind of "right answer" or shortest regex necessary, since any puzzle can be solved in a very boring way using a long regex of alternation.
Tutorials
- For tutorial, level A: mention that '|' work as 'or' operation, and that spaces are significant.
- Tutorial, level outlaws the strings dont look like a good example, the current is more natural to describe as bra[gst]s; A better strings can be . to match: drinks, drunks, dranks . to not match: drinkz, drunkz, drankz
- Add more tutorial types -- ideas:
- Trying to parse a phone numbers given in different formats
- Validating email addresses
- Validating that every other sentence contains the word "monkey"
Distribution
- Debian / Ubuntu Packages (educational section or games section?)
- Try to get it listed on this site?
