An ant colony where each ant is an active inference agent — it minimises variational free energy through perception (sensing pheromone gradients via its antennae) and action (moving through the environment and depositing pheromones).
The ants do not follow pre-programmed foraging rules. Their coordinated behaviour emerges from each individual minimising its own expected free energy — balancing epistemic value (exploring unknown terrain) against pragmatic value (following established trails toward food).
Level 1 — Individual blanket. Each ant maintains a statistical boundary between its internal states (beliefs about food locations) and the external world (the actual pheromone field). The dashed circle around each ant represents this boundary. Its sensory states are antennae sampling pheromone; its active states are movement and pheromone deposition.
Level 2 — Trail blanket. When multiple ants reinforce the same path, a trail-level Markov blanket emerges — shown as a green envelope around strong pheromone corridors. The trail is a stigmergic generative model: a shared belief structure written into the environment itself.
Level 3 — Colony blanket. The nest, all trails, and all foraging zones form a colony-level boundary. Toggle the colony blanket layer to see this macro-scale agent — a superorganism that maintains homeostasis through collective free energy minimisation.
Pheromone trails are a form of niche construction — the ants modify their environment, and the modified environment then shapes future behaviour. The pheromone field is the colony's generative model, externalised into the world.
The trail persistence slider controls how quickly this shared belief structure decays. Fast evaporation forces continuous re-exploration. Slow evaporation creates rigid, habitual pathways — the colony equivalent of high precision.
1. Set Πindividual to maximum. Watch each ant lock rigidly onto the nearest trail.
2. Now set epistemic drive to maximum. Ants begin exploring broadly, seeking information rather than reward.
3. Click "Remove a food source" while trails are established. Watch the colony's belief update propagate through pheromone decay.
4. Toggle the colony blanket layer to see the macro-scale boundary emerge.
5. Toggle sensory fields — the heatmap shows the colony's collective perception. Amber regions contain pheromone (information!); teal regions are sensed but empty. Notice how the heatmap is densest along trails — that's where shared sensory niches form.
6. Toggle collaboration network — amber links appear between ants that share the same trail, heading the same direction. This is generalised synchrony: the network shows where group-level Markov blankets are forming in real time.
7. Watch the soldiers (darker, larger ants) patrolling the nest perimeter. They use the same free energy minimisation — but their prior preferences encode "safety" instead of "food."
8. Check the nest webcam (bottom-right). The queen, larvae, food stores — these are the colony's internal states that all external foraging behaviour ultimately serves.
The soldiers demonstrate one of Active Inference's most powerful insights: the same inference algorithm produces completely different behaviour when the prior preferences change.
A forager's C-vector encodes "I prefer to observe food at the nest." A soldier's C-vector encodes "I prefer to observe safety at the nest perimeter." Both minimise expected free energy — but the resulting policies are utterly different. One explores the world; the other guards the boundary.
This is how biological role differentiation works under the FEP: not by switching algorithms, but by switching generative models.
The queen embodies the slowest timescale in the colony's hierarchical generative model. She doesn't forage or patrol — she represents the colony's deepest belief about its own continuity. Her presence in the queen's chamber is the attractor state that all other behaviour serves.
In hierarchical terms: fast legs (milliseconds) → medium trails (minutes) → slow colony strategy (hours) → the queen's reproductive cycle (weeks). Each level contextualises the one below.
Each ant selects its movement policy by minimising expected free energy G(π):
Epistemic value measures how much information a policy will yield. Pragmatic value measures how likely a policy leads to preferred outcomes.
Precision weights prediction errors: high-precision errors drive stronger belief updates. An ant with high precision that encounters unexpected pheromone absence will make a dramatic course correction.
Level 1 (fast): Individual ant movement — step-by-step direction changes.
Level 2 (medium): Trail formation and dissolution — emerges over many ant-trips.
Level 3 (slow): Colony-level foraging strategy — the macro-pattern of which food sources are exploited.
Under Active Inference, there is no exploration-exploitation dilemma — both drives emerge from the same objective function. The epistemic drive slider modulates the relative weight of information gain.
Toggle Sensory fields to see a heatmap of the colony's collective sensory coverage. Each ant contributes a forward-biased sensory radius — the region its antennae can sample. Where multiple ants' fields overlap, the heatmap brightens, showing shared sensory niches.
The colour encodes what the ants sense: amber regions contain pheromone (information flowing inward through the Markov blanket), while teal regions are sensed but empty (no prediction error signal). This directly visualises the Active InferAnts principle that agents have only local sensory access to their immediate surroundings.
Dense sensory overlap on trails shows why group-level Markov blankets emerge there: multiple agents sharing the same sensory niche become mutually predictive.
Toggle Collaboration network to see which ants have become mutually predictive. A link appears when two agents share three properties simultaneously: spatial proximity, co-occupation of the same pheromone trail, and aligned heading direction.
This implements generalised synchrony — when agents share similar generative models and sense each other (here, indirectly via pheromone), their internal states converge. The link strength is the product of these factors, which is equivalent to precision-weighted coupling.
When enough links form, the connected ants constitute a group-level agent with its own emergent Markov blanket — the same mechanism that produces trail-level blankets, operating at the agent-interaction scale.
Parr, T., Pezzulo, G., & Friston, K. J. (2022). Active Inference: The Free Energy Principle in Mind, Brain, and Behavior. MIT Press.
Friedman, D. A., Tschantz, A., Ramstead, M. J. D., Friston, K., & Constant, A. (2021). Active InferAnts: An Active Inference Framework for Ant Colony Behavior. Frontiers in Behavioral Neuroscience, 15, 647732.
Saund, E., & Friedman, D. A. (2023). A single-pheromone model accounts for empirical patterns of ant colony foraging previously modeled using two pheromones. Cognitive Systems Research, 79, 1–18.
Bruineberg, J., Rietveld, E., Parr, T., van Maanen, L., & Friston, K. J. (2018). Free-energy minimization in joint agent-environment systems: a niche construction perspective. J. Theoretical Biology, 455, 161–178.
Palacios, E. R., Razi, A., Parr, T., Kirchhoff, M. D., & Friston, K. J. (2020). On Markov blankets and hierarchical self-organisation. J. Theoretical Biology, 486, 110089.
Thestrup Waade, P. et al. (2025). As One and Many: Relating Individual and Emergent Group-Level Generative Models in Active Inference. Entropy, 27(2), 143.
Developed by Alexander Sabine (Active Inference Institute, Board of Directors). Interactive demonstrations at temporalgrammar.ai.
Contact: Alexander@activeinference.institute