Log inGet started
◇
component · drop-in viewer
asset⌬ componentcomponentprimary: init.luau·originates fromworld ad080bed-3…

FlyAgent

One living Fly Circus creature.

by◐rbiscutt·posted 1mo ago
What it does

FlyAgent

One living Fly Circus creature.

Attach it to an entity the scene's build has stood a fly body under (see flyBody). It owns a spiking brain, reads the world into it, reads motor commands back out, moves itself through real collision, and poses the body.

What it is

Not a fake. Nothing here decides a behaviour and then displays a number that agrees with it. The senses are currents into named circuits, the behaviour is whatever those circuits do about it, and the inspector reads the same rates the movement came from.

Simulated: the neural dynamics (leaky integrate-and-fire with synaptic delays, inhibition, refractory periods and reward-gated Hebbian plasticity); the drives (hunger, energy, stress, curiosity), which are real state that rises and falls; the movement, which obeys the scene's actual colliders by raycast and sphere-cast; and the food web, which is depleted by eating.

Approximated: the sense organs are simplified — "odour" is distance to the nearest food site rather than a diffusion field, and "vision" is a proximity and approach test rather than an image. The brain is a few hundred neurons, not a fly's hundred thousand. Biologically inspired; not a model of a real animal.

The loop, once per frame

  1. Drives — hunger rises, energy falls with exertion, stress decays at the species' nerve.
  2. Senses — the nearest food as a sustained odour current, a looming visitor as a vision current, another fly as touch. Each goes into its own circuit.
  3. Brain — net:update(dt) in bounded fixed steps.
  4. Decide — the mode comes from the brain's own output scaled by the species' temperament, plus memory: a place it has eaten before is only recalled when the memory circuit is actually firing.
  5. Move — steer toward what won, against real colliders, inside a home range.
  6. Pose and place — wings, legs, proboscis and the transform.
  7. Signal — occasionally, and only when a need is really true of the fly.

Modes are explore, seek, eat, flee, rest, social and return.

Public fields

species, displayName, seed, chatiness (silent/rare/natural/social), hunger, energy, stressLevel, activity, abstracted, senseRange, speaking. The director drives these directly.

Methods

MethodWhat it does
label()the name this fly answers to
rename(newName)rename it; empty returns it to its species name
doing()what it is doing right now, as one word
readout()everything its brain is doing: region rates, drives, position, home, memory, what it has learned
setDrive(which, value)set hunger, energy, stress or dopamine outright
reward(amount)a dopamine burst — it learns, and calms down
calm()clear its stress and let it rest
forget()erase its memories and reset the brain without changing its wiring

Two things that were bugs worth remembering

awake runs before the entity's children exist. The fly's body IS those children, so binding the rig in awake finds an empty tree. Binding happens in start(), and update retries — which is also what repairs the rig after a hot-reload, when the module's memory of it is gone but the entities are not.

A fly's home must not move. It is private and serialised, fixed once where the creature was created. Held in a public field it drifts with the fly; set in awake it is re-captured at whatever position the fly held the next time the component reloaded — which is how a creature ends up with its home pinned to the south edge of the world and stays there for ever.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

FlyAgent — one living Fly Circus creature. This component is the body-side half of a fly. It owns a spiking brain (flycircus.brain), reads the world into it, reads motor commands back out, moves itself through real collision, and poses the body that the scene's build stood up under this entity (flycircus.flyBody). It is deliberately NOT a fake: nothing here decides a behaviour and then displays a number that agrees with it. The senses are currents into named circuits, the behaviour is whatever those circuits do about it, and the inspector reads the same rates the movement came from.

clamp(v: number, lo: number, hi: number) → number

argtypedescription
vnumber
lonumber
hinumber

forwardOf(h: number) → void

The entity's forward is its local -Z, so a heading of 0 faces -Z and a heading h faces (-sin h, 0, -cos h). Both directions of that conversion are here so nothing else has to remember which way round it is. `math.atan2`, NOT `math.atan(y, x)`: in this engine `math.atan` takes one argument and silently ignores the second, so every heading came back in the wrong quadrant and the flies steered at random.

argtypedescription
hnumber

yawTo(dx: number, dz: number) → number

argtypedescription
dxnumber
dznumber

angleDelta(from: number, to: number) → number

argtypedescription
fromnumber
tonumber

groundUnder(st: AgentState) → number

What is under the fly. This is a real raycast against the scene's colliders, so a fly lands on a bleacher because there is a bleacher there and not because a height was assumed.

argtypedescription
stAgentState

obstacleAhead(st: AgentState, fx: number, fz: number, reach: number) → number

Is something solid just ahead? If so, which way is clear.

argtypedescription
stAgentState
fxnumber
fznumber
reachnumber

nearestFly(st: AgentState, radius: number) → void

The nearest other fly, for the social circuit. Cheap because there are six.

argtypedescription
stAgentState
radiusnumber

refreshAvatar(dt: number) → void

argtypedescription
dtnumber

loomingThreat(st: AgentState) → void

The visitor: the local player's avatar, if one is in the world. A human walking up to a fly is the biggest thing in its sky.

argtypedescription
stAgentState

choosUtterance(st: AgentState) → string

argtypedescription
stAgentState

bindBody(st: AgentState) → boolean

A component wakes as its own entity is created — which is BEFORE that entity's children exist. The fly's body is those children, so binding in `awake` finds an empty tree and the creature never moves. By `start()` the whole hierarchy is standing, and this is also the call that repairs the binding after a hot-reload, when the module's memory of the rig is gone but the entities are not.

argtypedescription
stAgentState

awake( ) → void

start( ) → void

onDestroy( ) → void

update(dt: ?) → void

argtypedescription
dt?

editorUpdate(dt: ?) → void

In edit mode the world does not tick, but a room full of dead flies reads as broken. They idle: wings at a low beat, a hover bob, and nothing else.

argtypedescription
dt?

label( ) → string

The name this fly answers to: its display name, else its species name.

examples

entity(id).component.get("FlyAgent"):label()

rename(newName: string) → void

Rename this fly. An empty name returns it to its species name.

argtypedescription
newNamestringThe name to show for this creature.

examples

entity(id).component.get("FlyAgent"):rename("Sir Buzz")

doing( ) → string

What this fly is doing right now, as one word.

examples

entity(id).component.get("FlyAgent"):doing()

readout( ) → any

Everything this fly's brain is doing, for the inspector. Cheap enough to call every frame: it reads smoothed rates, not the neuron arrays.

examples

entity(id).component.get("FlyAgent"):readout()

setDrive(which: string, value: number) → void

Set one of this fly's drives directly. What the director's sliders call.

argtypedescription
whichstringhunger, energy, stress or dopamine.
valuenumberThe value to set, 0 to 1 (dopamine is a burst, 0 to 2.5).

examples

entity(id).component.get("FlyAgent"):setDrive("hunger", 0.9)

reward(amount: number) → void

Give this fly a burst of reward. It learns, and moves on happier.

argtypedescription
amountnumberHow strong the burst is, 0.2 to 2.5.

examples

entity(id).component.get("FlyAgent"):reward(1.5)

calm( ) → void

Settle this fly: clear its stress and let it rest where it is.

examples

entity(id).component.get("FlyAgent"):calm()

forget( ) → void

Erase what this fly has learned and reset its brain's state, without rebuilding the network or changing its individual wiring.

examples

entity(id).component.get("FlyAgent"):forget()
⌬ Types
AgentState = any

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ 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".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.