Wednesday, November 5, 2008

Cellular Automata

The visualizations in Trancit are based on a mathematical process with the ungainly name of "cellular automata." For convenience, they are usually called "CA". What makes CAs interesting are the often compelling large-scale and ever-changing images that emerge from very simple descriptions. Here's how it happens...

Briefly, a CA exists in a grid-like space, like a chess board. Each square is called a "cell". Each cell has eight neighboring cells, usually referred to by the compass directions-- the cell above is called "North", the cell to the upper right is "Northwest", and so on. In Trancit, each pixel of the screen represent s a cell.

Along with space, a CA also has time. With each tick of a clock, each cell looks at some or all of its neighbors. Then the cell does a computation based on the state of its neighbors, and that computation defines the next state for the cell.

A Concrete Example
  1. A cell can be in one of two states: "on" or "off".
  2. If a cell is off, and it has three neighbors that are on, then the cell turns on during the next tick of the clock. Otherwise, the cell stays off.
  3. If a cell is already on, it stays on if it has two or three neighbors on, otherwise the cell turns off.
These three simple "rules" define a CA, called "Life", that is famous in computer science circles. You can see how these rules play out in Trancit, by selecting the visualization "Combinate" and clicking on the button labeled "a".

You'll see the "tumblers" of the combination move to 0, 3, 3, 2, 3. We'll talk about the "0" later. The the first two 3's define that a cell which is off will turn on if it has exactly 3 neighbors on. The last two numbers, 2 and 3, state that a cell that is on should stay on if it has between 2 and three neighbors on. Otherwise the cell should turn off.

With the three simple rules of life, all sorts of patterns form in pixels of the screen. It is not very colorful; just two "states" results in just two colors, with the "off" state being black. The interesting thing about "Life" is that it generates patterns that are much bigger than a single cell, and these patterns persist and evolve over a long time.

There's no way you would guess those patterns would exist just from looking at the three simple rules. But they do emerge, and other rules generate much different emergent behavior...

A Variation
Remember the "0" value we skipped over earlier? That defines the number of ticks that a cell must stay off before we can turn it on again. If you change this value from 0 to 1 for Life, you'll see that nothing interesting happens-- the patterns die out.

Clicking on the "b" button for Combinate, we see a new rule: "1 2 2 8 0". This describes the following:
  • "1": When a cell turns off, it can not turn back on for 1 tick of the clock.
  • "2 2": If a cell is off, and able to turn on, it can turn on when exactly 2 neighboring cells are on.
  • "8 0": Literally this says a cell can stay on only if it has more than at least 8, but no more than 0 neighbors on. This is an impossible condition to satisfy, so cells always turn off after being on.
When you run this rule, the behavior is much different from Life, and a lot more interesting (though still not very colorful).

Combinate represents one particular family of rules. The buttons "c", "d" and "e" are preset to some other interesting ones. You can change the values of each of the five numbers on your own, or pick a rule set at random with the "???" button. There are many in this family that are visually a lot more interstingin Life. There are other reasons why Life is interesting though,and if you want to know more then you might start here.

Sunday, October 26, 2008

Settings: The Trancit Control Room

The "gear" icon on the tool bar takes you to the "Settings" view, where you have detailed control over the capabilities of Trancit. If the visualization was playing, it will pause while you are in the settings view, and restart when you exit the settings view.

The Wheel
Visualizations: This is the largest control, and contains a list of the different visualizations available in Trancit. Each visualization is a unique math process, and generates a distinct graphical pattern. If you have been running with one visualization, such as "Mandala", and switch to another one, such as "Crystal Math", then you will see a gradual transition from one pattern to another.

Parameters: Some visualizations have numbers associated with them. These are known as "parameters." The default value for a parameter produces interesting behavior in the visualization. If you select a lower number for the parameter, the visualization will calm down. If you select a high number, the visualization will get more energetic. The up- and down-pointing triangles on the toolbar in the main display control these same parameters. This gives you a way to adjust the energy of the visualization without having to switch to the Settings view.

Some rules, such as "Crystal Math" and "Tie Dye" have no parameters, and the rule "Combinate" has five parameters. Well discuss "Combinate" more in another posting.

Beneath the wheel are two controls for randomly seeding the visualization. One is a slider titled "Randomization" and the other is a switch titles "Symmetric". Randomization means that random dots are placed in the display. This gives the visualization something to work with as a starting point, as well as a way to "spice things up" while a visualization is running. There are two ways to randomize:
  1. Double-tap when the visualization is displayed. This will clear the current image and randomize a blank screen
  2. Shake the iPhone (or iPod Touch) while the visualization is running. This will add random dots without clearing the screen.
The slider controls how many dots are added during randomization. The middle setting is a reasonable amount of randomization, tuned to the specific visualization. Setting the slider all the way to the right generates a lot of dots during randomization. Setting the slider all the way to the left generates no dots. This is handy if you want to hand your iPhone to someone else without disturbing the image.

The "Symmetric" switch controls how the random dots are placed on the screen. If this switch is set to "OFF", then the dots will be truly random. If the "Symmetric" switch is set to "ON", the the dots on the bottom will be a mirror image of the dots on the top, and the dots on the right will be a mirror image of the dots on the left. Symmetric randomization generates patterns that look more structured. Completely random patterns are beautiful too, just different from their more structured siblings.

