## Subset Sum Automata

WARNING: Contains brightly colored, rapidly flashing patterns. Best viewed in Chrome.

Subset sum automata are a family of cellular automata based on the subset sum problem. They're on a square grid like Conway's Game of Life, but instead of each cell being just on or off, the state is a nonnegative integer:

A subset sum automaton is defined by three integer parameters: a target offset, a reward, and a penalty. At each time step, each cell determines its target number by adding the target offset to its own value and checks its orthogonal and diagonal neighbors to see if any subset of them sum to this number. If such a subset exists, the reward is added to the cell. If not, the penalty is subtracted from the cell.

The above image comes from the +3/1/1 automaton, meaning the target offset is +3, the reward is 1, and the penalty is 1. Some examples:

The target number for this cell is 14 (11+3). There's only one subset of its neighbors which sum to 14 — the two 7s — but that's enough for it to earn its reward. This cell's value will increase by the reward (1) to 12 next generation.

The target for this cell is 15 (12+3), and there are four subsets of its neighbors that sum to 15: each of the 15s by themselves. This cell's value will increase by the reward (1) to 13 next generation.

The target for this cell is 16 (13+3) and, although there are subsets of its neighbors that sum to 15 and 17, there's no subset that sums to 16. This cell's value will decrease by the penalty (1) to 12 next generation.

Here's what it looks like running from a random seed:

Many subset sum automata have this chaotic, pulsating appearance. Clusters of low values tend to increase, since it's easy to sum them together to whatever target number you're trying to reach, and clusters of high values tend to decrease because they don't have access to smaller neighbors that get them to the exact value they need. In +3/1/1, the penalty is low enough that even when the values of the fan-like structures become too large and they begin to collapse, they stick around until the low-value medium around them aligns in such a way that they can grow again. Often, they don't collapse and instead grow forever, more on that later...

+3/1/1 doesn't look Life-like: there are no still lifes, no oscillators, and no spaceships. Still lifes aren't possible when cells are being either rewarded or penalized every turn; oscillators, though, we can do. Here's one with period 4 in +5/4/7:

And a c/2 orthogonal spaceship — the smallest possible, as far as I know — in +7/3/2:

Ships like this exist in all rules of the form +(2x+1)/x/x-1 for x >= 3. They are extremely simple, the gliders of subset sum automata, but nowhere near the most common in the scope of all rules. Much more common are c/8 orthogonal ships like this one from +12/5/9:

Despite its complexity — central cells iterate through 26 states before hitting zero for the last time — it's ubiquitous in its rule. Even more exotic ships, however, can be found with larger parameters. In +123/53/12, this strange, naturally occurring creature is mod 201 and moves diagonally at 25c/402:

Between the Life-like and the un-Life-like, plenty of variety can be found by fiddling with the target offset, penalty, and reward:

+9/5/4: blocky gradients that become less and less diverse until they ultimately die.
+1/7/6: a dense system of long-tailed spaceships.
+2/5/8: striated spacefilling regions surrounded by higher values that consume them.
+3/1/∞: a system of octagonal whorls that eventually stabilizes. A large-ish number can stand in for infinity.
+4/3/4: seeded with a 2x2 square of 2s, creates an expanding mandala-like pattern. Values stay within [0,8] with the occasional 11 for the first 226 generations, when finally two 11s have each other and a 4 as neighbors, beginning a cascade of higher numbers. Larger version capped at 8 here.
+3/5/7: a mixture of elementary replicators, spaceships, and divergent "still lifes."

You see the most interesting results when the reward and penalty are coprime; this way a cell can in the right circumstances come to have any value. Less interesting would be something like +10/2/4; odd-valued cells would always stay odd, and the evens would stay even. On the subject of undesirable parameters, it's easy to create rules that tend towards divergent patterns that, while nifty in their own right, are really just numbers getting larger in larger in a predictable way. Rules with a higher reward than penalty have a good chance of diverging (but won't always, as some of the rules above show). A low target offset also increases the odds of divergence. An example is +1/1/1, where a small seed of alternating 1s and 0s can grow adjacent cells to arbitrarily large values:

