{"slug": "fly-arena-simulating-a-fruit-fly-with-a-connectome-and-physics", "title": "Fly Arena: Simulating a Fruit Fly with a Connectome and Physics", "summary": "A developer released Fly Arena, an open-source simulation that combines a NeuroMechFly body in MuJoCo with MaleCNS v1.0 connectome data and explicit behavioral controllers to model a fruit fly. The hybrid mode supports walking, odor-guided food search, contact-based feeding through an articulated proboscis, grooming, sleep pressure, and waking, while a separate two-fly arena adds shared food, body collisions, pushing, foreleg fencing, and retreat. Setup requires 64-bit Python 3.12 and an OpenGL-capable driver, and the `prepare` command downloads approximately 1.11 GB of public MaleCNS v1.0 source data, verified by SHA-256 hashes, with no neuPrint account or token needed.", "body_md": "A local fruit-fly simulation combining a physical NeuroMechFly body in MuJoCo, MaleCNS connectome data, and explicit behavioral controllers.\n\nThe main hybrid mode supports walking, odor-guided food search, contact-based feeding through an articulated proboscis, grooming, sleep pressure, and waking. A separate two-fly arena adds shared food, body collisions, pushing, foreleg fencing, and retreat. These behaviors combine simulated physiology with engineered decisions and motor programs. This is an experimental model, not a physiologically validated digital fly.\n\n| Odor-guided search | Feeding through the proboscis | \n|---|---|\n| Foreleg grooming | Sleep and tactile waking | \n\nThese clips show the engineered behavioral and motor controllers with the connectome disabled. Playback speeds vary between clips.\n\nUse **64-bit Python 3.12** and an OpenGL-capable graphics driver. Neural dynamics\nand physics run on the CPU; CUDA and PyTorch are not required. Allow several GB\nof disk space for the environment, downloaded data, and generated output.\nReal-time performance depends on your CPU. The first neural run includes Numba\ncompilation.\n\nClone the repository and run commands from its root:\n\n```\ngit clone https://github.com/artem-x-meta/fly-arena.git\ncd fly-arena\npy -3.12 -m venv .venv\n.\\.venv\\Scripts\\python.exe -m pip install -e .\n.\\.venv\\Scripts\\python.exe -m fly_arena run --mode body-demo --seconds 3\n```\n\nThe last command checks the physical body and viewer with scripted walking;\nit does not load a connectome. Alternatively, use `launchers/01_setup_windows.cmd` and\nthen `launchers/02_test_body.cmd`.\n\nPrepare the neural graph, then start the hybrid arena:\n\n```\n.\\.venv\\Scripts\\python.exe -m fly_arena prepare\n.\\.venv\\Scripts\\python.exe -m fly_arena run --mode ethology-hybrid --config configs/ethology-fast.toml --seconds 0\n```\n\n`prepare` downloads approximately **1.11 GB** of public MaleCNS v1.0 source data,\nverifies SHA-256 hashes, and builds a sparse graph in `data/graph/`. Downloads\ncan resume after interruption. No neuPrint account or token is required.\nSubsequent runs use local data.\n\nIn the viewer, drag or scroll to move the camera, press **Space** to pause,\nand close the window or press **Ctrl+C** in the console to stop. In hybrid\nmode, **W** applies a local tactile wake stimulus. `--seconds` means simulated\nseconds; `0` keeps running until stopped. `--wall-seconds` can limit wall time\nfor the hybrid arena after loading.\n\nWindows launch scripts are grouped in `launchers/`. They locate the project\nroot automatically, so they can be started from any working directory.\n\n| Launcher | Demonstration | Prepared graph needed | \n|---|---|---|\n| `launchers/02_test_body.cmd` | Scripted walking and installation check | No | \n| `launchers/04_run_connectome.cmd` | LIF activity driving descending gait commands | Yes | \n| `launchers/05_run_ethology.cmd` | Feeding, grooming, sleeping, and walking | Yes | \n| `launchers/07_run_search.cmd` | Odor-plume search with recurring food and dust | Yes | \n| `launchers/09_run_escape.cmd` | Approaching visual object and engineered escape | Yes | \n| `launchers/13_run_food_fight.cmd` | Two flies sharing a scarce food supply | No | \n| `launchers/15_run_shared_meal.cmd` | The same encounter with more food available | No | \n\nThe `demo-fast` profile accelerates organism processes such as metabolism and\nsleep pressure by 60 times. Physics and neural time retain their normal scale.\nUse `configs/ethology-unscaled.toml` for an organism time scale of one.\nFood, energy, and contamination use model-specific units.\n\nThe two-fly demonstration can also be started directly:\n\n```\n.\\.venv\\Scripts\\python.exe -m fly_duel --social --scene encounter --single --seed 1 --seconds 12 --viewer\n.\\.venv\\Scripts\\python.exe -m fly_duel --social --scene encounter --single --seed 1 --seconds 12 --resources ample --viewer\n```\n\nEach contestant has its own organism state, navigator, and motor controller. Actual feeding draws from a shared finite resource. Failed feeding, remaining hunger, recent food contact, and local rival sensing drive the social policy; successful intake suppresses escalation. The motions include physical pushing and foreleg fencing, but do not reconstruct biological lunges or the full aggression repertoire. This mode runs engineered controllers without a neural graph. Its scarcity scenario can escalate after the food has been consumed; it does not establish a winner's advantage in access to remaining food.\n\nRecord a short feeding scenario without opening the viewer:\n\n```\n.\\.venv\\Scripts\\python.exe -m fly_arena run --headless --scenario feeding-contact --seconds 3 --video runs/feed.mp4\n```\n\nOn Linux, use Python 3.12 and `bash setup_linux.sh`. Replace the Windows Python\npath with `.venv/bin/python`; use `--headless --gl egl` when running without a\ndesktop and with a working EGL backend.\n\nOutputs go to `runs/`: telemetry, metadata, optional video, and checkpoints.\nHybrid-mode checkpoints contain physics, neural and organism state, resources,\ncontroller state, filters, and random generators. Continue a saved run with:\n\n```\n.\\.venv\\Scripts\\python.exe -m fly_arena run --resume runs/checkpoints/latest.npz --seconds 10\n```\n\nHere, `--seconds` adds simulation time and configuration comes from the\ncheckpoint. Compatibility checks include code, dependencies, graph, and model\nfingerprints, so checkpoints from another source revision may be rejected.\nThe older `connectome` mode saves neural state for analysis, not a complete\nresumable arena.\n\nThe prepared graph retains **166,700 annotated non-glial entries** and all\n**25,582,938 connection rows** between them, including weak and self connections.\nWeights derive from synapse counts, simplified transmitter signs, and a global\ngain. The default backend uses uniform leaky integrate-and-fire neurons with\nexplicit background and descending-neuron stimulation. These dynamics and input\nchoices are project implementations, not physiological parameters supplied or\nvalidated by the connectome authors.\n\nTwo 96 x 96 cameras provide approximate retinal input. Descending activity is converted to gait commands, while FlyGym supplies an engineered walking controller. Motor neurons are not individually mapped to muscles. In hybrid mode, food search, behavioral arbitration, and escape detection also contain engineered logic. Running the full graph does not demonstrate that natural behavior emerges from connectivity alone. Flight is not implemented.\n\nAdditional research packages remain separate from the main arena:\n\n- `fly_circuit_lab` contains visual-pathway probes and a paper-derived escape\nresponse model.\n- `fly_bio` and`fly_bio_selectivity` contain graded-response and motion\nselectivity experiments. They did not achieve a validated replacement for\nthe external visual controller.\n- `fly_semantic` and`semantic_tools` explore a small trained neural-activity\nreadout for the need for food, with frozen connectome weights and artificial\ninput ports. Directional instructions are not yet an operational learned\nnavigation interface. The demo requires separately generated calibration,\nmappings, and trained readout artifacts; these are not shipped in this\nrepository. Existing semantic labels and console messages are in Russian.\n\nDownloaded datasets, recordings, trained artifacts, local experiment reports, and development notes are excluded from version control. The source and configuration files remain available for inspection and further experiments.\n\nInstall the test extra and run the source test suites:\n\n```\n.\\.venv\\Scripts\\python.exe -m pip install -e \".[test]\"\n.\\.venv\\Scripts\\python.exe -m pytest --import-mode=importlib tests circuit_tests compat_tests duel_tests bio_tests selectivity_tests semantic_tests\n```\n\nThe import mode allows similarly named test modules in separate directories.\nSome integration and experiment-reproduction checks require OpenGL, a prepared\ngraph, or local generated artifacts. See each test's prerequisites before\nenabling them.\nUse `python -m fly_arena run --help` and `python -m fly_duel --help` for CLI\noptions, including diagnostic and ablation controls.\n\n- **Missing prepared connectome:** run`python -m fly_arena prepare` from the\nproject root, or set`--data` to the correct data directory.\n- **Missing Python:** check`py -3.12 --version` ; this dependency set targets\nPython 3.12.\n- **Black or clipped viewer:** MuJoCo's side panels are hidden by default due\nto a rendering issue on some drivers. Avoid`--mujoco-ui` on affected systems.\n- **Slow first run:** allow Numba compilation to finish. Model seconds are\nindependent of wall-clock seconds.\n\nProject code is available under the [MIT License](/artem-x-meta/fly-arena/blob/main/LICENSE). Connectome data\ncome from [MaleCNS v1.0](https://male-cns.janelia.org/download/) under CC BY 4.0.\nThe physical body and walking controller come from\n[NeuroMechFly / FlyGym](https://github.com/NeLy-EPFL/flygym), with physics provided\nby [MuJoCo](https://github.com/google-deepmind/mujoco). See\n[THIRD_PARTY.md](/artem-x-meta/fly-arena/blob/main/THIRD_PARTY.md) for attribution, transformations, and dependency\nlicenses.", "url": "https://wpnews.pro/news/fly-arena-simulating-a-fruit-fly-with-a-connectome-and-physics", "canonical_source": "https://github.com/artem-x-meta/fly-arena", "published_at": "2026-09-12 20:23:52+00:00", "updated_at": "2026-09-12 20:55:28.388294+00:00", "lang": "en", "topics": ["ai-research", "robotics", "neural-networks", "ai-tools", "developer-tools"], "entities": ["Fly Arena", "NeuroMechFly", "MuJoCo", "MaleCNS v1.0", "Python 3.12", "Numba", "PyTorch", "fly_duel"], "alternates": {"html": "https://wpnews.pro/news/fly-arena-simulating-a-fruit-fly-with-a-connectome-and-physics", "markdown": "https://wpnews.pro/news/fly-arena-simulating-a-fruit-fly-with-a-connectome-and-physics.md", "text": "https://wpnews.pro/news/fly-arena-simulating-a-fruit-fly-with-a-connectome-and-physics.txt", "jsonld": "https://wpnews.pro/news/fly-arena-simulating-a-fruit-fly-with-a-connectome-and-physics.jsonld"}}