A returning forager honeybee tells the colony where food is by dancing it. On the vertical comb she runs a short straight line while waggling her body side to side, then loops back and repeats, tracing a figure eight. The angle of that straight “waggle run” and its duration are the message. Karl von Frisch decoded the scheme in the 1940s and won a Nobel Prize for it (waggle dance; von Frisch). This sketch models it with the same primitives as the rest of these maps: a vector (Chapter 1), a sine oscillation (Chapter 3), and steering agents (Chapter 5) from The Nature of Code.

The dance encodes a 2D vector in polar form. The bearing is the angle \(\theta\) of the waggle run measured from vertical, and it equals the food’s bearing relative to the sun’s azimuth. Because the comb is vertical and dark, the bee substitutes gravity for the sun, transposing the solar angle onto the up direction: \(\theta_{\text{comb}} = \theta_{\text{sun}}\). The distance is carried by the waggle-run duration \(t_w\), approximately linear in range, \(t_w \approx \alpha\, d\) (roughly one second per kilometre, varying by subspecies). Decoded back to a location relative to the hive, with up aligned to the sun, \(\mathbf{x} = d\,(\sin\theta,\, -\cos\theta)\). During the run the body’s lateral offset is a sinusoid, \(y(s) = A\sin(2\pi f s)\), at a waggle frequency \(f \approx 13\) Hz. One correction matters: the sun’s azimuth drifts about \(15^\circ\) per hour, so a dance performed after a delay \(\Delta t\) is rotated to compensate, \(\theta \to \theta - \dot{\psi}\,\Delta t\).

Follower bees read the dance in the dark by pressing against the dancer, tracking the run’s angle against gravity, timing its duration, and sensing the airflow from her wing buzz. Each then leaves, re-references the real sun, and flies the reconstructed vector. No single follower reads it perfectly; the errors are noise, and many followers converge on the same patch because the average is close.

That structure is an embedding. The dance is an encoder that maps a rich situation, a food patch somewhere in a continuous landscape, to a compact fixed-format vector \(\mathbf{e} = (\theta, t_w)\); the followers are a decoder that reconstructs \(\hat{\mathbf{x}} \approx \mathbf{x}\) from that vector alone. It is the same shape as a learned vector embedding: compress an input into a low-dimensional vector that preserves the task-relevant relationships (here direction and distance), then let a consumer use only the vector, never the original scene. Nearby food produces nearby dances, so the space is metric and smooth; the whole colony shares one fixed codebook, an embedding space agreed upon by encoder and decoder; and averaging over many noisy readers denoises the estimate, the way ensembling does. The waggle dance is a natural embedding scheme, evolved rather than trained.

In the sketch below, move the mouse to place the food. The orange waggle-run axis tilts to the food’s bearing from the sun, its duration grows with distance, and the blue follower bees decode the vector and fly the reconstruction back out to the patch.