Log inGet started
World

Fly Circus — The Living Simulation

Branchmain
Branchesmain
Commitff727ce6b1

README.md

brain

A biologically inspired spiking brain for a Fly Circus creature.

This is not a real fruit-fly brain and does not claim to be. It is a hand-built artificial nervous system: 198 leaky integrate-and-fire neurons wired into named circuits, with the same shape of organisation a small insect brain has — sense at one end, motor at the other, modulatory, associative and gating circuits between. A real Drosophila connectome is installable from ZeroMind as the fruitFly package (164,587 traced neurons); this world deliberately does not use it, because the brief calls for a simplified, clearly-labelled simulation and six full connectomes would not run on the hardware this is built for.

What it provides

M.build(seed) returns a network. Each fly passes its own seed, so two flies with the same code have different wiring and different temperaments.

CallWhat it does
net:update(dtMs)advance the network by a slice of real time, in bounded fixed steps
net:step(n)run n fixed 5 ms steps
net:stimulate(region, current)a steady current into a whole region — how the body reports its condition
net:pulse(region, strength)a one-off kick — a thing the fly just sensed
net:reward(amount)a dopamine burst; this is what teaches the network
net:rate(region)a region's mean firing rate in Hz
net:readout()every region's rate, its position in the brain, and what it does
net:motor()the five motor drives plus the drives, normalised
net:firings()per-neuron spike flags for the frame
net:reset()clear membrane state without rebuilding the wiring

M.regions() returns the region catalogue — key, label, role, size, position inside the brain, what the circuit does and what it influences.

The model

Every neuron is a leaky integrate-and-fire unit. Each step its membrane leaks toward rest, accumulates whatever synaptic current arrived, and fires at threshold:

v += (dt / tauM) * (-(v - vRest) + I)
if v >= vThresh then spike(); v = vReset; refractory = refracMs end

Synaptic current decays exponentially, not by an Euler step. With a 5 ms step against a 5 ms synaptic time constant an Euler decay is 1 - dt/tau, which is zero — every arriving spike is wiped before it can move a membrane, and the failure presents as "senses do nothing" rather than as a broken integrator.

Resting currents sit just under the 7 mV gap between rest and threshold, so the circuits idle at a few hertz and membrane noise carries them across irregularly. Without that the network is silent until driven, which reads as a dead brain.

Plasticity is Hebbian and gated by reward: a plastic synapse whose pre- and post-synaptic neurons fire together grows, and a burst of reward opens the gate. Without reward the gate is nearly shut, so the fly only learns about things that turned out well. A slow trace of forgetting fades associations never reinforced.

Who calls it

  • FlyAgent owns one network per creature and steps it every frame.
  • BrainViewer reads readout() to draw and explain it.