🐝 Bee Colony Behaviour Model

Secondary Biology 3–4  |  Explore how bees respond collectively to windy conditions

Agent-Based Model Each bee follows simple local rules. Complex colony behaviour emerges from these interactions — no single bee is in charge! Collective Behaviour The colony acts as a "superorganism". Individual bees respond to neighbours, producing coordinated group patterns. Thermoregulation Bees cluster tightly in wind to maintain hive warmth (~35 °C). Outer bees insulate inner bees, protecting the queen and brood. Waggle Dance Forager bees perform a figure-8 "waggle dance" to communicate the direction and distance of food sources to hive-mates. Beard Formation In strong wind, bees hang in a teardrop "beard" below the hive entrance. This shape minimises wind resistance while keeping the cluster stable.

💡 Click anywhere on the canvas to label that region.

Active (nurse/worker)
Guard bee
Peripheral bee
Direction of movement
Wind

🎛️ Simulation Controls

💨 Wind Speed 0.0 m/s
Higher wind → bees cluster more tightly (beard formation)
🧭 Wind blowing FROM
🐝 Number of Bees 80
Larger colonies cluster more effectively in wind
🔗 Cluster Strength 0.5
How strongly bees are drawn to the swarm centre
Waggle Dance
Show forager bees signalling food sources (figure-8 motion)
💡 Observation Try increasing Wind Speed to see how the colony reorganises into a "beard"!

📊 Cluster Compactness (%) — higher = tighter cluster

📊 Average Bee Speed — relative units

📐 Mathematical Model — Bee Cluster Evolution Equations

This simulation implements a Reynolds–Boids agent-based model extended with wind forcing and colony-level clustering, following the formalism used in computational ethology and swarm-intelligence research (Reynolds 1987; Bonabeau, Dorigo & Théraulaz 1999). Each bee \(i \in \{1,\ldots,N\}\) is an autonomous agent with position \(\vec{x}_i \in \mathbb{R}^2\) and velocity \(\vec{v}_i \in \mathbb{R}^2\), updated at each discrete time step \(t\).

1 · Equation of Motion — Euler Integration (\(\Delta t = 1\) step)

Agent positions are advanced by first-order (forward) Euler integration:

$$\vec{x}_i(t+1) \;=\; \vec{x}_i(t) + \vec{v}_i(t)$$

2 · Velocity Update — Superposition of Behavioural Forces

The velocity is updated by summing five independent force terms, then clamped to a maximum speed \(v_{max}\):

$$\vec{v}_i(t+1) \;=\; \mathrm{clamp}\!\Bigl(\,\vec{v}_i(t) + \vec{f}^{\,\mathrm{sep}}_i + \vec{f}^{\,\mathrm{ali}}_i + \vec{f}^{\,\mathrm{coh}}_i + \vec{f}^{\,\mathrm{wind}} + \vec{f}^{\,\mathrm{clust}}_i,\;\;v_{max}\Bigr)$$

3 · Neighbourhood Definition

Each bee perceives conspecifics within a topometric radius \(r_\mathrm{per}\). Two nested neighbourhoods are defined — a separation zone \(r_\mathrm{sep}\) and a larger perception zone \(r_\mathrm{per}\):

$$d_{ij} \;=\; \|\vec{x}_j - \vec{x}_i\|_2, \qquad \mathcal{N}(i) \;=\; \bigl\{\,j \neq i \;:\; d_{ij} < r_\mathrm{per}\bigr\}$$ $$\mathcal{N}_\mathrm{sep}(i) \;=\; \bigl\{\,j \neq i \;:\; d_{ij} < r_\mathrm{sep}\bigr\}, \qquad r_\mathrm{sep} < r_\mathrm{per}$$

4 · Separation Force — Avoid Crowding

Bees steer away from neighbours within the personal-space radius. This prevents physical crushing and maintains airflow — critical for colony thermoregulation:

$$\vec{s}_i \;=\; -\!\!\!\sum_{j \;\in\; \mathcal{N}_\mathrm{sep}(i)} \frac{\vec{x}_j - \vec{x}_i}{d_{ij}}, \qquad \vec{f}^{\,\mathrm{sep}}_i \;=\; \begin{cases} \alpha_\mathrm{sep}\,\dfrac{\vec{s}_i}{\|\vec{s}_i\|} & \text{if } \|\vec{s}_i\| > 0 \\[4pt] \vec{0} & \text{otherwise} \end{cases}$$

5 · Alignment Force — Match Neighbours' Heading

Bees steer toward the mean normalised heading of their local neighbourhood, producing the coordinated flight patterns seen in swarms:

