An interactive flocking simulation — glowing fish-like boids that steer, school, and drift through a wind field you can tune live.
Built by cm30w as a small canvas experiment in classic boids rules (separation, alignment, cohesion), plus a 3×3 wind vector field.
simpleboid is a browser-only demo: open the page, watch ~100 agents move, and drag sliders to feel how each force changes the flock. No install, no build step — just HTML, CSS, and vanilla JavaScript.
Each boid:
- Separates from neighbors that get too close
- Aligns with nearby headings
- Coheres toward the local group center
- Feels wind from whichever zone of the 3×3 field it is in
Wind directions are randomized on load. Refresh the page anytime to reshuffle the wind field and reset the scene.
- Clone or download this repo.
- Open
index.htmlin a browser, or serve the folder locally:
python3 -m http.server 8000- Visit
http://localhost:8000.
That’s it — the simulation starts immediately.
The layout has two parts:
| Area | What it is |
|---|---|
| Left — Boid Controls | Sliders that update flock behavior in real time |
| Right — Canvas | The live simulation (fish-shaped boids + faint wind particles) |
Leave the sliders alone for a few seconds. You should see loose groups form, break apart, and drift as boids react to neighbors and wind.
Drag Speed up (toward 600) for a frantic school, or down (toward 15) for a slow drift. Speed sets max velocity; minimum speed stays at about 25% of that so boids never fully stop.
Try these one at a time so the effect is obvious:
- Raise Cohesion → boids pull into denser clusters.
- Raise Separation → they keep more personal space and look “jitterier.”
- Raise Alignment → nearby boids point the same way and travel as streams.
- Perception Radius — how far a boid looks for neighbors (cohesion & alignment). Larger = bigger, smoother groups.
- Separation Distance — how close is “too close.” Larger = more spacing even inside a flock.
Increase Wind Impact. Blue particles hint at local wind; boids in each zone get pushed in that zone’s direction. High wind + high speed makes the flock feel turbulent.
Refresh the page to:
- Randomize wind zone directions again
- Restore default slider values
- Respawn boids in new positions
| Control | Range | Default | What it does |
|---|---|---|---|
| Speed | 15–600 | 60 | Max movement speed (px/s). Min speed ≈ 25% of this. |
| Cohesion | 0–30 | 10 | Strength of steering toward nearby neighbors’ center. |
| Separation | 0–40 | 20 | Strength of pushing away from overcrowding. |
| Alignment | 0–30 | 10 | Strength of matching neighbors’ heading. |
| Wind Impact | 0–100 | 20 | How strongly the wind field steers each boid. |
| Perception Radius | 20–200 | 100 | Neighbor search distance for cohesion & alignment. |
| Separation Distance | 10–100 | 30 | Distance at which separation kicks in. |
index.html # page + control markup
boidstyle.css # layout and slider styling
boidscript.js # boids, wind zones, animation loop
docs/ # screenshots + capture helper
See LICENSE.




