Session 4: Behaviour & Agency

A system can change over time. A behaviour emerges when that change begins to respond to rules, conditions and its environment.
In Session 3 we controlled how values changed from one moment to the next. Today we give elements their own state and rules and allow them to respond.

The main progression is:
state → movement → response → feedback → multiple agents → emergent behaviour

🟠 EXPLAIN → 🟡 COLLABORATE

Begin the session in 🟠 EXPLAIN mode.

Use AI to:

First build a meaningful version of the system yourself.

Once you can explain the basic behaviour, move into 🟡 COLLABORATE mode.

You can then use AI to:

Do not begin by asking AI to generate a complete agent system or drawing machine.

Before collaborating, you should be able to answer:

What rules currently control the behaviour?

What we will explore

By the end of the session, you should be able to:

→ Examples and references

1. From change to behaviour

In Session 3 we created change by updating values:

x = x + 1;

The rule is simple and predictable.

The element always moves in the same direction.

A behaviour begins to appear when the next change depends on the current situation.

For example:

if (x > width) {
  speed = -speed;
}

Now the movement responds to the environment.

The important shift is:

change

value → new value

becomes:

behaviour

current state + condition → response → new state

2. Give an element state

An element can have several values that describe its current state.

For example:

let x = 100;
let y = 100;

let vx = 2;
let vy = 1;

x and y describe position.

vx and vy describe velocity.

Inside draw():

x = x + vx;
y = y + vy;

circle(x, y, 20);

The element now has a direction and speed.

Try changing:

Ask:

Which values describe what the element is, and which values describe what it does?

3. Respond to boundaries

Without another rule, the element eventually leaves the canvas.

Introduce a condition:

if (x > width || x < 0) {
  vx = -vx;
}

if (y > height || y < 0) {
  vy = -vy;
}

The element now responds to its environment.

A small rule creates a recognisable behaviour:

move → encounter boundary → change direction → continue

Change the response.

Instead of bouncing, an element could:

The boundary is the same.

The behaviour comes from the response.

4. Respond to something else

An element can respond to more than the edge of the canvas.

For example, calculate its distance from the mouse:

let d = dist(x, y, mouseX, mouseY);

Then use that distance as part of a rule.

For example:

if (d < 100) {
  // change behaviour
}

The mouse could become:

Do not think only in terms of interaction.

The important idea is:

Behaviour depends on relationships.

5. Feedback

A system has feedback when what happens now affects what can happen next.

Consider:

position → boundary → direction changes → new position → boundary...

The output of one moment becomes part of the input for the next.

This creates a feedback loop.

Feedback can be simple:

hit edge → reverse direction

or more complex:

move → leave trace → detect trace → change movement

Ask:

Feedback is one of the important differences between a fixed animation and a behaving system.

6. Introduce variation

Perfectly predictable behaviour can become repetitive.

Introduce a small amount of variation.

For example:

vx = vx + random(-0.1, 0.1);
vy = vy + random(-0.1, 0.1);

Or only introduce variation under certain conditions:

if (x > width) {
  vx = random(-3, -1);
}

Compare:

random movement

with:

a rule that occasionally uses randomness

These are not the same thing.

Try to keep the underlying behaviour visible.

Ask:

Does randomness create behaviour, or does it only disturb it?

7. From one element to many

A single element can already behave.

Several elements following the same rules can produce something much less predictable.

Imagine five elements that all:

Even if the rule is identical, different starting states can produce different trajectories.

This introduces an important distinction:

local behaviour
what one element does

global behaviour
what becomes visible when many elements act together

The individual element does not need to know what the final composition should look like.

8. Agents

For this session, an agent is simply an element that has:

It does not imply intelligence or consciousness.

A very simple agent might only know:

where am I?
which direction am I moving?
what happens if I reach an edge?

A more complex one might respond to:

Complex behaviour does not necessarily require complex agents.

9. Drawing machines

A drawing machine is a useful way to explore behaviour because movement becomes visible through the marks it produces.

Instead of drawing every line directly, design a system that decides how marks are made.

Your program might behave like:

The important shift is:

drawing an image

becomes:

designing something that draws

Build a drawing machine

Create a system with:

  1. a movement rule
  2. at least one response or condition
  3. a mark-making rule
  4. one source of variation
  5. a recognisable character

Examples of character:

Use the same machine to produce several different drawings.

→ Drawing machine references

10. Develop the behaviour gradually

A useful process is:

move → respond → vary → multiply → observe

Do not begin with many agents and many rules.

Start with one element.

Ask:

What does it do?

Then add one relationship:

What does it respond to?

Then add one consequence:

How does that response change what happens next?

Only then introduce additional agents or variation.

Useful questions:

What to keep for your journal

Document the development of the behaviour, not only the final drawing.

Keep:

For the system, try drawing a simple diagram such as:

move
  ↓
sense
  ↓
respond
  ↓
update state
  ↓
move again

If you move into 🟡 COLLABORATE mode, add a short note:

You do not need to include complete prompt histories.

Next session

In Session 5 we move from individual behaviours toward parameter spaces.

Instead of changing one system through trial and error, we will identify its important variables and explore families of possible outcomes systematically.

→ Examples and references
→ Drawing machine references
→ Notes on this session