← Cellular Automata From First Principles

Regenerate After Damage

Persistence asks whether the organism can remain near its target.

Regeneration asks a different question:

after part of the state is destroyed, can local rules reconstruct the missing structure?

This is a much stronger test.

Damage the state, not just the image

If we erase only visible RGBA channels but leave hidden channels untouched, the model may retain a perfect invisible blueprint.

A harder test removes all channels inside the damaged region.

def damage(x, centre_y, centre_x, radius):
    yy, xx = torch.meshgrid(
        torch.arange(x.shape[-2], device=x.device),
        torch.arange(x.shape[-1], device=x.device),
        indexing="ij",
    )

    mask = ((yy - centre_y) ** 2 + (xx - centre_x) ** 2) > radius ** 2
    return x * mask[None, None]

(Verified: the disk interior is zeroed across all sixteen channels while distant cells are untouched.)

Now the missing region loses appearance and internal state together.

Put damage inside training

def train_regeneration_step(model, x, target):
    x = damage(
        x,
        centre_y=torch.randint(20, 44, ()).item(),
        centre_x=torch.randint(20, 44, ()).item(),
        radius=torch.randint(6, 14, ()).item(),
    )

    steps = torch.randint(32, 65, ()).item()

    for _ in range(steps):
        x = model(x)

    return x, F.mse_loss(x[:, :4], target)

Different locations and sizes prevent the rule from memorizing one fixed wound.

Train from mature states too

A useful pool now contains:

seed
partial growth
mature organism
recently damaged organism
recovering organism

This broadens the states from which the rule must return toward the target. The full damage protocol as a loop — note what gets damaged (all channels) and what gets compared (visible trajectory):

    flowchart LR
    M[mature state] --> D[damage: erase disk, all channels]
    D --> R[recovery rollout]
    R --> C[compare visible trajectory to target]
    C --> T[train step on recovery loss]
    T --> M
  

Damage families differ in what they test — record train/eval status for each:

Damage familyIn training?Channels hitRecovery demonstrates
random disk (train)yesall (no blueprint kept)trained repair instances
held-out rectanglenoallgeneralization of repair
edge/slice cutsevaluatedallboundary-condition repair
multiple small woundsevaluatedalldistributed vs focal repair

Measure recovery as a trajectory

Do not report only a post-damage screenshot.

def recovery_curve(model, damaged, target, steps=128):
    x = damaged.clone()
    curve = []

    for step in range(steps):
        x = model(x)
        curve.append(float(F.mse_loss(x[:, :4], target)))

    return curve

(Verified: the harness executes end to end. On an untrained identity baseline the curve is flat — no recovery, as it should be. A falling curve is therefore evidence about training, not about the harness.)

Useful metrics include:

peak damage error
minimum recovered error
steps to 50% recovery
steps to 90% recovery
final residual error

Test multiple damage geometries

A robust evaluation suite should include more than circles:

central deletion
edge deletion
horizontal slice
vertical slice
random rectangular cut
multiple small wounds
large catastrophic wound

The training distribution and evaluation distribution should be recorded separately.

Otherwise we can accidentally call memorized repair “general regeneration”. Hold out at least one geometry family entirely — if rectangular cuts were never trained on, they are the honest test.

Regeneration is evidence of corrective dynamics

A regenerating NCA is not simply replaying its original growth trajectory.

After damage, the remaining cells are in a state that may never have appeared during clean growth.

The rule must use local context to steer the system back toward an acceptable global configuration.

That is why regeneration is such an interesting property of local learned systems.

But do not overclaim

Successful recovery of one image under one family of masks does not establish biological regeneration, universal self-repair or general intelligence.

It establishes something narrower:

a learned local rule can maintain and reconstruct a distributed target morphology under specified perturbations.

One distinction matters for the chapters that follow: all of this measures the visible target image. Return to the target image is not restoration of the original internal state, because hidden channels may settle somewhere entirely new while RGBA looks right. Target-image recovery is not internal-state recovery, just as, in Chapter 35, mass recovery was not morphology recovery.

Whether repair survives a change of world is the next question, and the next chapter tests generalization beyond the training conditions.


Research

  • Mordvintsev, A., Randazzo, E., Niklasson, E. & Levin, M. — Growing Neural Cellular Automata (Distill, 2020). Experiment 3 is this chapter’s protocol: pool states damaged with random erasing circles during training, with recovery generalizing to unseen damage shapes (including rectangles) — plus the honest baseline that persistent models often regenerate weakly without ever being damage-trained. https://doi.org/10.23915/distill.00023