My latest quick project was to write a basic scripting language for building cellular automata. The framework is built on javascript, and I made a nice little interface to go with it. As long as you’re using a browser that isn’t terrible, you can check it out here. All the code on that page except the utility functions is public domain, but please give credit where credit is due. If you end up examining the source, I apologize for the mess; I was trying to fit everything in one file, and not use jQuery or other libraries.
For those interested in writing your own automata, here is a quick guide to the syntax:
An automaton is composed of rules. Each rule is designated by a new line. Double slash (//) or pound (#) designate a commented line.
Each rule looks something like BLACK->WHITE: 1 = 2
BLACK is the type of cell that the rule applies to, WHITE is the type of cell that it will become. After the colon is a statement that must resolve to a single value, or “noun”.
Nouns can be strings, numbers, true/false, JSON arrays, “neighbors”, or any of the cardinal directions (lower-case). The noun “neighbors” is a special noun which is a JSON array with values equal to the types of the surrounding tiles (in eight directions). The special nouns “west”, “north”, “south” and “east” are equal to the type in that direction, or “NULL” if at the edge.
Nouns can be acted upon by the following “verbs”:
- =, >, < — Basic comparison operators. They behave like their counterparts in javascript (except for =, which is comparison, not assignment). — example: “1 > 2 = false” (returns true)
- or, and — Low-priority logic operators. These behave like || and && in most languages. Low-priority means they are evaluated after other verbs. — example: “true and false or true” (returns true)
- not — Inverts the boolean value to the right. If the value to the right is non-boolean, it is cast to a boolean just like ! in javascript. — example: “not true” (returns false)
- contains, isIn — Check if a value is contained in an array. The two verbs are identical except in the order of their parameters (“value isIn array”, or “array contains value”). — example: “[1,2,3] contains 0″ (returns false)
- count — Changes the noun on the right from an array to an integer. — example: “count [0,1,2]” (returns 3)
- ofType — Filters an array on the left to only contain the value on the right. — example: “[0,0,0,1,2,3] ofType 0″ (returns [0,0,0])
- echo — Makes a popup containing the value on the right. Does not change the data. This verb isn’t very useful, and can flood your browser with popups if you aren’t careful.
Verbs are evaluated from left-to-right, but you can use parentheses to change the order of operations. More examples can be found by loading the prebuilt automata.
I know the interface is a bit hard to use, but if you make anything (even if it’s pretty trivial) please leave a comment! You can export boards as well, so feel free to share interesting formations in Conway’s Game of Life, Wireworld, or others.
On a related note, this talk by Wolfram is not to be missed:

One Comment
Torrential Rain:
EMPTY->BLUE: north = BLUE or (north = CYAN and south = WHITE)
EMPTY->CYAN: north = CYAN or east = BLUE or west = BLUE
EMPTY->WHITE: (south = BLUE and (not (north = NULL))) or south = WHITE
CYAN->EMPTY: south = EMPTY or south = CYAN
CYAN->BLUE: north = CYAN or north = BLUE or south = WHITE
BLUE->EMPTY: south = EMPTY
BLUE->CYAN: south = CYAN or west = EMPTY or east = EMPTY or north = WHITE
WHITE->EMPTY: not (north = NULL)
WHITE->CYAN: north = NULL