# Sensorimotor arena: a synthetic integration experiment

A native consumer of the installed `Brain::advance` API closes the loop between
an environment, sensory channels, neural output and steering. It uses a **hand-wired
four-neuron synthetic circuit**, not the MaleCNS connectome. The public portfolio
replays recorded native trajectories. It does not execute inference in the browser.

## Reproduce from a FlyBrain checkout

```sh
cmake --preset release
cmake --build --preset release -j2
cmake --install build/release --prefix /tmp/flybrain
cmake -S examples -B build/consumer -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/tmp/flybrain
cmake --build build/consumer -j2
ctest --test-dir build/consumer --output-on-failure
python3 examples/record_arena.py --binary build/consumer/flybrain_arena --engine-revision "$(git rev-parse HEAD)" --output arena-results.json
```

The collector preserves source/binary SHA-256 hashes, an explicitly supplied engine
revision, compiler, available consumer flags, platform, method and all trajectories. Its output creation is exclusive;
it rejects malformed/missing runs, sensor ranges, bounds, sample order, impossible
motor counts, mismatched initial conditions and inconsistent reach outcomes.
The supplied revision identifies the engine checkout; source hashes describe the
actual files, including uncommitted example changes. Pass `--compiler` if the
compiler used to build the executable is not `c++`. No wall-time benchmark or
cross-platform bitwise promise is made. The FlyBrain engine repository is currently
private; the public page includes the consumer source and recorded evidence for
inspection, while running it requires access to the installed engine.

## Environment and encoding

- Unit square; position starts at `(0.5, 0.5)` and is clamped to `[0.02, 0.98]`.
- Three target positions and six initial headings produce 18 fixed scenarios.
- A target is reached within radius 0.045. Speed is 0.12 world units per second.
- Host step is 0.02 seconds, up to 600 steps (12 seconds simulated time).
- Bearing error `e = atan2(target.y-y, target.x-x) - heading` supplies a synthetic
  directional signal: `left=(1+sin(e))/2`, `right=(1-sin(e))/2`.
- Sensors know this directional signal. They are not anatomical eyes, ray-cast
  vision, distance sensors, or learned perception. There are no obstacles.

## Neural path

Synthetic IDs 1001/1002 are input neurons; 1003/1004 are output neurons. Two
excitatory edges connect left input to left output and right input to right output,
with weight 28 represented synapses each. Defaults from `Parameters` are unchanged:
1 ms model step, 20 ms membrane time constant, rest/reset -52 mV, threshold -45 mV,
two refractory steps and 0.275 mV per synapse. Input gain is 3 mV per unit.

Every host step holds both inputs for 20 model ticks. The output window totals
supply `yaw=0.8*(left_motor_spikes-right_motor_spikes)` radians/second, clamped to
±3. The environment then updates heading and position. Wiring and gains are
hand-chosen for demonstration, with no training, search or held-out evaluation.

## Baseline and ablation

The rule controller directly computes `yaw=3*(left-right)`, with the same ±3
limit, input signal, movement rules, targets, starting poses and time horizon.
The disconnected controller removes the two edges; motor neurons receive no
input, emit no spikes, and steering remains zero. A straight trajectory may still
reach a target by coincidence. These controls test the causal integration; they do
not establish superiority or generalization of the neural controller.

The executable checks mirrored inputs yield mirrored output windows, disconnected
motor silence, active transmission, repeated same-build trajectories, finite/bounded
positions, and reach predicates. Scenario outcomes are observations, not biological
validation. Existing simulator semantics, reference engine and golden values are
unchanged. The arena is not an optimization and makes no engine speedup claim.

## Recording layout

Each trial records frames every five host steps (0.1 simulated seconds), plus the
exact terminal step. Frames are arrays in this order:
`step, x, y, heading_radians, left_input, right_input, left_motor_spikes, right_motor_spikes`.
Sensors and counts belong to the final 20-tick window of that sampled host step;
the pose is after its movement update. Counts are not sums across the five-step
recording interval. The initial frame uses zero placeholders for inputs/counts.
`output_spikes` is the total across all windows. Reached agents stop, and the public
replay holds their final pose while the remaining agents finish.

Full-graph sensory selections, biological validation, richer dynamics and a body
model remain separate future work. This small fixture validates the adapter and
makes the input/output boundary inspectable without the full dataset.
