Some time ago I created this small script to convert numbers into patterns. I’m not going to explain how the script works in detail but it’s inspired on Stephen Wolfram’s Elementary Cellular Automatas which converts numbers like 30 into binary (00011110) and then interprets the digits as turning ON or OFF of 8 different basic rules (In that case there are 4 rules activated, rule 4, 5, 6 and 7) that define when to turn ON and OFF a pixel in the image.

Using this I can generate an infinite number of different patterns, the problem is that most of them are not really interesting and I have no time to check them one by one. That’s why in this post I explain how I tried to automate the process of finding out the most interesting/beautiful cellular automatas.

## Clusterization

My goal is to group the patterns by its beauty. I do this using a clustering algorithm based on features frequently attributed to beauty such as fractal dimensionality and compression efficiency. You can read more about these features here: Forsythe, Alex, et al. “Predicting beauty: fractal dimension and visual complexity in art.” British journal of psychology 102.1 (2011): 49-70.

### The Code

The full code is here but I also uploaded it into colab here so you can run everything from your web browser.

### Defining clustering attributes

First I define the previously mentioned attributes, fractal dimension (Code taken from here) and compression score (The weight of a raw tiff image over its weight compressed as a gif image).

### Clustering

There are several clustering algorithms, you can choose the one that best fits your use case.

In my case I ended up using Agglomerative Clustering which captures better the clusters generated by this dataset.

You need to specify the number of clusters, I tried with different numbers, at the end I chose 5 since it grouped them well from null patterns to crazy and chaotic ones.

## Results

Here I show some samples of each cluster. I sorted them from the simplest ones to the most complex. As you can see this method is useful to identify and discard uninteresting patterns such us the ones from the Cluster 0. It’s also useful to identify the most beautiful patterns, most of the best patterns I found are from the Cluster 3, the one with big complexity but not the biggest fractal dimension.

### Cluster 0: Null patterns

### Cluster 1 and 2: Almost Null Patterns

### Cluster 4: Too crazy and chaotic patterns