Tombstone
ComboLang
Mar 2005 · age 23
What it was
A tiny language for fighting-game combos, written in OCaml with camlp4 in a single Sunday afternoon. A combo is a regular expression over joystick inputs: a comma sequences inputs, a plus offers alternatives, a question mark matches any of the eight directions, a percent sign matches nothing, and an equals sign names the move. The sample defined a Shoryuken, an uppercut with optional diagonals, a full-circle attack written out in all eight rotations, and a throw. The compiler expands each pattern into every concrete input sequence it can match, then prints one C if statement per sequence, comparing slots of an input buffer and returning the move. The whole compiler is one expansion function and a printer: 189 lines in six modules, and 32 lines of generated C. It was built, run, checked in, and never revised.
Wins, for the age
- At twenty-three, in one afternoon, Jeff treated combos as regular expressions and compiled them to plain comparisons, finding on its own what M.U.G.E.N's command definitions (1999) had already found. A dirty monkey with one free Sunday taught a compiler to read a joystick.
- Ordered every check newest input first, so the game scans its history buffer backwards from the present, exactly the order such a buffer is easiest to keep.
- Got optional inputs for free from alternation with the empty pattern, with no special operator.
- Knew when to stop. The whole thing is about as much code as the idea deserved, a restraint this species rarely shows on a Sunday.
What it taught
- camlp4 grammars, and how little code a parser needs when the language is small.
- Expanding a regular language to its finite set of strings is a legitimate compilation strategy when the strings number in the dozens.
- Let the data decide the buffer order, not the other way round.
- Strip copied scaffolding. The banner, argument parser and commented pipeline came from another project and did nothing here.
Genealogy
Ancestors: none on record. One afternoon, one idea. Descendants: Kitchen Grill: a game scripting language, compiled, for the next engine.
Epitaph
Here lies ComboLang, five constructors and a cartesian product, which taught a joystick buffer to recognize a Shoryuken from the last input backwards.