Sunday, July 20, 2014

Single Rotation rule, color shows flashing rate. Note that different spaceships have different colors.

In the binary cellular automata, cells can have only 2 states: ON and OFF.
This, monochrome images are the most natural choice to visualize such automata.
While informative, this visualization method produces somewhat dull images, especially when spaceships don't have easily recognizable form. My first idea to make it a bit fancier was to add some motion blur, emphasizing spaceships, and it worked well:

Single Rotation rule, with motion blur

Motion blur is effectively a low-pass filter applied to the original BW image. The next idea was to use a combination of several filters to make image more colorful. In my final application, 3 filters were used:

Low-pass filter, detecting cells that are constantly ON. This filter was assigned to the red channel.

High-pass filter, detecting cells that are flashing with period 2 (ON-OFF-...). Green channel was used for this filter.

Band filter (2-nd order), detecting cells, flashing with period 4. If was used for blue.

Together, these 3 filters produce images like this:
Single Rotation rule, with 3 different frequency filters for each color channel.

The picture above shows the Single Rotation rule, where random reactions produce many different kinds of spaceships. Interestingly, this colorization scheme allows to distinguish different spaceships by their colors. Finally, by applying these filters to the animation, you'll get the video above. In this video, the field is initialized with random block at the center (at first it appears red because of high cell concentration), and a vertical bar of 2 cells. In the "Single Rotation" rule, such bar of cells is an example of indestructible still life. After the simulation is started, dense random block starts dissipating, emitting multiple spaceships of different kinds. Single Rotation rule supports a lot of them!

For those who prefer higher resolutions, a HD version is available. Full screen and "HD" quality are recommended.

This colorization algorithm can be applied to any other cellular automata too. For example, here is Conway's Life. Note how still lifes are colored in red, and p2 oscillators are green:

Conway's Life, colorized using the same algorithm. See also HD version.

Sunday, July 13, 2014

The “Single Rotation” rule (it's my personal naming, it could be already known under the different name) is a very simple reversible cellular automaton, acting on a field with Margolus neighborhood. In this rule, each 2x2 block is rotated by 90° if it has exactly one alive cell. All other blocks remain unchanged. Despite its simplicity, this rule supports a multitude of different pattern types, and is especially interesting for me because of its spaceships. There are hundreds of spaceships with different periods.

Some spaceships of the Single Rotation rule. All spaceships on this animation are different.

Even simple observations showed that random reactions in this rule naturally produce more than ten different spaceships. Of course, ten was not enough so I tried to find more of them. This post is a digest of what I have found.

Spaceship search method

The method to search for spaceships was simple: take an empty field and put a random initial block in its center. During evolution, random reaction would produce multiple spaceships, which are then removed from the field and automatically classified. Typical parameters, used for search:

Field size: 128x128.

Initial random block size: 80x80.

Initial pattern density: 40%.

Simulation time: 30000 generations.

Several days of search brought a list of 205 different spaceships. To identify them, 108'720'436 moving patterns were analyzed. Here are the top 10 most frequent spaceships from this list:

Digesting the data

Size distribution

All discovered spaceships have 4 to 9 cells. The distribution of their sizes shows good agreement with power law:

Probability of the natural production plotted against spaceship weight. Dashed line is a best-fit power law distribution.

Power law approximation (dashed line on the plot) gives the following distribution:
$$P_n \approx \frac{0.679} {{17.55}^{n-4}},$$
where Pn is a probability of a randomly produced spaceship having weight n.
For 10-cell spaceships, this formula gives expected probability P10=2.33·10-8. Thus, the expected number of 10-cellers is 2 or 3, while none were discovered. Either I have bad luck, or the actual probability is lower, or maybe these spaceships have too large periods, and were not detected.

4-cell spaceships

Lightest spaceships have 4 cells and there are exactly 6 different spaceships of such size (I don't have a proof, but it should be easily provable by enumeration). Lightest spaceships have some interesting properties, mentioned in the previous post.

5-cell spaceships

Only 6 spaceships made of 5 cells were discovered during the search, all with significant hit counts. This suggests that there are no other 5-cell spaceships. From them, 2 are diagonal, and 4 are orthogonal. Curious coincidence: the most common diagonal 5-celler have a phase, that looks exactly as the Conway's Life glider.

The most common diagonal 5-cell spaceship, suspiciously resembling a phase of the Conway's glider

It moves by 1 cell every 15 generations, and its intermediate steps don't resemble glider at all, so this resemblance is nothing more than a coincidence. The other diagonal 5-celler is the R-pentomino.

Heavier spaceships

Number of different spaceships increases with weight, the experiment discovered 57 different 6-cell spaceships and 69 spaceships of 7 cells. Some of them are extremely rare, having probability less than 3.31e-07, which suggests that there are more spaceships, too rare to be discovered. The heaviest spaceships discovered are 10 different 9-cellers. Of them the most common one, detected 26 times, is $b2o$b3o$3bo$obo$2bo, fast diagonal spaceship with period 31 and velocity c/31.

The most common 9-cell spaceship and its evolution. Try it in the simulator.

Interestingly, record for the diagonal spaceships is achieved by the relatively heavy (6 cells) and rare (probability 0.08%) pattern. Are there any heavier moving patterns with smaller periods? I don't know (though intuition says no).

Highest period

While in the Conway's Game of Life naturally produced spaceships and oscillators commonly have small periods, in the "Single Rotation" rule there are numerous patterns taking extremely long time to start repeating.

Obviously, there is no upper limit for the spaceship period. But among known (to me) patterns the one with highest period is orthogonal 8-cell spaceship b3o$o3b2o2$bo$2bo. It takes whopping 9046 generations to move horizontally by 2 cells (thus its speed is c/4523).

Spaceship with the highest known period 9046.

Velocities

Fastest spaceships

As one may expect, the pair of the spaceships with the smallest periods also hold the speed record. Their movement speeds are: