# Fly Colony Fruit flies on your Windows desktop. Every adult runs its own copy of a real *Drosophila* brain circuit, from the FlyWire connectome and the MaleCNS leg circuit. Leave them alone and they find food, court, mate and lay eggs. The eggs hatch into maggots, the maggots pupate, and new flies emerge with genes inherited from their parents. Swat them and they burst all over your screen, and then you have to wipe it up. Built on [DesktopFly](https://github.com/DenisSergeevitch/desktop-fly). See `UPSTREAM.md`. ## Run it For the Windows x64 user build, download `FlyColony-*-win-x64.zip` from the [Releases page](https://github.com/TZY114514/fly-colony/releases), extract the complete ZIP, and double-click `启动器.exe`. Its Chinese launcher starts the colony, opens the lab, and saves both worlds before closing the app. Node.js is included in the runtime. See `使用说明.txt` inside the package. Personal saves live in `%APPDATA%\fly-colony`, outside the extracted folder. For development: Needs Node.js 18+ on Windows 10/11. ``` npm install npm start ``` A tray icon appears. The flies live on a transparent, click-through layer over your whole desktop, so your clicks still go to your apps. ## Controls The tray menu has everything. Hotkeys toggle the tools; if another app already owns a combination, Fly Colony falls back to Ctrl+Alt+Shift+… and the tray shows which one it got. | | Hotkey | What it does | |---|---|---| | Fly swatter | Ctrl+Alt+S | Hold to raise, release to strike. Right-click or Esc to put it down. | | Cleaning cloth | Ctrl+Alt+W | Drag to wipe. Right-click wrings it out. A soaked cloth smears. | | Bug net | Ctrl+Alt+N | Hold and sweep *fast* through a fly to catch it alive for the lab. | | Banana slice | Ctrl+Alt+F | Click to drop food. Flies feed and lay eggs in it, and it rots. | | Magnifier | Ctrl+Alt+I | Hover a fly to see who it is and what it's doing; click it to open its brain. | | Fly spray | Ctrl+Alt+P | Hold to spray a neurotoxic mist. *kdr*-resistant flies shrug it off. | | Fly paper | Ctrl+Alt+K | Click to hang a baited sticky strip; click a strip to take it down. | | Fly Lab | Ctrl+Alt+L | Vials, crosses, genetics, strain library. | | Debug overlay | Ctrl+Alt+H | Population, brain tiers, neural CPU time. | Tray settings cover life-cycle speed (frozen to 16×), gross level, creature size, sound, whether wild flies wander in, and **Incubator mode**. Incubator mode moves every fly and every young one into the Fly Lab and hides the desktop layer. A **How to play** window opens on first run, and later from the tray. ## The Brain Inspector Click a fly with the magnifier, or double-click one in the Fly Lab (or press **View brain** on its card), to watch its own brain work in real time: - **3D brain.** Its 23k real soma positions, with all 668 simulated neurons glowing at their true locations as they fire. Drag to turn, scroll to zoom, and click a cluster to stimulate those neurons optogenetically. - **Spike raster.** Scrolls by as it fires, grouped by cell type: looming detectors, giant fiber, steering, walking, grooming, backward and escape-wing DNs. - **Command neurons.** Live firing rates with sparklines. - **Decision signals.** What the brain is telling the body, with a plain-language summary of what it is doing and why. - **Senses.** Looming on each eye, wind and vibration, leg proprioception, excitability, and the sensory gate. - **Legs.** The MaleCNS leg-motor heatmap. An inspected fly is promoted to neural legs. - **Genes → brain.** The parameters its genotype sets. - **Body state.** - **Event log.** For example "Looming detectors hot → darted away" or "Giant fiber spiked → escape jump". - **Stimulation buttons:** groom, walk, back up, escape, raise wings, steer. Spray a fly while you watch it: the insecticide makes its neurons fire on their own and sends its command populations into seizure-like bursts. ## What happens on your desktop - **Brains.** Each adult has a 668-neuron FlyWire LIF network. Escape, darting, walking, steering, grooming, backward walking and wing posture all come from its neurons. Flies near the cursor (or the one you are inspecting) also get the 1,045-neuron MaleCNS leg circuit, which drives articulated legs. A CPU governor decides how many get it. - **Swatting is a race against a real escape circuit.** The descending swatter is a looming stimulus on each fly's LC4/LPLC2 neurons. If its giant fiber fires in time, it jumps clear. Sleepy, feeding, mating and genetically sluggish flies are easier to hit. - **Goo.** - A swat bursts the fly: hemolymph, gut contents, and red eye pigment (only from red-eyed flies). - A squashed carcass with spilled viscera, a torn wing, and a leg that keeps twitching. - Droplets fly out and short drips run down the screen. - The goo dries to a crust that's harder to wipe. - A swatted female full of eggs spills them, and they can still hatch. - **Goo is food.** Flies smell unwiped mess and fly to it, feed with their proboscis, and lay eggs in it. - **Fly spray** is a pyrethroid-style neurotoxin: 1. Exposed flies' neurons fire uncontrollably. 2. They are knocked down. 3. Badly poisoned flies end up spinning on their backs and die. Flies carrying the *kdr* allele of the para sodium channel resist it, so heavy spraying selects for a resistant colony. - **Fly paper** is baited, and flies land on it on their own. Once stuck, their brains keep firing escape commands and the body struggles until it gives out. The dead stay on the strip until you take it down. - **Score.** Swat streaks, "double swat!", and colony milestones such as the first eggs, 15 or 30 flies, and generation 3. - **The desktop is terrain.** - Flies walk along window title bars and the taskbar, and perch and ride on your cursor if it sits still. - Eggs and pupae stick to windows and move with them. - Shake, minimize or close a window and whatever was on it falls off. - Wandering maggots climb to window edges and the taskbar to pupate. - **Life cycle**, on a game clock (default 1 game-day per minute): 1. Egg (~1 day) → three larval instars (~4 days) → pupa (~4 days) → adult. 2. Pupae tan from white to brown; red eyes show through the case before the adult emerges. 3. Newly emerged flies are pale, with crumpled wings that expand. 4. Old flies die and lie on their backs. ## The Fly Lab - **Vials.** A stock bottle and four vials, seen from the side. Food sits at the bottom and larvae tunnel through it, then climb the glass to pupate. The food runs out and goes moldy; "Fresh food" replaces it. - **CO₂.** Knock a vial out, then drag the sleeping flies into another vial with the brush, as in a real fly room. Collect virgin females (they are only virgin for about 8 game-hours) to set up controlled crosses. - **Fly cards.** Genotype in fly-pushing notation (`w/w ; vg/+ ; +`), trait bars, the brain parameters its genes produce, parents, generation, and swats dodged. - **Crosses.** Predicted offspring ratios next to an observed tally, with a χ² test. - **Strains.** Save a vial as a strain, then export or import `.flystrain` files to share with friends. - **Incubator temperature.** - 18 °C halves development speed. - 29 °C speeds it up, but heat-stressed males are often sterile. - **EMS mutagenesis.** Feed a vial's males the mutagen, cross them, and screen their grandchildren for brand-new mutants (a real forward genetic screen). *Bar* and *Curly* never occur in the wild; this is how you get them. - **Colony over time.** A chart of desktop and lab populations, swats, dodges, poisonings and fly-paper deaths. - **Lab notebook.** Challenges, such as a true-breeding line, a swat-proof fly, generation 5, insecticide resistance, or a mutant recovered from a screen. ## Genetics Real genes at their real map positions: | Gene | Location | Effect | |---|---|---| | *yellow* | X, recessive | yellow body; males court poorly | | *white* | X, recessive | white eyes; worse vision | | *Bar* | X, semidominant | narrow eyes | | *Curly* | 2, dominant | curled wings; lethal when homozygous | | *dumpy* | 2, recessive | shortened wings | | *vestigial* | 2, recessive | stub wings; can't fly, hops instead | | *sepia* | 3, recessive | brown eyes | | *ebony* | 3, recessive | dark body; worse vision | | *para^kdr* | X, semirecessive | insecticide resistance (invisible until you spray) | - **Inheritance:** males don't recombine and X-linked genes are hemizygous in males, as in real flies. - **Quantitative traits:** jumpiness, activity, grooming, flight vigor, fecundity, development speed, longevity and size come from several additive loci each. - The behavioral ones set brain parameters: looming gain, giant-fiber coupling, and DNp09 / DNg11 excitability. Selective breeding really changes the circuit. - `test/colonybrain-test.js` sweeps random extreme genomes to check that no genome pushes a brain off its operating point. - **Wild flies** carry hidden recessive alleles, and rare new mutations appear. ## What is connectome-driven, and what is modeled Wiring and synapse counts are measured, while neural dynamics and the body are models, as described in the upstream README. These behaviors are scripted layers, labeled MODELED in the code: - courtship and mating - hunger and food-seeking flights - egg-laying - all larval and pupal behavior - the CO₂ knock-out - insecticide action: raised excitability plus seizure bursts injected into the real command populations - fly-paper adhesion - temperature effects - EMS mutation rates Where possible, they act by stimulating the real command neurons. Odor steering, for example, goes through DNa01/02 and DNp09. ## Development ``` npm test # upstream suites + genetics + brain + headless colony npm run bench # per-fly brain cost npm run package:win # Windows x64 portable folder, ZIP, and SHA-256 in dist/ npm run test:package # packaged startup, duplicate launch, lab, save/quit, restart ``` Packaging uses the installed Electron runtime and the Windows .NET Framework compiler. The launcher needs .NET Framework 4.5+ (included in Windows 10/11). Only application assets and Windows x64 runtime dependencies enter the user package; development tools, tests and personal saves are excluded. The binaries are unsigned. Rebuild after source changes and rerun the package smoke test. Environment variables for development: | Variable | Effect | |---|---| | `FLY_DEMO=macro\|closeup\|swarm\|goo\|lab\|inspect\|inspectpoison\|paperspray\|welcome` | stage a scene | | `FLY_CAPTURE=out.png` and `FLY_CAPTURE_DELAY=s` | save a screenshot and quit | | `FLY_USERDATA=dir` | use a throwaway save folder | | `FLY_SWATS=n` | automated test swats | | `DESKTOPFLY_DEBUG=1` | verbose logging | ## License The code is MIT. The FlyWire data is **CC BY-NC 4.0, so Fly Colony must stay non-commercial**. The MaleCNS data is CC BY 4.0. See `NOTICE.md`.