Ant Swarm

Multi-agent reinforcement learning · part three

Does a leader emerge when AI agents solve the piano-movers puzzle together?

Real ant groups have leaders: the few ants that know where the nest is. My swarm of AI agents carried the load through the maze with no leader in sight. So I looked for one, and then gave the goal to only one agent to see what happens. The others followed it, even to a fake goal.

This is part three. In part one one AI agent learned to carry a T-shaped load through two narrow slits, the puzzle that crazy ants solve in the lab. In part two five, then ten, agents learned it together. Each one pushed at its own point on the load, saw only its own small view, and never talked to the others.

Once the swarm worked, one question stayed with me: who is in charge? Does one agent end up leading, and the others follow? Real ant groups do have leaders. So I went looking for one.

The short answer: when every agent knows where the goal is, no leader appears. When only one agent knows it, that agent leads, and the others follow it, even to the wrong place.

01What leaders look like in real ants

When crazy ants carry food home, several of them hold the load at once. Most of them do not know which way the nest is. A few do, because they just joined the load and still remember the way. Those few pull toward the nest. The others do something simple: they feel which way the load is moving and push the same way. That amplifies the pull of the few who know. The research behind this is Gelblum et al., Nature Communications 2015.

So a leader, in ants, is an ant that knows something the others do not, and whose small pull the others amplify without knowing why.

In part two, my agents all saw the same thing. Each one knew where the load was, how it was moving, where the goal was, and how close the tips were to the walls. The only things that differed were where it held the load, and how the load moved right under its feet. Nobody knew more than anybody else.

So I asked two questions. First: did a leader appear anyway? Second: if I give the goal to only one agent, does it become a leader?

02Looking for a leader in the swarm

How would you recognise a leader in a group that never talks? I tried four ways.

  • Does someone act first? If one ant changes direction and the others copy it a moment later, that ant leads. The same test was used to find the leaders in pigeon flocks (Nagy et al., Nature 2010).
  • Does someone move the others more? I gave the load a small extra push at one ant’s grip point, as if that ant had suddenly pushed a bit differently, and watched how much the other ants changed their pushes in the next few steps.
  • Can the swarm lose someone? I removed one ant for a whole episode.
  • Does someone steer? I kept one ant’s push strength, but forced its direction along the load’s current motion, like a pure follower. If that ant was steering, the swarm should now fail.

Nobody acts first. In all four swarms from part two, every ant’s push agrees best with the whole group’s push at the same moment, not a few steps later. Nobody moves the others more. A small push at any grip point changes the other ants by about the same amount.

But the swarm is not a group of identical workers either. Roles did appear.

A lead pusher for each part of the maze. In the ten-ant swarm with one brain per ant, ant 10 pushes hardest in the corridor and in the goal room in 96 to 97 out of 100 episodes. In the start room it is ant 4.

Drivers and adjusters. Some ants push along the way the load is moving, and do most of the useful work. Others push across it and do almost none. In the ten-ant swarm, five drivers do 71% of the work, and three adjusters do 11%, while pushing about as hard as everyone else.

The ten-ant swarm crossing the maze, drivers in blue and adjusters in orange, each ant’s push drawn as an arrow.

Ants the swarm cannot lose. Removing one ant does very different things depending on which one. In the five-ant swarm, losing ant 4 still leaves 74% success. Losing ant 3, its mirror image on the other side of the small head, leaves 6%.

Success when one ant is removed, for each ant in each swarm
Success when one ant is removed, for each ant in each swarm.

Everyone on the heads steers. Making any one ant on the big or small head a pure follower costs most of the success. In the five-ant swarms it drops to 10% or less. The ants near the middle of the stem do less harm as followers, because a push near the middle cannot turn the load anyway.

Success when one ant is forced to follow the load's motion, for each ant in each swarm
Success when one ant is forced to follow the load’s motion, for each ant in each swarm.

One result surprised me. A blind follower is worse than no ant at all. In the five-ant swarm, removing ant 4 leaves 74% success. Making it a pure follower leaves 0%. A follower amplifies whatever the load is doing, including drifting into a wall.

One ant (orange) forced to follow the load’s motion; the swarm gets stuck at the second slit.

So, no leader. The roles belong to places on the load, not to individuals: they appear even when all ants share one brain, where the only difference between them is where they hold. One more thing makes places unequal: every swarm always takes the same route through the corridor, with the big head below the stem. The ant above and the ant below end up with different jobs.

That fits the ant story. Leaders come from knowing more. My ants all knew the same.

03Give the goal to only one ant

So I made it unequal. A new switch in the config, ants.informed, lists the ants that see the goal. The others get zeros where the goal would be. Everything else stays the same.

One detail makes this a clean test. The way through the two slits is the same for every goal. Every ant can learn that part. Only the last part, reaching a goal somewhere in the goal room, needs to know where the goal is. So the uninformed ants are not lost in the maze. They are lost only at the very end.

I trained four swarms of five ants, each with one brain per ant:

who sees the goal
nobodythe control
only the centre antan ant that can push but not turn the load
only ant 1, on the big headthe head that has to reach the goal
ants 1 and 2, both on the big head

and compared them with the swarm from part two, where all five see the goal.

04A surprise: the swarm that knows nothing still succeeds

I expected the swarm where nobody sees the goal to score about 4%. That is the chance that the load stops within reach of a random goal. It scored 48% on fresh episodes.

It found a way around its blindness. A success counts the moment the big head comes within 6 cm of the goal. Getting through the slits takes about 100 steps, and an episode lasts 500. So the swarm learned to cross the maze and then wander through the goal room until it happens to touch the goal.

