Friendly turtles

Collective shapes emerging from individual behaviours.
April 28, 2018

The animation above is inspired by the ideas behind Heroes and Cowards, an agent based model created by William Rand and Uri Wilensky, although it’s a very distant alteration of this model. The code written to generate this animation is contained on the second-version branch of the project’s Git repository, which is hosted on GitHub.

The animation’s mechanism is simple: each black dot represents a turtle that can receive instructions and that possesses a certain behaviour. When the animation starts, each turtle is associated with two friends (two different dots in the group). Then, between each new frame of animation, each turtle walks in the direction of a point that is equally distant between its two friends.

The turtles thus have an identical individual behaviour, but because their initial positions are all different, a complex collective behaviour emerges from the aggregate of their actions: the group of turtles is collectively trying to form a single loop. When a new spiral is added in the scene, those new turtles are rapidly merging with the path of older turtles.

A variation

The animation below is built with the same mechanism, but each turtle is now represented by a small dot of black India ink. The code for this animation is on the master branch of the project’s repository. Also, the creation of new turtles is now controlled by hand, with gestures made on my computer’s trackpad.

Animation sheets

These short animations are also an opportunity to think about “animation sheets” (traditionally called exposure sheets or x-sheets), a crucial tool in the field of classical paper animation that could potentially be useful for algorithmic art.

It often happens, when I create algorithmic animations, that I want to add a precise event at a precise moment (to intervene, so to speak, in an ongoing process). This can be simply done with a conditional expression:

if (frameCount == 200) { intervene(); }

But an accumulation of too many of those conditional expressions can rapidly become unwieldy, and it’s interesting to think of alternative methods. The model below, named eventSheet, is an example of a simple mechanism that could potentially be useful in many situations.

let eventSheet = {
    10: function(){
        console.log("Ten frames!");
    },
    20: function(){
        console.log("Twenty frames!");
    },
    run: function(f) {
        if (this[f]) {
            this[f]();
        }
    }
};

function draw() {
    eventSheet.run(frameCount);    
}

But this construction is rather rigid; it would be interesting to be able to alter the duration of scenes more fluidly. Below is another rough idea for an eventSheet. It’s a bit strange, though.

let eventSheet = {
    slowScene: {
        t: () => 10, 
        f: function(){
            console.log("Ten frames!");
        },
    },
    fastScene: {
        t: () => eventSheet.slowScene.t() + 10,
        f: function(){
            console.log("Twenty frames!");
        },
    }
    // run: function(f) {
    //     if (this[f]) {
    //         this[f]();
    //     }
    // }
};

It could also interesting to define an eventSheet in a way that would make it possible to generate new ones algorithmically. I could algorithmically create sequences of events and then select the most interesting ones and save them in json files. An animation sheet could even be envisioned as something that has a genotype able to mutate and reproduce itself.

Scribbled notes

Would it be possible to make the spirals appear progressively in the first animation? If they were to appear progressively, maybe they would be too deformed and would never look like spirals. Or maybe when they are appearing, the new spirals could be disconnected from the other turtles. Could I have different groups of turtles between which “friendships” would be impossible?

In his course “Build towards
a question.”
Introduction to Agent Based Models, William Rand explains how important it is, while developing a model, to “build towards a question”, meaning that a model should answer a precise question (it is, after all, a scientific tool). Evidently, this point is difficult to consider while creating models for artistic goals—it can seem like we are not building towards questions but I think this is mostly a false impression. The questions are simply different and blurrier.

For example, if I want to create a sequence of various animated scenes that are similar in some ways to the ones above, and create a short animation film with them, I can ask myself: “What types of behaviours could generate ‘geometric dances’ with various sections that are coherently connected together?” Or: “How could colour be added to such dances? Would turtles of different colours move differently? If so, what could those differences be and what effects would they have on the resulting animations? Could turtles change colours?”

While watching those animations, Audio
considerations.
I’m also tempted to create new versions of them that would respond to sound. Different moments of a musical piece could be accompanied by various types of turtles, and the pitch and velocity of the notes could determine some properties of the turtles.

Context

This blog post is part of my research project Towards an algorithmic cinema, started in April 2018. I invite you to read the first blog post of the project to learn more about it.