FruitFlyBrain
A whole connectome running as a spiking network on this entity. It loads the `connectome` asset the field names (the package's `maleCNS` by default), steps it every frame the gameplay clock runs and, with `runInEdit`, in edit mode too; draws every neuron with a soma as a lit poin…
FruitFlyBrain
A whole connectome running as a spiking network on this entity. It loads the
connectome asset the field names (the package's maleCNS by default),
steps it every frame the gameplay clock runs and, with runInEdit, in edit
mode too; draws every neuron with a soma as a lit point around the entity;
plays the network's own crackle from it; and hands the live network to
anything that asks.
Fields: connectome, running, runInEdit, timeScale,
maxStepsPerFrame, gain, minSynapses, showCloud, cloudGate,
cloudScale, neuronRadius, bloom, bloomIntensity, crackle. The
defaults are the calibrated regime: gain 0.6, minSynapses 5, timeScale 1,
maxStepsPerFrame 32.
Methods on the ref: getBrain(), stimulate(sel, hz, source?),
silence(sel, on), clearStimulation(source?), drives(), reset(),
watch(name, sel), unwatch(name), rates(), classRates(limit?),
groupActivity(name), neuronAt(screenX, screenY, radiusPx?),
keepCloudDrawn(seconds?), describe(). stimulate, silence,
clearStimulation and reset are synced calls, so every peer's copy of the
network receives the same inputs. onLoaded fires with the neuron and edge
counts once the network is on the GPU.
local e = entity.spawn("Brain")
e.position = { 0, 5, -8 }
e.component.add("FruitFlyBrain", { gain = 0.6 })
local c = e.component.get("FruitFlyBrain")
c:watch("MN9", { types = { "MN9" } })
c:stimulate({ types = { "claw_tpGRN" } }, 100, "bench")
The visibility gate, and what it means for a capture
The cloud is 139,741 instances, and a registered instanced population has its
whole transform run recomposed on the CPU every frame whether or not the cull
draws any of it. Measured on this world: render.mesh_transform_compose is
4.74 ms a frame with the cloud registered and 0.67 ms with it down. So the
component tests the cloud's bounding sphere against the on-screen camera's
frustum every three frames, registers the draw the moment the sphere enters,
and drops it after thirty consecutive frames outside. showCloud = false
still takes everything down.
The gate only knows about the camera on screen. An offscreen capture aimed
at the brain from a station the player is not standing at can therefore come
back with no cloud in it. Call keepCloudDrawn(seconds) first, or set
cloudGate false.
Moving the entity moves the cloud with it: the transforms are rewritten from the neuron records a slice a frame, with no rebuild.
Drives are owned
stimulate takes the name of whoever is driving. The rate a neuron sees is
the largest any source asked for, so the fly stepping onto a food patch
("fly") cannot take away what the bench ("bench") or a protocol
("protocol") is driving, and clearStimulation("fly") clears only the
fly's. A call that names no source is recorded as "code". drives() is what
the bench lists.
Sound and light
While the cloud is drawn the component registers the builtin bloom on the
scene layer, which is what turns a spiking neuron from a bright dot into a
point of light, and takes it off again when the cloud goes down. The Audio
component it puts on the entity plays the package's crackle clip on a loop
with its volume following the whole-network rate: silent below 0.05 Hz,
rising to 0.35 by 5 Hz.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2FruitFlyBrain: a whole connectome running as a spiking network on this entity. It loads the connectome the `connectome` field names through the package's `brain` module, steps it every frame the gameplay clock runs (and in edit mode while `runInEdit` is set), draws every neuron with a soma as a lit point around the entity, and hands the live network to anything that asks through `getBrain()`. Stimulation, silencing and resets are synced calls, so every peer's copy of the network receives the same inputs. The cloud is 139,741 instances, and a registered population has its whole transform run recomposed on the CPU every frame whether or not the cull draws any of it. So the component registers the draw only while the on-screen camera can see the cloud's bounding sphere, and drops it again after CLOUD_OFF_FRAMES frames outside. An offscreen capture aimed at the brain from a station the player is not standing at does not move that gate: call `keepCloudDrawn(seconds)` first, or turn `cloudGate` off.
cloudOrigin( ) → void
sphereInView(x: ?, y: ?, z: ?, r: ?) → void
| arg | type | description |
|---|---|---|
| x | ? | |
| y | ? | |
| z | ? | |
| r | ? |
setBloom(on: ?) → void
| arg | type | description |
|---|---|---|
| on | ? |
syncCloud( ) → void
armAudio( ) → void
loadBrain( ) → void
awake( ) → void
gateCloud( ) → void
followEntity( ) → void
The cloud is placed in world space once, at build. When the entity is moved the cloud follows it, rewriting the transforms it already holds a slice a frame rather than building the population again.
driveAudio( ) → void
tick(dt: ?) → void
| arg | type | description |
|---|---|---|
| dt | ? |
update(dt: ?) → void
| arg | type | description |
|---|---|---|
| dt | ? |
editorUpdate(dt: ?) → void
| arg | type | description |
|---|---|---|
| dt | ? |
onPropertyChanged(key: ?, value: ?) → void
| arg | type | description |
|---|---|---|
| key | ? | |
| value | ? |
onDestroy( ) → void
getBrain( ) → any
The live network, for code that stimulates, reads out or draws it.
examples
local b = entity(id).component.get("FruitFlyBrain"):getBrain()stimulate(sel: any, rateHz: number, source: string?) → number
Drive a set of neurons with external spikes at a Poisson rate, on every peer. A rate of 0 stops this source driving them; the rate a neuron sees is the largest any source asked for.
| arg | type | description |
|---|---|---|
| sel | any | A selection (`{ types = {...} }`, `{ classes = {...} }`, ...) or an array of indices. |
| rateHz | number | Spikes per second per neuron. |
| source | string? | Who is driving: `"fly"`, `"bench"`, `"protocol"`. Omitted, `"code"`. |
examples
comp:stimulate({ types = { "claw_tpGRN" } }, 100, "bench")silence(sel: any, silenced: boolean) → number
Silence a set of neurons (an ablation) or restore them, on every peer.
| arg | type | description |
|---|---|---|
| sel | any | A selection or an array of indices. |
| silenced | boolean | True to silence, false to restore. |
examples
comp:silence({ types = { "DNp01" } }, true)clearStimulation(source: string?) → number
Stop one source's external drive, or every source's, on every peer.
| arg | type | description |
|---|---|---|
| source | string? | The source to clear. Omitted, every drive goes. |
examples
comp:clearStimulation("bench")drives( ) → any
Who is driving the network right now, one row per source.
examples
for _, d in ipairs(comp:drives()) do print(d.source, d.hz) end
reset( ) →
Put the network back at rest, on every peer.
examples
comp:reset()
watch(name: string, sel: any) → number
Read a set of neurons out under a name; `rates()` then reports their mean firing rate. A neuron carries at most three readout groups, and a watch that would need a fourth on any neuron raises rather than taking a group something else depends on.
| arg | type | description |
|---|---|---|
| name | string | The group's name. |
| sel | any | A selection or an array of indices. |
examples
comp:watch("MN9", { types = { "MN9" } })unwatch(name: string) → boolean
Stop reading a group out, freeing the readout slots it held.
| arg | type | description |
|---|---|---|
| name | string | The group's name. |
examples
comp:unwatch("MN9")rates( ) →
The mean firing rate of every watched group, spikes per second per neuron.
examples
comp:rates().MN9
classRates(limit: number?) → any
The cell classes with the most activity right now, by the mean of the 60 ms spike trace over the class. Activity on a 0 to 1 scale, not Hz.
| arg | type | description |
|---|---|---|
| limit | number? | How many classes, most active first. Default 10. |
examples
for _, c in ipairs(comp:classRates(5)) do print(c.class, c.activity) end
groupActivity(name: string) → any
The activity of each neuron of a watched group of at most 32, in the order the group lists them. What a raster draws a row from.
| arg | type | description |
|---|---|---|
| name | string | The group's name. |
examples
local rows = comp:groupActivity("MN9")neuronAt(screenX: number, screenY: number, radiusPx: number?) → number
The drawn neuron nearest a point on screen, for a click in the cloud.
| arg | type | description |
|---|---|---|
| screenX | number | Pixels from the left of the viewport. |
| screenY | number | Pixels from the top. |
| radiusPx | number? | How far from the point to look. Default 12. |
examples
local i = comp:neuronAt(405, 540)
keepCloudDrawn(seconds: number?) →
Hold the cloud's draw up for a while regardless of where the on-screen camera is pointing. An offscreen capture aimed at the brain calls this first, because the visibility gate only knows about the camera on screen.
| arg | type | description |
|---|---|---|
| seconds | number? | How long to hold it. Default 10. |
examples
comp:keepCloudDrawn(20)
describe( ) → any
A one-table summary of the network: counts, simulated time, rates, what the cloud is doing, and the model parameters.
examples
comp:describe()
Puts a whole connectome on an entity as a running spiking network: steps it every frame, draws its neuron cloud while the camera can see it, and hands the live network to the lab bench and the fly.Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Showing up to 3 levels deep. Open a part to see what it holds further down.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.