$$\bar{\vec{v}}_{\mathcal{N}(i)} \;=\; \frac{1}{|\mathcal{N}(i)|}\sum_{j\,\in\,\mathcal{N}(i)} \vec{v}_j, \qquad \vec{f}^{\,\mathrm{ali}}_i \;=\; \alpha_\mathrm{ali}\!\left(\frac{\bar{\vec{v}}_{\mathcal{N}(i)}} {\|\bar{\vec{v}}_{\mathcal{N}(i)}\|} - \vec{v}_i\right)$$

6 · Cohesion Force — Steer Toward Local Centre of Mass

Each bee is attracted to the centroid of its neighbourhood, scaled by the user-controlled cluster-strength parameter \(\phi_s \in [0,1]\):

$$\bar{\vec{x}}_{\mathcal{N}(i)} \;=\; \frac{1}{|\mathcal{N}(i)|}\sum_{j\,\in\,\mathcal{N}(i)}\vec{x}_j, \qquad \vec{f}^{\,\mathrm{coh}}_i \;=\; \alpha_\mathrm{coh}\cdot\phi_s\cdot \frac{\bar{\vec{x}}_{\mathcal{N}(i)} - \vec{x}_i} {\|\bar{\vec{x}}_{\mathcal{N}(i)} - \vec{x}_i\|}$$

7 · Wind Force — Uniform Environmental Perturbation

A spatially uniform wind of speed \(v_w\) blowing in direction \(\theta_w\) exerts an identical translational impulse on every agent at every step:

$$\vec{f}^{\,\mathrm{wind}} \;=\; \alpha_w \cdot v_w \begin{pmatrix}\cos\theta_w \\ \sin\theta_w\end{pmatrix}$$

where \(\theta_w\) is the compass bearing of the wind direction (e.g.\ \(\theta_w = 270°\) corresponds to wind from the north, pushing bees southward).

8 · Colony Centroid Pull — Wind Resistance via Collective Clustering

Each bee is attracted toward the global colony centroid \(\vec{x}_c\). Crucially, this force grows with both wind speed \(v_w\) and cluster strength \(\phi_s\), modelling the empirically observed transition to tight beard formation in adverse conditions:

$$\vec{x}_c \;=\; \frac{1}{N}\sum_{k=1}^{N}\vec{x}_k, \qquad \vec{f}^{\,\mathrm{clust}}_i \;=\; \alpha_c \cdot v_w \cdot \phi_s \cdot \frac{\vec{x}_c - \vec{x}_i}{\|\vec{x}_c - \vec{x}_i\|}$$

The product \(v_w \cdot \phi_s\) ensures that clustering only intensifies when wind is actually present — reflecting the behavioural switch observed in Apis mellifera colonies.

9 · Speed Clamping — Biological Locomotion Limit

Individual bee flight speed is bounded by \(v_{max}\), preventing numerical blow-up and approximating metabolic constraints:

$$\vec{v}_i \;\leftarrow\; \begin{cases} \vec{v}_i & \text{if}\;\|\vec{v}_i\| \leq v_{max} \\[5pt] v_{max}\,\dfrac{\vec{v}_i}{\|\vec{v}_i\|} & \text{otherwise} \end{cases}$$

10 · Local Activity — Thermal Density Proxy

The activity level \(a_i \in [0,1]\) approximates local bee density and is used to colour-code agents (orange = high activity / warm; teal hollow = peripheral / cool). It serves as a visual proxy for the thermal gradient observed in real beard formations:

$$a_i(t) \;=\; \min\!\left(1,\;\frac{|\mathcal{N}(i)|}{N_\mathrm{act}}\right), \qquad |\mathcal{N}(i)| \;=\; \#\bigl\{j\neq i : d_{ij} < r_\mathrm{per}\bigr\}$$

\(N_\mathrm{act} = 11\) is a normalisation constant set so that a fully surrounded bee saturates at \(a_i = 1\). The colour mapping is: \(a_i > 0.6\;\Rightarrow\) orange \(\approx\) 35–38 °C (nurse/worker core); \(0.28 < a_i \leq 0.6\;\Rightarrow\) yellow–green (mid zone); \(a_i \leq 0.28\;\Rightarrow\) teal hollow (peripheral guard bees, \(\approx\) 20–25 °C).

11 · Observable — Cluster Compactness \(C(t)\)

The graph plots a real-time compactness metric: the mean distance of all agents from the colony centroid, inverted and normalised to \([0, 100]\%\):