Palette Shift
Trancit currently has eight different color palettes, and you select the one you want using the toolbar. A palette has a set of colors in a specific order (see the earlier posting on palettes). Shifting the palette maintains the order, but changes where the palette starts and finishes.

The slider: Let's take the "Earth" Palette as an example. Its colors are blue, brown, gray and green. If you move the "Palette Shift" slider from the default position on the left end, to the middle, then the colors in the Earth palette will now be ordered gray, green, blue and brown.

The order of colors makes a difference to the visualization, because every pixel is in a specific "state" at each point in time. The color palette assigns a color to each state. You can change the color palette without changing the state and get a very different image, as you may have experienced when you use the toolbar to switch palettes. Shifting the palette has a similar, but more subtle effect.

The "Auto" switch next to the Palette Shift slider makes this more interesting. If this switch is set to "ON", then the palette will shift automatically, by a little bit with each frame of the visualization. This adds extra energy to any visualization, and can sometimes change its character.

Saturday, October 25, 2008

Trancit Demo

This video demonstrates the features available in the Trancit Control Panel, accessible by clicking on the gear icon in the toolbar. Music by Larry Fast.

The video shows the iPhone (or iPod Touch) turned on its side so that the full frame can be used for the demo. The resolution of the visualization is much higher in Trancit than in this video-- you can try "Trancit Lite Edition" to see what full resolution looks like.

The toolbar appears and disappears with a single tap on the display. The triangles on the toolbar control the energy of the visualization. You can double-tap the screen any time to start a visualization fresh.

When the screen goes blank because a visualization has "died out", or if you shake your iPhone (or iPod Touch), the display will be "seeded" with a starting point - random dots. These dots are symmetric by default. As demonstrated at the end of this video, you can remove this symmetry, generating a new variation of each of the visualizations.

Monday, October 20, 2008

Demo Video

Here's a video of a new visualization coming soon. This is lower-rez than the actual application, of course. Enjoy!

Music by Zero 7

Tuesday, October 14, 2008

Capturing Images

If you have an image you want to save, you just need to press the buttons at the top and bottom of the iPhone simultaneously . You'll hear a camera sound and see a flash. The image will be saved to your photo library.

Before you take the image, you might want to pause the simulation, and make sure the toolbar is hidden. To hide the toolbar, just tap the screen once. Tap again t show the toolbar.

Here are a few images I captured recently:

Friday, October 10, 2008

Piloting Tracit - The Toolbar

The Toolbar: This is a set of controls at the bottom of the screen. If you don't see the toolbar, tap once and it will appear. If you do see the toolbar, tap once and it will disappear.

If you tap twice quickly, the screen will clear.

Start/Stop Simulation
: Trancit is a simulator, which means that it is either "running" (computing the next frame of the image) or "stopped" (leaving the current image unchanged). Click on this control to switch the simulation between stopped and running.

Wrap/Don't Wrap Edges: Trancit simulates a world where every pixel is a particle. Particles have neighbors, and the neighbors affect each other. At the edge of the screen, a particle is missing some neighbors, and this affects the images generated. This is called a finite, or "bounded" world. If you want to approximate an infinite world, you can use this control to switch to "wrapped", where a particle on the left edge of the screen will see a particle on the right edge of the screen as its neighbor, a particle on the top will see one on the bottom as its neighbor, etc. The box icon indicates a bounded world, and the "plus with arrowheads" indicates a wrapped world.

Increase / Decrease a "Parameter": In the settings you can choose different processes for generating patterns. Later posts will describe the settings interface in detail. Some processes have numbers you can change, which affect how the particles interact and evolve. These numbers are known as "parameters". Changing parameters will change the dynamics of the image; it can be interesting to change them while watching the pattern run.

For some pattern types, I've made one of the parameters controllable from the toolbar. You use the up-arrow to increase the value of the parameter, and the down-arrow to decrease it. If you hit the minimum or maximum value for the parameter, the appropriate arrow will become disabled. It will be re-enabled when you use the other arrow to move the parameter in the other direction. To see which parameter is being varied by the arrow, switch to settings, notice the parameter values, leave settings, use the arrows, and go back to settings to see which number changed.

Choose a color palette. Trancit currently has 8 color palettes. I'll add more in the future, but I need to think of a way to make it easy to find the palette you want without having to go through them all. The current palettes are shown at the right.

Info and Settings: Tapping the "i" button will generate a very brief version of the information in this post. Tapping on the gear sends you to the settings panel, which will be described in detail in an upcoming post.

Monday, October 6, 2008

What is Trancit?

Trancit is a simulation of a a category of mathematical processes that use simple rules to generate complex results. Traffic jams, stock market bubbles, and ecosystems form without any top-level design. In a similar way, swirls, pulsations, lattices and waves form in Trancit without any intentional design.

Trancit's images unfold from the interaction of simple particles with other nearby particles. While the resulting visual structures can take up the entire screen, they have their genesis simply in pixels interacting with the pixels next to them. I'll describe some of the specifics in future posts, for those that are curious, and I'll highlight parallels with the world around us, from atoms to brains to galaxies.

But the point of Trancit isn't the science-- it's the beauty of a dynamic, ever-changing and abstract work of art that you can guide or just simply watch. Perhaps even become entranced.