# The resident fly

An independent educational experiment for Mason Earl’s wiki. Release the fly to load a real, filtered connectome into a JavaScript leaky integrate-and-fire simulation. The article is usable without JavaScript and without downloading the graph.

## Provenance

- Original data: **MaleCNS v1.0**, HHMI Janelia Research Campus and collaborators, https://male-cns.janelia.org/download/ — **CC BY 4.0**, https://creativecommons.org/licenses/by/4.0/. Attribution is also visible on the page. No endorsement is implied.
- Compiler, binary format, model parameters, and population mapping reference: **Blendi Remade / fal.ai**, `fly-brain-minecraft`, MIT; pinned commit **6cfa30175003ef25da68a237d5eda958f8047b82**: https://github.com/blendi-remade/fly-brain-minecraft/tree/6cfa30175003ef25da68a237d5eda958f8047b82. Original license is in `assets/fly-brain/UPSTREAM-LICENSE.txt`.
- The redistributed `malecns-v1.0.flyb.gz` is byte-for-byte the graph in that commit at `src/main/resources/connectome/malecns-v1.0.flyb.gz`. SHA-256: **e33df182bed7a6f3ea279daf4790a82b05706d3d41e819a6a80c0473e8c559f3**. Compressed size: 22,964,094 bytes. Decompressed: 46,555,448 bytes.
- Threshold: at least five synapses per directed neuron pair. 176,422 retained graph nodes, 6,287,749 edges, 90,296,905 represented synapses. This includes 9,722 unclassified nodes. These compiler counts differ from the curated study’s headline count and are not the full unfiltered graph.
- The lightweight map is a deterministic sample of every 43rd neuron with soma coordinates (3,302 points). Positions and signs are derived from the licensed graph. Displayed points are cell bodies, not reconstructed axons. Live lights show sampled simulated spikes, not measured animal activity. The diagram projects normalized coordinates for readability; do not use it to measure anatomy.
- Science reference: Shiu et al., *A Drosophila computational brain model reveals sensorimotor processing*, Nature (2024), https://www.nature.com/articles/s41586-024-07763-9. The paper studied a different, female connectome. This page is an adaptation, not a reproduction of the paper’s validation.

## Model and body boundaries

`fly-brain-data.mjs` parses FLYB v1 into CSR arrays. Every retained node is represented; sparse integration skips resting neurons with no pending input. A browser worker owns the graph and simulation.

The model uses a 0.2 ms time step (coarser than the upstream 0.1 ms default), membrane time constant 20 ms, synaptic time constant 5 ms, relative threshold 7 mV above rest (absolute rest/reset −52 mV, threshold −45 mV), refractory period 2.2 ms, delay 1.8 ms, weight per synapse 0.275 mV × 0.65. Kenyon-cell input gain is 0.25. Exact exponential integration is used between spikes; synaptic drive is held during refractory periods, matching the upstream implementation. Small residuals below 0.02 mV are truncated when no inputs remain.

GABA, glutamate, and histamine are treated as inhibitory; other/uncertain predicted neurotransmitters as excitatory, following the compiled metadata. These signs, identical point neurons, and global parameters omit substantial physiology. Sensory drive uses seeded Poisson generators with absolute refractory suppression. The engine does not model plasticity, biochemical state, memories, or consciousness.

Page inputs:

- Fruit proximity → 160 Hz sugar population: LB3b, LB3c, LgLG3, LgLG4, PhG1a/b/c (247 nodes). Unlike the upstream mod, all these types get the same drive here; no graded taste composition.
- Startle → 150 Hz LC4/LPLC2 (311 nodes), for 140 simulated ms.
- Brush → 150 Hz JO-C/JO-E prefixes (335 nodes), for 140 simulated ms.
- Ambient light → 8 Hz in a subsample of 82 retinal photoreceptors. This is a fixed stimulus, not actual visual perception of HTML or game frames.
- The engine also exposes a bitter population for regression testing; the UI currently offers the three stimuli above.

Selected outputs: MN9 feeding; DNp01 escape; DNg62/DNge078 grooming; DNp09/DNg100/DNge053/DNge050/DNg97 forward; DNa02/DNg13/DNa01 left and right; DNg02 wing drive. Their actual firing rates modulate the animated body, with smoothing over 70 simulated ms. UI readings use that same smoothing; escape events are unsmoothed.

The **page controller** supplies baseline propulsion, target attraction, random exploration biased toward less-visited cells, resource collection, and block placement. These rules are explicitly authored. Block arrangement follows adjacency, height, centrality, and randomness, not a learned construction policy. This is a toy habitat coupled to neural outputs, not evidence that biological fly brains plan buildings. The worker cannot edit the article, site files, or external systems.

The worker runs at most 50 neural steps or about 12 ms CPU time per tick, then yields for 50 ms. Neural time is reported separately from animation/wall time. A slow device simply advances the simulation more slowly. Model loads require a user action. Hidden tabs pause neural stepping; closing the page stops execution. The UI includes pause, Escape, confined/page roaming, reduced-motion behavior, and load-failure handling.

Only up to 192 validated block records are saved in localStorage (`mason-fly-backyard-v1`), on a 12×12 grid with height ≤4. Neural state is reset on reload. Storage failure leaves a functional session-only habitat. No behavioral data is sent to a simulation server.

## Rebuild and check

Run from the repository root with Node 22 or later:

```
node scripts/build-fly-brain-assets.mjs
node scripts/test-fly-brain.mjs
node scripts/test-fly-brain-page.mjs
npm run search:build
npm run site:check
```

The asset builder regenerates `assets/fly-brain/map.json` from the pinned graph. It does not fetch or replace the graph. The tests check graph integrity, numerical reference dynamics, refractory and delay behavior, inhibition, deterministic stimulation, real sensory-to-output responses, worker loading/pause/resume, and bounded autonomous construction and persistence. They are software checks, not validation against a living fly.

## Illustration

`assets/fly-brain/fly.png` is an AI-generated illustration, separate from the research data. Generated with imagegen on September 9, 2026. Prompt: “Polished scientific-educational Drosophila sprite, top-down, head right, translucent open wings, amber/brown thorax and striped abdomen, ruby compound eyes, six legs; crisp silhouette for 70–90 px display on charcoal; genuinely transparent background; no text, shadow, backplate, or extra objects.” The original RGBA image is retained.

## Source record

The article links original project sources for Neurocraft, fly-brain-minecraft, DOOMFLY, Eon’s embodied simulation, and original Beat Saber and Mario posts. The original Mario post resolves to Jessica Paquette / @barrelshifter, status 2097004115826200898. Beat Saber is Lyra bubbles / @_lyraaaa_, status 2097527368919470162; the creator’s replay/visual-reactivity caveat was also present in their follow-up text at the time of research. GTA and a literal fruit-slicing game remain unverified as of September 9, 2026 and are labeled accordingly. There is no scheduled monitor; this is a dated wiki entry.
