FlySim — a fruit fly that walks on its connectome and flies on a trained brain
Closed-loop Drosophila simulation: the NeuroMechFly v2 / FlyBody body (MuJoCo), three interchangeable brains — flygym's CPG, a 64-pool rate network distilled from the MaleCNS v1.0 connectome (Janelia/Google, CC-BY), and a pure-NumPy port of the FlyBody flight policy — plus a self-sustaining colony loop: food, energy, olfactory chemotaxis, courtship, eggs, eclosion, starvation.
LIVE Feed the flies — the real simulator, interactive. Two actual MuJoCo walkers streamed live: click the arena to move their food, they re-orient with the M4-verified chemotaxis, walk over, and feed. Energy drains; starvation is real. Open the live viewer →
Flight — steered by its brain
M0: the connectome steers the flight. Lateralized activation of connectome-identified descending neurons (each weighted by its measured projection asymmetry onto the left vs right wing motor pools — DNs project bilaterally, so soma-side masking would be wrong) is read out through the connectome's premotor→wing-MN mapping and drives a dead-reckoning goal integrator. Verified on HF Jobs (3 drives × 3 seeds × 5 s): the heading-change sign matches the drive in 6/6 lateralized runs, straight stays near zero by construction, |ΔψL−ΔψR| > 0.5 rad.
The colony — a self-sustaining ecosystem
- Multi-fly physics: explicit inter-fly collision pairs — a head-on meeting deflects (±9.9 mm y-escape), never passes through
- Food & energy: metabolic drain 0.02/s, patch intake 0.25/s; starvation at exactly E₀/drain = 50.0 s
- Feeding (M3): 20/20 reach vs 10/20 chance, p<10⁻⁶
- Olfaction (M4): 20/20 with the antennal gradient alone, p<10⁻⁶ — no oracle
- Courtship & breeding (M5–M6): mating event → egg at t=10.9 s → eclosion t=40.9 s; parents starve at t=50 s
Interactive trajectory player
Replays of real committed run logs, animated in your browser — open the player (colony 60 s · steered flight). Trails, goals, energy readouts; scrub with the speed slider.
Walking on its connectome
Milestone board — every claim has a metric
| M | Capability | Verified number | Status |
|---|---|---|---|
| 0 | Connectome steers flight (DN turn-bias readout → goal integrator) | 3 drives × 3 seeds × 5 s on HF Jobs: sign-consistent, |ΔψL−ΔψR|>0.5 rad, RMSE ≤ 1.5× baseline | PASS |
| 1 | Multi-fly arena with fly-fly collision | N=3 walkers 60 s finite, min separation 3.27 mm; head-on deflects | PASS |
| 1.5/7 | Live interactive stream | MJPEG colony + click-to-feed: clicking moves the food patch (mocap body) and both flies chemotax to it (M4 sensing); verified end-to-end in-container | PASS |
| 2 | Food & energy substrate | death at exactly E₀/drain (50.0 s); patch recovery to cap | PASS |
| 3 | Feeding FSM (oracle bearing) | 20/20 vs 10/20 chance, one-sided binomial p<10⁻⁶ | PASS |
| 4 | Sensing in the loop (antennal gradient, no oracle) | 20/20 vs 10/20, p<10⁻⁶; odor-zeroed ablation = chance | PASS |
| 5 | Courtship (male connectome × scripted female) | orient→follow→contact→mated (egg); courtship-ablation = no mating | PASS |
| 6 | Population loop | egg t=10.9 s → eclosion t=40.9 s; starvation regulates; carrying capacity by allocation | PASS |
| 8 | Release (CI, README, attribution, ledger) | ruff clean, 5 tests passing, every artifact committed | PASS |
The live stream renders through a raw mujoco.Renderer
(flygym's Renderer EGL path fails in job containers; the identical raw stack works).
Cost ledger — every job, success or failure
| Tag | Mode | Hours | Est. cost | Note |
|---|
Rendered from data/site.json (built by flysim/site.py
from the append-only ledger at output/job_ledger.jsonl) — dedup rule: one row
per job tag, keeping the max estimate. Every killed launch and stale job is logged honestly.
Run it yourself
python run_sim.py --mode connectome — walk on the connectome
python -m flysim.brain_sim --ref-mode connectome --drive left — steered free flight
python -m flysim.arena --duration 60 --n 3 — multi-fly colony with collisions
python -m flysim.m3 --trials 20 — the feeding experiment
python -m flysim.population — the whole loop: courtship, egg, eclosion, starvation
python -m flysim.jobs --live --ref-mode circuit — watch the fly fly live (HF Job)
Artifacts: epoch14/fly-sim-runs ·
full state report in REPORT.md · every gotcha in AGENTS.md ·
ownership in ATTRIBUTION.md
Interactive fly, in your browser (client-side, no server)
More: pose viewer · NeuroMechFly Live slalom game
Credits
- FlyGym / NeuroMechFly v2 (Apache-2.0), Ramdya lab, EPFL — please cite the NeuroMechFly v2 paper
- MaleCNS v1.0 connectome (CC-BY), FlyEM/Janelia + Cambridge + MRC-LMB + Google Research
- FlyBody (Nature 2025, Turaga/Ramdya labs) — the flight body, WPG and trained policy checkpoint
- MuJoCo (Apache-2.0) · Three.js (MIT)