No ant sees the goal; the swarm crosses the maze, loops through the goal room and touches the goal after about 200 steps.

That makes the success rate useless for my question. A swarm that searches and a swarm that knows can both succeed. What differs is how they get there.

05One ant that knows is enough

So I measured how directly each swarm reaches the goal once it is in the goal room: how many steps it takes, and how straight its path is. A straightness of 1 is a straight line.

The big head's path in the same four episodes: wandering with nobody informed, straight with ant 1 informed, and to the fake goal when ant 1 sees one
The big head’s path in the same four episodes: wandering with nobody informed, straight with ant 1 informed, and to the fake goal when ant 1 sees one.
who sees the goalsteps in the goal roomstraightness
nobody380.45
centre ant290.80
ant 1 only180.99
ants 1 and 2280.93
all five200.96

With only ant 1 informed, the swarm goes as straight and as fast as when all five know the goal. Four ants that see nothing move the load straight to a point they cannot see.

Only ant 1 (green) sees the goal; the swarm carries the load straight to it.

The centre ant helps, but less. It can push the load toward the goal, but it cannot turn it, and it is the big head that has to arrive.

06The fake goal: they follow it anywhere

Going straight to the goal is suggestive. But is ant 1 really leading, or do the others just happen to push that way? To find out, I lied to ant 1.

I showed ant 1 a fake goal: the real goal, mirrored to the other side of the goal room. The other four ants saw nothing, as always. If they follow ant 1, the swarm should go to the fake goal. If they have their own idea, it should not.

Only ant 1 (green) sees a goal, and it is a fake one; the swarm carries the load past the real goal to the fake one.

The load passes right by the real goal, and ends at the fake one.

Which goal the swarm reaches first when some ants see a fake goal
Which goal the swarm reaches first when some ants see a fake goal.
who sees the fake goalfake goal firstreal goal firstneither
all five (a check)94%6%0%
ant 1, the only one with a goal92%4%4%
ant 5, the only one with a goal88%12%0%
ants 1 and 2, both92%6%2%

One ant with a fake goal takes the whole swarm there in 92% of the episodes. When all five ants see the fake goal, it happens in 94%. So one informed ant steers the group about as well as five.

Even the centre ant, the one that cannot turn the load, leads the others to its fake goal in 88% of the episodes.

Only the centre ant (green) sees a goal, the fake one; the swarm carries the load to the fake goal.

07How the others follow

How do four ants follow a leader they cannot see or hear? Through the load.

Left: the ten ants from section 2 on the load, sized by their share of the work; right: pushes in the goal room when only ant 1 sees the goal
Left: the ten ants from section 2 on the load, sized by their share of the work; right: pushes in the goal room when only ant 1 sees the goal.

The right side of this picture is the swarm with only ant 1 informed. (The left side shows the drivers and adjusters from section 2.)

In the goal room, with only ant 1 informed:

  • Ant 1 pushes toward the goal, and becomes the hardest pusher in 47 of 60 episodes. In the swarm where everyone is informed, it is the hardest pusher in only 2 of 60.
  • Ant 2, its mirror image on the big head, cannot see the goal. It still pushes toward it just as strongly. It does that by pushing the way the load moves, and ant 1 is what makes the load move that way.
  • Ant 4, on the small head, does the same: it pushes along the load’s motion.

This is what real ants do. One ant knows, pulls a little, and the others amplify the motion they feel. I did not build this in anywhere. There is no reward for following, and no message between the agents. The swarm found it on its own, because it is the way to reach a goal that only one of you can see.

08When two leaders disagree

The last test: two informed ants with different information. Ant 1 sees the fake goal, ant 2 the real one.

Ant 1 (red) sees a fake goal and ant 2 (green) the real one; the swarm stalls before the second slit.
who sees whatfake firstreal firstneither
ant 1 fake, ant 2 real19%27%54%
ant 1 fake, ants 2 to 5 real27%35%38%

Mostly, the swarm gets stuck. With two informed ants in conflict, it reaches neither goal in more than half the episodes. And in about half of those it gets stuck already in the corridor, before the goal room, because the ants use the goal the whole way through the maze.

Even one lying ant against four honest ones stops the swarm in 38% of the episodes, and wins in 27%. The swarm never learned to outvote a wrong leader, because in training its informed ants never disagreed.

09What I learned

  1. No knowledge, no leader. When every ant sees the same thing, nobody leads. The ants still split into jobs: lead pushers, drivers, adjusters. But those jobs belong to places on the load.
  2. One ant that knows is enough. With only one ant seeing the goal, the swarm is as fast and as straight as with all five.
  3. The others follow the leader anywhere. Show that ant a fake goal, and the swarm goes there, 92% of the time.
  4. Following is learned, and it works through the load. The uninformed ants push the way the load moves. That is exactly the rule of real ants, and nobody told them.
  5. Blind following has a price. A pure follower can be worse than no ant, and two leaders who disagree mostly get stuck.
  6. Check what "success" measures. A swarm that knows nothing still reaches the goal about half the time, by searching. Only the path shows who knows.

Cite this post

If this write-up is useful in your work, you can cite it as a blog post:

@misc{kakooee2026antswarm3,
  author       = {Kakooee, Reza},
  title        = {Does a Leader Emerge When {AI} Agents Solve the Piano-Movers Puzzle Together?},
  year         = {2026},
  howpublished = {\url{https://rezakakooee.github.io/ant-swarm-leaders/}},
  note         = {Blog post, part three. Code: \url{https://github.com/RezaKakooee/ant-piano-movers-rl}}
}