🦋 Butterflies & Flowers

Butterflies
Speed
Butterflies: 15
Flowers: 8
🦋 Did you know?

🦋 Butterflies & Flowers

Colourful butterflies flutter between flowers using natural steering behaviour. Each butterfly independently seeks nectar, avoids others and performs a gentle, realistic wing-beating flight pattern.

🔬 What It Demonstrates

Steering behaviours — seek, arrive and wander — combined with a procedural wing animation. Each butterfly navigates independently using local perception.

🎮 How to Use

Click anywhere to plant new flowers and watch butterflies discover them. Observe how they approach, feed and move on to the next flower.

💡 Did You Know?

Real butterflies can see ultraviolet light, which reveals hidden patterns on flowers called "nectar guides" — runway lights pointing to the pollen.

About Butterflies & Flowers Simulation

This simulation models butterfly foraging behaviour using autonomous steering agents. Each butterfly independently applies seek, arrive, and wander steering forces to locate flowers, approach them, feed briefly, then move on — closely mirroring how real butterflies navigate a garden. The wing-beat animation is procedurally driven by a sinusoidal function, producing a lifelike flapping rhythm.

Steering behaviours were popularised by Craig Reynolds in 1987 and underpin modern game AI, robotics path planning, and crowd simulation. Butterfly pollination itself is critical to roughly one-third of global food crops, making it one of the most economically important ecological interactions studied today.

Frequently Asked Questions

What is steering behaviour and why do the butterflies move the way they do?

Steering behaviour is an algorithmic technique where each agent computes a desired velocity toward a goal and smoothly corrects its current velocity to match. In this simulation every butterfly independently calculates a force pointing toward its chosen flower, blended with a "wander" wobble force that prevents straight-line flight. The result is the organic, slightly erratic path real butterflies take in nature.

How do I interact with the simulation?

Click anywhere on the canvas to plant a new flower at that spot — a nearby butterfly will immediately redirect toward it. Use the Butterflies slider to add up to 40 individuals and the Speed slider to slow down or accelerate the scene. The Spring Burst button scatters 10 new flowers at once, while Clear Flowers resets to the original 8 blooms.

Why do butterflies pause on flowers before flying off?

When a butterfly closes within 20 pixels of its target flower it enters a "resting" state lasting 1.5 to 4.5 seconds — modelling the time a real butterfly spends drinking nectar with its proboscis. Once the rest timer expires the butterfly selects a new random flower and resumes flight. You can observe the slower wing-beat during this resting phase, which also matches real butterfly behaviour.

What mathematics drives the wing-beat animation?

The wing opening is computed as the absolute value of a sine function applied to a continuously incrementing angle: wingOpen = |sin(wingAngle)|. This produces a value that oscillates smoothly between 0 (wings closed) and 1 (wings fully spread) without ever going negative, giving a natural flapping appearance. The wing angle increments at a rate of 0.12 to 0.22 radians per frame, scaled by the global speed multiplier, so faster speed settings also produce a faster flap rate.

How do real butterflies find flowers in the wild?

Real butterflies rely primarily on colour vision that extends into the ultraviolet spectrum, allowing them to detect nectar guide patterns on petals that are invisible to humans. They also use olfactory cues — detecting floral volatile compounds from distances of several metres — and landmark memory to revisit productive patches. Monarch butterflies additionally use a time-compensated sun compass to navigate migration routes spanning 4,500 kilometres from Canada to central Mexico.

Is it true that butterflies taste with their feet?

Yes — this is a well-documented fact, not a myth. Butterflies possess chemoreceptors called contact chemosensilla on their tarsi (feet). When a butterfly lands on a leaf or flower these sensors detect sugars, salts, and plant compounds almost instantly, allowing it to decide within milliseconds whether to feed or lay eggs. This is why you will often see a butterfly "stamp" on a surface immediately after landing.

Who first described steering behaviours for computer animation?

Craig Reynolds introduced the concept in his landmark 1987 SIGGRAPH paper "Flocks, Herds and Schools: A Distributed Behavioral Model," which demonstrated that complex group movement emerges from three simple local rules — separation, alignment, and cohesion. He later formalised individual steering behaviours including seek, flee, arrive, pursue, and wander in a 1999 paper. Reynolds received a Scientific and Engineering Academy Award in 1998 for this work's impact on visual effects.

What other simulations are closely related to this one?

The Migrating Bird Flock simulation on this site uses the same family of steering behaviours but adds the three flocking rules (separation, alignment, cohesion) so birds move as a coordinated group rather than independently. Ant colony and bee swarm simulations extend the model with pheromone trails or waggle-dance communication. Crowd evacuation simulations used in stadium and building design rely on the same arrive and separation forces scaled to thousands of pedestrian agents.

How is butterfly-inspired movement used in robotics and engineering?

Micro air vehicle (MAV) researchers study butterfly wing kinematics to design flapping-wing drones that are more efficient at low speeds than fixed-wing aircraft. The unsteady aerodynamic effects — leading-edge vortices shed by the flexible wing — generate lift coefficients far above what steady-state aerodynamic theory predicts. Companies such as Festo have built demonstration robots (BionicFlyingFox, eMotionButterflies) that use on-board infrared tracking to replicate the same seek-and-avoid steering logic shown in this simulation.

What are the current open research questions about butterfly flight?

Active research areas include understanding how butterflies exploit "wake capture" — recycling energy from their own previous wing stroke — to minimise metabolic cost, and how the flexible, scaled wing surface dynamically deforms for passive aerodynamic stability. A 2020 study in Nature Physics showed that butterfly wings clap together and trap air in a cupped shape that catapults them forward far more efficiently than a rigid surface; the full fluid-structure interaction is still being modelled with high-resolution CFD. Neurological studies are also mapping how the tiny butterfly brain integrates polarised light, time-of-day, and magnetic field cues for long-distance navigation.