What you will learn
Simulate multiple agents and measure coordination under communication failures.
Before you begin: Robotics: estimation, planning & control; Reinforcement learning + SNNs
START WITH A QUESTION
Picture this.
Three people choose a meeting time by repeatedly moving their suggestions closer together. They might agree without a leader—but only if information can travel between them. A swarm needs a communication story as well as a local rule.
- Consensus
- Agreement on a specified quantity across agents.
- Neighborhood graph
- The links defining which agents can exchange information.
- Synchronous update
- Computing every next state from the same old-state snapshot.
Read for the idea first. Work through the numbers next. Try answering the questions before opening the explanations.
Name the collective goal
Consensus means reaching agreement on a quantity. Coverage means spreading across an area. Collision avoidance means keeping incompatible trajectories apart. These goals can conflict: a group that collapses to one point may achieve position consensus while failing coverage. Calling a pattern emergent describes a group-level outcome of interactions; it does not explain why it occurs. Start with a measurable goal and ask what each member can observe and communicate.
Understand the ideal averaging rule
Our example moves each scalar state a fraction α toward the global mean. With states [0, 1, 2], the mean is 1. At α = 0.5, the updates are [0.5, 1, 1.5]. Each agent halves its deviation from the mean. The average stays the same because all agents use the same snapshot and the deviations sum to zero. This is easy to verify and makes a good reference model. It assumes access to a global mean, so it is not by itself a decentralized implementation.
Now remove the impossible information
A real local protocol needs a neighborhood graph: who can hear whom? If one group cannot communicate with another, they need not agree. Delays and lost messages can mean agents are averaging different moments. A weighted-neighbor update can behave differently from the global rule, especially if weights or links are asymmetric. Stigmergy is another coordination route: agents alter the environment and others respond to those traces. It is different from broadcasting every internal state.
Where a neural controller fits
Each agent could use a neural policy to interpret local observations, while sharing only a few messages. A spiking representation is one option, not a requirement for collective behavior. Compare with simple local rules at matched bandwidth, sensing and noise. Log both individual failures and the collective metric. A beautiful flocking animation can hide agents that collide, lose communication, or consume a much larger message budget than the baseline.
SEE THE RELATIONSHIPS
From structure to behavior.
MAKE THE IDEA PRECISE
The mathematics.
| Symbol | Meaning |
|---|---|
| x_i | Scalar state of agent i |
| alpha | Mixing factor between zero and one |
| mean(x) | Mean of the states available to this illustrative update |
Build the equation, step by step
- Compute the mean of the current states and update all agents from that same snapshot. In-place sequential updates would define a different process.
- The formula moves each value a fraction α toward the mean. With 0 < α < 1, each new value lies between its old value and the current mean.
- For this all-to-all toy rule, the mean is preserved and deviations from it shrink by 1 − α. A genuinely local network requires a neighborhood graph and appropriate connectivity/weight conditions.
WORK THROUGH THE NUMBERS
Worked example
States [0, 1, 2] have mean 1. With alpha = 0.5, the next states are [0.5, 1, 1.5]. Disagreement decreases while the mean remains 1 in this ideal case.
A small Python experiment.
Python 3 · Standard library only · Synthetic educational example. Run this in your own notebook or a local file.
states, alpha = [0.0, 1.0, 2.0], 0.5
mean = sum(states)/len(states)
updated = [(1-alpha)*x + alpha*mean for x in states]
print(updated)Read the code as a story
The mean is calculated before any state changes. The list comprehension then creates a fresh updated list. If you change the original list sequentially while recomputing the mean, later agents see a different world from earlier ones. That order-dependent process is not the rule derived here.
Expected output
[0.5, 1.0, 1.5]
Change one quantity, predict the result, and then run the code again. Explain any difference before adding complexity.
Test your understanding.
Try it: Give one agent a stale mean. Does the mean-preservation argument still hold?
Self-check: Is computing a global mean a decentralized algorithm?
Not by itself. Every agent needs access to that mean through some communication mechanism. The example explains consensus arithmetic; a distributed implementation must specify what each agent can observe, how messages travel and what happens when links fail.
Where this model stops: Global averaging is an idealization; real local communication requires graph and delay analysis.
A research question: Does a neural local controller outperform simple rules under matched bandwidth and noise?
Record evidence in your mastery worksheet →PREDICT / TRY / EXPLAIN
Test a preserved quantity
Use paper, a calculator or the Python example. Write your prediction before checking the result.
- Apply two global-mean updates with α = 0.5 to [0, 1, 2]. Record the mean and the largest-minus-smallest spread each time.
- For a separate one-step experiment, let only the first agent use stale mean 0 while the others use mean 1.
- Compare the new mean with the original mean. State which assumption failed.
Compare with a worked solution
The two correct updates are [0.5, 1, 1.5] and [0.75, 1, 1.25]. The mean remains 1 while the spread shrinks from 2 to 1 to 0.5. With the stale value, the first update becomes [0, 1, 1.5], whose mean is about 0.833. The shared-snapshot assumption no longer holds.
CLOSE YOUR NOTES
Can you explain it back?
These questions test the reasoning, not just a remembered phrase. Say your answer out loud or write a sentence first.
01Does agreement prove the agents are correct?
Reveal the reasoning for question 1
No. They may agree on a biased or irrelevant quantity. Consensus is a coordination property, not a truth guarantee.
02Can disconnected groups necessarily reach one global consensus?
Reveal the reasoning for question 2
No. Without a path for relevant information to travel, separate components can retain different values. The protocol's connectivity assumptions matter.
TAKE THE IDEA WITH YOU
Three things to remember.
- Specify the collective objective before admiring a pattern.
- Global averaging is a useful reference, not a free communication primitive.
- Test timing, topology and message limits alongside local policies.
Next we bring perception, memory and planning together inside one system and ask how conflicting proposals should be resolved.
Continue to Part 20 →THE NEXT LAYER
Chapter depth map.
This introduction provides a first model. The following chapters are outlines for deeper future editions; their full treatments have not yet been published.
Local interactions
19.1 Rules and emergence · Outline
- 19.1.1 Swarm robotics and multi-agent systems
- 19.1.2 Alignment, cohesion and separation
- 19.1.3 Stigmergy and environmental traces
- 19.1.4 Distributed decision-making
- 19.1.5 Emergent patterns need quantitative descriptions
19.2 Communication and decentralization · Outline
- 19.2.1 Local neighborhoods and message budgets
- 19.2.2 Consensus and delays
- 19.2.3 Partial information and conflicting objectives
- 19.2.4 Faults, packet loss and unreliable peers
- 19.2.5 Compare centralized and decentralized control
Neural swarms as experiments
19.3 A small SNN per robot · Outline
- 19.3.1 Observation encoding and local policy
- 19.3.2 Shared parameters versus independent state
- 19.3.3 Local communication as input
- 19.3.4 Group objectives and credit assignment
- 19.3.5 Separate biological analogy from engineered coordination
19.4 Evaluate collective behavior · Outline
- 19.4.1 Coverage, task completion and collision metrics
- 19.4.2 Scaling agent count and bandwidth
- 19.4.3 Randomized starting conditions
- 19.4.4 Robustness to failed robots
- 19.4.5 Baselines with simple local rules
Read with the original sources.
These readings support the concepts and deeper investigation. The worked numbers and illustrations above are teaching examples.
Primary paper / preprint
Schulman et al. (2017): Proximal Policy Optimization Algorithms ↗
Read after policy gradients. Explain the clipped objective and assess results under matched environment and training budgets.