Skip to content

Add operant control of rewards based on velocity#568

Open
galenlynch wants to merge 8 commits into
mainfrom
feat-operant-abort-velocity
Open

Add operant control of rewards based on velocity#568
galenlynch wants to merge 8 commits into
mainfrom
feat-operant-abort-velocity

Conversation

@galenlynch

@galenlynch galenlynch commented Jun 2, 2026

Copy link
Copy Markdown
Member

Attempt to fix #566. This version includes a separate velocity threshold than the stop threshold, which is more flexible. Happy to discuss that detail, or others.

@galenlynch galenlynch changed the title Feat operant abort velocity Add operant control of rewards based on velocity Jun 2, 2026
galenlynch and others added 7 commits June 2, 2026 10:01
The probability-grid stages now run operant (is_operant=True), so abandoning a
wait forfeits the reward — making the long delay a real wait-or-abandon decision
(it was free water on a schedule before).

Adds OperantLogic.abort_velocity_threshold (cm/s) as an ADDITIONAL abort source
alongside grace distance and leaving the site: an operant choice aborts if velocity
exceeds the threshold OR displacement exceeds grace_distance_threshold OR the animal
leaves the reward site. It catches slow-creepers who lick while drifting forward
(e.g. 860900: velocity stays <15 cm/s while engaged, ramps to ~45-55 to leave) — a
pure spatial grace clips their genuine licking. Set to 15 on both grid stages;
shaping stages leave it None.

Optional (default None), so prior trainer states/JSON deserialize unchanged.

NOT YET ENFORCED ON THE RIG (Python/curriculum side only): enforcing the threshold
requires adding a velocity-abort branch ALONGSIDE the grace/leave-site sources in
InstantiateSite.bonsai, plus regenerating the core JSON schema + C# (vr-foraging
regenerate, needs .NET). The core schema and Generated.cs are not regenerated here.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ity_threshold

This curriculum schema was left stale on the branch — it embeds OperantLogic
but was missing the new abort_velocity_threshold field that the other six
curriculum schemas already carry. Regenerated so the branch is internally
consistent and a rig-side regenerate.py only produces the core schema/C# diff.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…eshold

Per review feedback: the velocity abort is evaluated on the same filtered
velocity signal as stop detection (IsStopped = velocity < StopVelocityThreshold),
so the two gates partition one velocity axis in opposite directions. Document that
abort_velocity_threshold must stay >= the operative StopVelocityThreshold (else a
locked stop instantly aborts), and that because StopVelocityThreshold is shaped
(60->8 via the GAIN updater) while the abort is a fixed absolute, the abort may
only be enabled where the stop gate is already floored below it. Add the matching
rationale where the grid stages set 15 against their static stop threshold of 8.

Docstring only; schema/*.json and Generated.cs must be regenerated on the rig.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Per review feedback. Drop the InstantiateSite.bonsai location pointer after the
abort_velocity_threshold field (its semantics live in the field description) and
condense the 13-line inline block in _probability_grid_blocks to the stage-specific
values plus the stop-threshold constraint; the parameter mechanics are already in
make_patch's docstring and the field description.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@galenlynch galenlynch force-pushed the feat-operant-abort-velocity branch from 3c37f8e to f34fdd2 Compare June 2, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow operant control to use velocity thresholds as well as distance and time

1 participant