$$\bar{d}(t) \;=\; \frac{1}{N}\sum_{i=1}^{N}\|\vec{x}_i - \vec{x}_c\|, \qquad C(t) \;=\; \max\!\left(0,\;100 - \frac{\bar{d}(t)}{1.8}\right)$$

12 · Model Parameters

ParameterSymbolDefaultDescription
Separation strength\(\alpha_\mathrm{sep}\)0.12Avoidance force magnitude weight
Alignment strength\(\alpha_\mathrm{ali}\)0.03Velocity-matching weight
Cohesion strength\(\alpha_\mathrm{coh}\)0.04Local centering weight
Wind coupling coeff.\(\alpha_w\)0.018Wind–velocity coupling constant
Cluster pull coeff.\(\alpha_c\)0.007Colony centroid attraction constant
Separation radius\(r_\mathrm{sep}\)22 pxPersonal space boundary
Perception radius\(r_\mathrm{per}\)65 pxNeighbourhood sensing range
Maximum speed\(v_{max}\)2.8 px/stepSpeed limiter (locomotion cap)
Cluster strength\(\phi_s\)[0, 1]User-controlled cohesion scale
Wind speed\(v_w\)[0, 10]User-controlled (m/s, scaled)
Wind direction\(\theta_w\)270°Bearing of wind FROM (degrees)
Activity normaliser\(N_\mathrm{act}\)11Neighbourhood saturation count

13 · Key References

  • Reynolds, C. W. (1987). Flocks, herds, and schools: A distributed behavioral model. SIGGRAPH Computer Graphics, 21(4), 25–34. https://doi.org/10.1145/37402.37406
  • Bonabeau, E., Dorigo, M., & Théraulaz, G. (1999). Swarm Intelligence: From Natural to Artificial Systems. Oxford University Press.
  • Seeley, T. D., & Heinrich, B. (1981). Regulation of temperature in the nests of social insects. In B. Heinrich (Ed.), Insect Thermoregulation (pp. 159–234). Wiley.
  • Gilad, T., & Shoresh, N. (2021). Collective thermoregulation of honeybee clusters: A model. PLOS Computational Biology, 17(2), e1008740.
  • Vicsek, T., Czirók, A., Ben-Jacob, E., Cohen, I., & Shochet, O. (1995). Novel type of phase transition in a system of self-driven particles. Physical Review Letters, 75(6), 1226.

🧠 Check Your Understanding — Swarm Behaviour Quiz

Answer all 6 questions, then click Submit Quiz to check your answers. Each question connects directly to the equations above — refer back to them if you are unsure!

1. The separation force \(\vec{f}^{\,\mathrm{sep}}_i\) is active whenever two bees are closer than \(r_\mathrm{sep} = 22\) px. What is its primary biological purpose in a real bee colony?
2. From the colony centroid pull equation: \(\vec{f}^{\,\mathrm{clust}}_i = \alpha_c \cdot v_w \cdot \phi_s \cdot \dfrac{\vec{x}_c - \vec{x}_i}{\|\vec{x}_c - \vec{x}_i\|}\) — if wind speed \(v_w\) triples while \(\phi_s\) and \(\alpha_c\) stay constant, what happens to \(\|\vec{f}^{\,\mathrm{clust}}_i\|\)?
3. The activity metric \(a_i = \min\!\left(1,\,\tfrac{|\mathcal{N}(i)|}{11}\right)\) is highest for bees with the most neighbours within \(r_\mathrm{per}\). These are rendered orange in the simulation. Where are they in the cluster, and what does this represent biologically?
4. The compactness observable is \(C(t) = \max\!\left(0,\;100 - \tfrac{\bar{d}(t)}{1.8}\right)\). If you increase wind speed from 0 to 8 m/s in the simulation, the compactness graph rises steeply then levels off. Which pair of forces creates this equilibrium — one pushing bees together and one pushing them apart?
5. In the model, the waggle dance is implemented by adding \(v_x \mathrel{+}= A\cos(\omega t)\) and \(v_y \mathrel{+}= A\sin(2\omega t)\) to about 8% of bees, producing a figure-8 trajectory. What does the real waggle dance communicate to hive-mates?
6. The alignment force is \(\vec{f}^{\,\mathrm{ali}}_i = \alpha_\mathrm{ali}\!\left(\hat{\bar{v}}_{\mathcal{N}(i)} - \vec{v}_i\right)\). In the Storm preset (\(v_w = 9\) m/s), most bees in the core align their velocity toward the hive. What emergent phenomenon does this model at the colony level, even though no single bee is "in charge"?

📊 Learning Analytics (Teacher view — tracks student interactions)