Elementary Automata
Imagine a bunch of cells lined up in a row, some are set to 1, some to 0. Each cell has a neighborhood consisting of itself, the cell to its left, and the cell to its right. And there's a concept of time (just like in Conway's Game of Life), where whenever time advances, each cell looks at its neighborhood and decides what its next state should be.
This setup is called an elementary cellular automaton.
How the cells decide what their next state should be is captured in the rule, which is basically a lookup table. You line up the cell's left neighbor, then its own value, then its right neighbor, and look up what the next state should be, based on that.
Here's the lookup table for Rule 30. (That's the rule pictured in the diagram above when you first load the page.)
| Current | 111 | 110 | 101 | 100 | 011 | 010 | 001 | 000 |
|---|---|---|---|---|---|---|---|---|
| New | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 0 |
So if a cell starts out alive (1), with an alive cell to its left and a dead (0) cell to its right, then its current state is 110 (first 1 for the alive cell to its left, second for the cell itself being alive). We look up "110" in the table, and its entry is "0", so our new value for this cell will be 0, or dead.
There is the question of what to do at the edges. My preferred approach is to pretend that we're on a circular strip, so rightmost and leftmost cells are next to each other. (If you want to see what I mean, change the "Rule" in the diagram at the top of the page to "2", and make sure that "Starting Points" is "One Point", and you'll see the one living cell drift right past the end of the screen and reappear on the left.)
Oh, and as for why it's called "Rule 30"... notice how the "New" row is just eight 1's and 0's? Well if you line them up like "00011110", then that's how you write 30 in binary. Notice how, as you change the rule in this diagram, the 1's (darker cells) and 0's (white cells) in the rule chart at the bottom also read like a binary number.
Since those eight values completely characterize how the rule works, that means that there are 256 (2 raised to the 8'th power) possible rules, and you can completely capture the rule with a single number from 0 to 255.
Well, there are 256 possible rules, but some of them behave basically the same. If you count rules as the same if they differ either by flipping left and right, or by swapping all 1's and 0's, then there are 88 distinct rules. If you want to see what I mean, go up to the top diagram and see what happens with rules 30, 86, 135, and 149.
Here's a visual to show how the rule gets applied. It defaults to Rule 30, but you can change it to another one if you want (anything from 0 to 255 is fair game). You can also add the next generation of cells to see how a rule builds on itself through more than one generation.
That row of palomino-like things at the bottom is the lookup table. For rule 30, it captures the same thing as the table above, just using light and dark cells instead of ones and zeroes.
I find this stuff so fascinating because even though the rules are so simple and in a sense, so similar to each other, there's a huge amount of variety in how they behave. Play around with the diagram at the beginning of the page and you'll see what I mean. You can change the rule, and also the starting cell layout, so you can see what happens if the world starts out with one cell alive and the rest dead, and also what happens if the world starts out with a kind of random assortment of cells.
It's only kind of random because I wanted to be able to look at how the same "random" cell layout was changed by different rules, so it won't change between page reloads or re-renders. Sort of like decided by fair dice roll.
Here are a couple of rules that I find particularly fascinating:
- Rule 18. I like it for its simplicity. If you start from zero and count up, it's the first one that forms a Sierpinski Triangle if you start from one cell, and it looks kind of like one that got printed on a dot-matrix printer.
- Rule 30. This one is so utterly chaotic that even starting with a single cell, it devolves into unpredictable chaos. Rule 45 is also like that, although the chaos of Rule 45 looks very different.
- Rule 110. It also looks kind of chaotic at first, even from one starting cell, but if you zoom out, it actually looks more like it does something a bit more orderly. It forms a kind of an intricate background, and a bunch of shapes that move around on that background. This one's been studied pretty extensively, and it turns out that if you use enough cells, you can run a computer in a Rule 110 world.
- Rule 73. This one fills itself with all sorts of fascinating shapes. If you start with one cell, you can see small background regions of stripes, dots, and tiny spaceship things that stay stable until they get disrupted by other, more complicated shapes. If you start with a random layout, you also see walls form that create little isolated hallways, each of which has its own collection of little spaceships and dots that bounce back and forth.
- Rule 169. The first version of this that you'd run into is actually its complement, 106, which looks really cool if you start from a random cell layout; kind of like raindrops streaked across a windshield (so does 169, for, well, the same reason). But I like 169 because when you start with a single cell, you get something that looks kind of like a Sierpinski Triangle that got hung up to dry on a windy day.
- Rule 57. I like this one because it forms a very simple, but non-trivial "law of physics". If you start from a random cell layout, you can see a checkered background form, and after the turbulence of the first few generations calms down a bit, you can also see a bunch of "particles" running around; white particles to the right and black to the left (Rule 99 has them going the other way). If the particles bump into each other, then they annilihate. This is so deeply, amazingly cool to me because the rule itself doesn't say anything about particles! Starting only with cells that are just doing their best to figure out whether to be 1 or 0 in the next generation, suddenly particles appear and start moving around! How cool is that?
- Rule 54. My personal favorite: If you start this one with just one cell, then it forms a triangle filled with alternating black and white tetris pieces. And if you start with a random assortment, then you get a background that looks very much the same, except that there are also a bunch of triangular pieces that come into existence and hang around.... and move! They'll stay put for a while, and then flicker a little bit and then move a cell or two to the left or the right. Oh and also occasionally a little triangle comes into existence for a little bit and then disappears, and if you blur your vision just so, you can almost see the larger triangles sending messages to each other. What in the world is going on here?
Play around with the rules. Which ones seem the most interesting to you?