Which can "crystallize" a gradient of values that always have a neighbor one higher than themselves, which happens to be their target number:

Another type of divergent pattern never grows in population but nevertheless reaches arbitrarily large values, like this small square in +3/5/7:

Unlike their plane-devouring brethren, these bounded divergent clusters can be useful for pattern construction. They're nearly impossible to disrupt and their values are only ever fit for summing to their own target numbers, meaning that as far as their neighbors are concerned, they're worthless for summing to moderate values and might as well be locked at 0. This ability to "shut off" cells makes for readily controllable machinery, as in this +3/5/7 gun derived from naturally occurring patterns:

Speaking of devouring the plane, here's a quadratic replicator — reminiscent of something you might find in HighLife — running in +111/71/17:

It has an initial population of just 4: two 111s and two 148s. It replicates every 21 generations, but collisions hinder its growth leading to a self-similar population curve that trends towards a quadrupling of population with each doubling of generations. And here's maybe the weirdest thing I've found, this self-replicating spaceship:

It runs in a variant of +10/3/11 that allows each cell to use its own value as well as the values of its neighbors to sum to the target number. It occurs with high frequency in random soups using this rule. It begins life with a population of just 8 (which can be trivially reduced to 6) and 48 generations later emits a reflected copy of its earlier self. What makes this replicator somewhat unusual, I think, is that the "mature" version of it — what remains after it has emitted a copy — can no longer replicate.

I haven't yet found a variant of the subset sum automata that matches the simultaneous unpredictability and intuitiveness of beloved and better studied CA like Life. There are, though, plenty of avenues still to be explored. A programmatic search for patterns in the ash of random soups would find plenty of stuff I didn't have the patience to look for in my hand-tuned experiments. I've been surprised by how different a rule's behavior can be when you only use orthogonal neighbors, or throw in a cell's own value as in my replicator example. There are a couple of non-divergent rules that use a fixed target number instead a target offset, and the new sums you can find by permitting negative numbers are probably worth checking into... but ultimately, the only thing I know about subset sum automata is that they make some pretty cool GIFs.

+4/9/5, orthogonal neighbors only: checkered medium (unsurprising given the orthogonal restriction) chased by solid edges, gives way after thousands of generations to overlapping diamond whorls.
+6/3/5, orthogonal neighbors only: checkered regions that are strangely particular about where they spread. Sometimes there are little sparks that flit around.
+4/3/5, orthogonal neighbors only: spacefilling patterns that are quickly overtaken by ones that freeze them from the inside out.
+6/3/8, orthogonal neighbors and self: rainbow whorls that look like something from a continuous CA, despite ignoring even diagonal neighbors.
=7/1/1, all neighbors and self: as opposed to +7/1/1, cells in this rule are only looking for subsets of neighbors that add up to 7 exactly. Intersecting divergent veins spread across the plane.
+1/1/2, orthogonal neighbors only: seeded with a 2x2 square of 1s, creates a short-lived bloom with higher-value wake.
+10/7/4, orthogonal neighbors only: diagonal waves and several oscillators running on the same base reaction.
+9/4/7: reactions both symmetrical and asymmetrical, plenty of the "simple" spaceships found in lots of subset sum automata. Quite Life-like but without the tendency to settle.
+9/5/6: tons of fun spaceship types, including some waves.
+9/8/4: a wide variety of period-3 oscillators. Might have something to do with the shared factor between the reward and penalty? We may never know.
+13/11/15: tangled-up concentric shapes with shared gradients rippling throughout. Similarly to +9/5/4, eventually dies to a lack of numerical diversity.
=2/1/∞, orthogonal neighbors and self: collisions between geometric waves, leading to right-angled interference zones.
+13/1/0: even without a penalty, we can find rules that don't diverge. Seeded with values [0,2], the highest we ever get is 40.
+21/19/12: waves, orthogonal and diagonal spaceships, unusual oscillators.
thanks
Finn Sohst
Jonny Leahey