In case it is not working for you (Since it is HTML5 canvas application, I did not pay much attention to the old browser support), here is a demonstration video.

Single Rotation rule is a very simple reversible cellular automaton that acts on a grid of cells, that are either dead (0) or alive (1). On each generation, the grid is divided into 2x2 blocks, and if the block contains exactly one alive cell, it is rotated by 90°. Thus "single rotation".

Cell tracking

Single Rotation rule preserves total number of the alive cells. Moreover, from the definition of the rule it is clear that it is possible to track the position of every individual alive cell (something that is impossible in the Conway's Game of Life, where cells born and die but not move). The simulator implements this idea.

Interpolation

On each generation, alive cells always move by 1 grid unit in some direction, making animation jerky. To make it smoother, this simulator interpolates intermediate coordinates of the cells, using Lanczos resampling.

Oscillation filtering

A single cell in the "Single Rotation" rule would constantly rotate with period 4. To make animation less annoying, a possibility to filter higher frequencies of the cell movement is added: "filter" setting. For example, when "filter" setting is 4, every oscillation with period 4 or less is replaced by the constant average value, and rotating cells visually stand still. Higher filter setting allow to cease oscillations of higher period. This is also done by Lanczos filter. Note that computational complexity is proportional to the the filter setting.

More information

Here are some of my other pages, where you can find information about the reversible cellular automata and Single Rotation rule.

Online simulator, uglier but more suited for experiments tool, where you can try your own patterns and rules.

Sunday, November 16, 2014

Have you enjoyed the awe-inspiring interactive flash animation by, Cary and Michael Huang The Scale of the Universe? If not, then do it before reading.
I enjoyed it a lot, and when few days ago I've seen it again in the G+ stream, an idea appeared in my mind: make a log-polar image of it.

Logarithmic polar coordinate system is a natural way to show things of different scale on the same diagram. Previously I've already used it to make a photographic image of the Earth: Logarithmic zoom at the Palace square, Saint Petersburg, and played with Google Maps: Log-polar system applied to Google Maps, so I already had some python scripts to do the thing. So I took the Python, and after a night of scripting and Gimp'ing got this! (Linked image is 800x18000 pixels)

Monday, November 10, 2014

Few more nice crystals grew today, this time it is Rochelle salt, or sodium potassium tartrate tetrahydrate:
$$NaK C_4H_6O_6 \cdot 4H_2O.$$

This compound is very well known among crystal growers because of its availability and ability to form big and clear crystals easily, so I won't say much about the growing process. The usual method with slow evaporation was used, with seed crystal suspended on a thin thread. The crystals on the photo grew only in 3 weeks.

Scale in centimeters.

Preparation

Rochelle salt can be prepared from the cream of tartar (unfortunately, it is not sold in my country, so I ordered some on eBay), and baking soda. Some instructions on preparation can be found on the Dom's crystal growing page (UPD: the site is down, but web archive have it), though I've simplified that recipe by using baking soda directly, without the heating step. Simply stir some cream of tartar powder in hot water and add small portions of baking soda until it stops fizzing. The reaction is:
$$ K H C_4H_6O_6 + NaHCO_3 \rightarrow K Na C_4H_6O_6 + H_2O + CO_2 \uparrow.$$

Transparency of the smaller crystal.

Safety

This compound is not toxic and, in fact, edible (but not tasty at all). I would not recommend consuming big quantities though.

More photos

Update: piezoelectric effect

Rochelle salt is well known for its property to generate electricity, when mechanical force is applied to the crystal: piezoeffect. Actually, the voltage is so big that it can make flash a light emitting diode, directly connected to the crystal.

Schematic of the experiment. Blue arrow shows direction of the mechanical force (hit).

I took 2 pieces of aluminum foil and tightly attached them to the crystal sides with thread and adhesive tape. Wires are connected to these foil pieces with another piece of the same tape, and a pair of LEDs in opposite direction is connected to wires.

Then, in the dark room, I can see dim but visible red flashes, when the crystal is hit along the vertical axis (blue arrow on the schematic). To protect crystal from smashing, I put a small wooden piece between the crystal and the "hammer" (actually teaspoon).

Photo of the experiment.

So cool. Not that I ever doubted the existence of this effect, but it is really pleasure to observe such effects on a crystals, grown "from scratch", at the corner of the table.

Fourier transform discovers periodicity in the source data, so applying it to some data points with nearly periodic patterns can often produce interesting results. For example, see Fourier transform of the Hilbert curve images. Still, the 3-dimensional look of the resulting image is something totally unexpected for me. Below is the same image, but rendered for a bigger fragment of the plane, 2048x2048.

Extensions

The idea can be extended by building the co-prime matrix not for integers but for some general integer sequence. This gallery contains some of the spectra, obtained for different sequences: Fibonacci numbers, \(n^2+1\), \(n^3+3\), \(n^2-n+41\) (Euler polynomial with many primes), partition function values and tribonacci numbers. Curious fact: the spectrum for the Fibonacci numbers is very similar visually to the original integers spectrum. But there is a difference, the image below shows two spectra superimposed, with yellow color for integers, and blue color for Fibonacci numbers.

Source code

The images above were generated by a simple Python script below. See it here, if the gist fails to load. To run it, you will need to install Numpy and PIL (Python Imaging Library).
The code itself is fairly straightforward, in fact, the most complicated part is the adaptive calculation of the brightness diapason.

That's because if the minimal number of alive neighbors required to the cell birth is 3 or more, then due to the geometry of the {5;4} tiling, a compact pattern can't grow "outside". This prohibits spaceships and possibility of infinite growth in such rules. However, if 2 alive neighbors are enough to create a new alive cell, then 2-cell pattern will grow infinitely, and the rule becomes "explosive". (However, some of the explosive rules support spaceships!)

Strobing rules

There is one exception though: "strobing" rules, where a cell spontaneously becomes alive if it has 0 alive neighbors, and dies, if all its neighbors are alive.

In the standard B/S notation, strobing rules on the {5,4} tiling have B0 and don't have Sa (where "a" stands for 10 neighbors). Under such rules, empty field becomes completely filled in the next generation, and then it completely dies out one generation later.

In these rules, if a pattern starts
with finitely many live cells on a background of dead cells, it will continue to
have finitely many live cells on a background of dead cells in every even step,
but in the odd steps the pattern is reversed: there are finitely many dead cells
on a background of infinitely many live cells

Naive simulation of such rules would either require making field finite or consume infinite amount of memory, but a simple trick could be used for effective simulation: consider evolution of the difference between the "flashing" background and the cells. This can be done by replacing one strobing rules with a pair of complementary stable rules without B0 part; where first rule is applied on even generations, and the second is on odd. For example rule B0157/S01 is replaced by the pair: B234689a/S23456789a, B59a/S359a.

It is possible to find such strobing rule, that the first rule of its non-strobing representation is "explosive", and the second is "stable". Careful choice of these rules allows to find that "edge of chaos" between stability and chaotic explosion, where interesting things could occur.

Below are some results of my small exploration of such rules. I used brute-force search in the rule space, searching for the rules that do not grow exponentially fast, but produce patterns away from the original random seed.

Rules with spaceships

Rule B0157/S01

The rule is stable, random initial patterns evolves into spaceships and few very rare oscillators. This is the first rule where I discovered a spaceship. The spaceship has 7 cells in one of its configuration. It has period 4 and velocity c/2.

The 332 spaceship, moving along the hyperbolic plane.

The spaceship virtually the only common pattern in this rule, but there are some rare oscillators too. One of them is 5-star:

Rule B0157A/S01

This rule is very similar to the previous. The same spaceship is present, but the 5-star oscillator has different period

5-star and its oscillator evolution in the B0157A/S01 rule.

Rule B01357/S01

This rule has a slightly different spaceship, made of 5 cells. Also, this rule is on the "explosive" side of the "edge of chaos". Though most small patterns are not growing infinitely, most big random patterns show gradual population growth. I has not identified a smallest pattern, that causes this behavior, probably, there are some natural replicators, puffers or rakes.

The 32 spaceship in the rule B01357/S01, period is 4, velocity is c/2.

5-star is stable in this rule, but there are different oscillators.

Rule B01357A/S01

This rule has the same 32-spaceship and several rare oscillators. Same as the previous, B01357/S01 shows slow infinite growth for large initial patterns. No minimal pattern with infinite growth identified.

Rule B01347/S013

The spaceship in this rule has different configuration, I dubbed it L-ship. It has period 8 and velocity c/2, same as the rest spaceships. This rule is stable, random initial pattern quickly evolves into some spaceships and very rare oscillators.

L-ship with period 8 and velocity c/2, in the rule B01347/S013.

Oscilators are rarely produced

One of the rare oscillators, 4-bar.

Rule B01367A/S013

This rule is stable, with c/2 spaceship which is the same as L-ship above, but because of the different intermediate steps, this spaceship does not coincides with its own mirror image.

L-ship in the rule B01367A/S013, same velocity c/2 and period 8.

Rules without spaceships

There also are some rules exhibiting slow growth, but without apparent spaceships or puffers. I haven't identified the mechanism of growth in them.

Rule B01568A/S013

No spaceships visible, but random initial patterns tends to grow slowly. Some oscillators are present.

Relatively common period-6 oscillator.

Rule B01568/S01

Same as above. No spaceships found, slow but steady growth, oscillators.

Rule B01478A/S01

Same as above. No spaceships found, slow but steady growth. Has 2 common oscillator patterns: 3-celled corner and 5-star.

Conclusion

Some properties are common for all of the explored strobing rules (that are the small part of the whole rule space).

"Static" patterns are rare. This is natural, because the patterns that appear static in the simulation (hence quotes), are actually inverting on each step, together with background.

The set of naturally occurring patterns is very limited. Usually, there is one or no spaceship with velocity c/2, and a few significantly rare oscillators. Some oscillators can be constructed manually, but almost never form naturally.

Discovered spaceships have clear resemblance. The same velocity c/2 regardless the period, the same method of moving by growing a block of 2 cells on each even generation.

Open questions

Some questions I don't have an answer:

Are there any other spaceship in these rules? Geometry of the hyperbolic plane seems to complicate formation of the "wide" spaceships, but "long" ones should be possible.

What pattern causes very slow but infinite growth in some of the rules? Some patterns are visible, but they are relatively big and hard to grasp.

Are there any significantly different rules with spaceships?

Software

To produce images and animations, self-written Pentagrid simulator was used. It is open source, and runs on every desktop platform supported by Java (Linux and Windows are tested). To run the program, download the pentagrid-0.x.jar file and run it with java -jar (usually double-click in Windows). Install Java runtime, if not installed (it is safe if you don't enable java plug-in in the browser).
The program has very basic GUI and controlled by the hot keys, so read the readme first.

Sunday, September 21, 2014

This post continues the previous one: Log-Polar coordinate system applied to Google maps. Now I made an attempt to extend the set of Google maps images with own photos, to make an image showing things at scales from millimeters to tens of thousands of kilometers.

Several coins on the bricks of the Palace square. Click to open it in full resolution (2692 x 8897).

The picture above is in logarithmic polar coordinates, with center at the specific point on the Palace square in Saint-Petersburg. I put a few coins on a bricks of the square to slightly animate the view and provide some scale reference.

On this image, vertical coordinate shows distance from the center of the coin. Horizontal coordinate corresponds to angle. Since the central coin is round, it looks like a yellow band at the bottom of the image.

It is composed from many sources. Maps were taken from the Google, and the close-up photos were taken by me and processed with Gimp to remove perspective distortion. To convert regular photos to log-polar coordinate system a self-written script: log-zoom (Github) was used.

Single image of reasonable size in the regular coordinates can't show details of such different scales, but it can be done with animation:

Animated zoom, obtained from the top image. To load GIF animation (8 Mb), click the image.

Source photos

Bricks on the square, arranged in a circular pattern.

Because bricks are arranged in circles, on the log-polar image they appear in straight rows, gradually decreasing as the scale of the image grows. Removing perspective distortion and adjusting the pieces in Gimp was a real pain...

Close-up view of the coins.

Three coins on the central brick. Center of the log-polar coordinate system is in the center of one of them.

Drawing of the central coin.

Finally, a design of the central coin. The text around the border says "50 years since first manned space flight".

Sunday, August 17, 2014

Table salt, or sodium chloride (NaCl) is a widely available chemical. It also forms nice transparent cubic crystals that are, unlike copper compounds, stable on dry air and not toxic. No surprise that almost every crystal growing book for kids recommends table salt as a good material to try. The instructions are innocuously easy: make a saturated solution, put a small seed crystal into it, and let it evaporate slowly. And voila!

But this almost never works. With some patience, you can make good transparent cubes... few millimeters in size. Often, you won't get even this. This method works perfectly with copper sulphate, alum, many other salts, but not with NaCl. I guess, those who write all these books are just citing other's words and never tried to follow their own instructions.

Those why tried to grow them, talk about salt differently:

... Small (sub-millimetre) clear cubes with smooth faces will grow on the bottom of your glass dish or jar, or on any thread suspended in the jar (see figure on the right). Larger crystals tend to develop hopper faces, or even more erratic growth habits ... Dom's crystal growing page

There are several factors that are causing the problem. Firstly, NaCl is prone to forming Hopper faces. With some substances like bismuth, the sometimes leads to a beautiful results, but not with table salt. You'll get dendrites, white crystalline crust, hollow flat rectangles - anything but not the transparent cubes, drawn in the books. NaCl also crystallizes too readily, using every smallest crack or dust particle as a seed.
Table salt crystals, grown in 7 months. The biggest one is about 2cm in size. Yellow substance is inclusions of the iron (III) chloride.

So, without some trick you'll never get big and (relatively) transparent crystals like ones at the photo above. I'd like to share a trick I have found by an accident. Not sure that it is the best method for growing NaCl crystals at home, but it worked for me, at least.

The trick was to use not the pure NaCl solution (as it is usually recommended), but a mixed solution of salt and iron (III) chloride FeCl3. The latter is a brown crystalline solid, highly soluble in water. It is used by amateurs in the printed circuit board production, and can be bought in the most shops for electronic hobbyists.

Growing NaCl crystals from the solution with FeCl3.

By some mysterious reason, presence of FeCl3 changes the way salt crystals grow: they are growing bigger and more transparent. Iron chloride itself is not going into the crystal, though occasionally, small portions of the ferrous solution are getting included in the transparent crystals, creating yellow spots inside.

The crystals are relatively transparent and clear.

Growing instructions

I used the following procedure, you could improve it according to your taste.

Prepare solution: dissolve some FeCl3 in the warm water. Solution must have intense yellow color. Then add salt in excess, and let it dissolve for several hours. If all salt dissolved, add more.

Prepare a seed crystal: take thin fishing line or some filament, put it in a drop of solution and let it dry. Some very small crystals will stick to the filament. Remove all of them except 1 or 2. (Instead of growing crystal on a thread, it can also be grown on the bottom of the container).

Fill a clean glass or plastic container with solution, and put the seed into it. Cover the solution (not tightly), to slow down evaporation and avoid dust.

Wait patiently. If salt crust is forming at the edge, don't let it grow too large, move your crystals to a new clean container. Also, crust can be dissolved by a drop or two of pure water. During the growth, concentration of FeCl3 grows gradually, so add small amounts of pure salt solution when appropriate.

Crystal properties

Salt crystals are hard and very stable on air, because they don't contain crystalline water (unlike the easier to grow copper(II) sulphate, which gradually loses transparency if exposed to the air). Their basic form is cube, though crystals growing on the bottom of a jar would be shorter along the vertical axis. Also, growing in the solution with FeCl3 is making their faces somewhat uneven, as if they are made of lots of smaller cubes.

Safety

Iron(III) chloride is not a toxic compound, though it can irritate skin on contact. Don't taste it though, technical grade chloride may contain significant amount of more dangerous impurities. It is also strong corrosive agent that can easily etch copper, iron and many other metals. Don't put it into a metallic container, use glass or plastic. Iron(III) chloride also makes permanent stains on clothes and tables, so handle it carefully.

Wash the crystals with pure saturated salt solution and wipe them well, and they will be entirely safe to handle.

Further ideas

I've discovered the effect of iron chloride accidentally, forgetting a bottle with solution opened for several weeks. When I found it again, it contained some transparent salt crystals, much bigger and cleaner than I would expect. Possibly, there are other compounds that work as growth stabilizers, what are them? My intuition suggests that other metal chlorides and glycerol are good candidates.

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: