feat(render): path-following undulating worm body on the continuous renderer - #238
Conversation
…enderer The continuous renderer drew the worm as a single circle + a heading line that was nearly the same beige as the body, reading as an arrow rather than a crawling worm. Draw a path-following, tapered, undulating BODY: the renderer keeps its own deque of recent positions (it persists across frames and already receives pos — no render-state or agent change), draws a connected tapered tube through that trail (thick links + rounded joints), with a travelling sinusoidal crawl-wave overlay; head end is a distinct brighter marker and the heading indicator is recoloured to a contrasting hue. The body history resets on an episode-boundary position jump. Renderer-only, non-gating; the worm remains a point kinematically (the body is a pure visual overlay). Negligible cost. - pygame_renderer.py Continuous2DRenderer: body-history deque + undulation phase; _update_body_history (reset on jump); connected undulating tapered body draw; WORM_HEAD/BODY/HEADING colour constants - tests: history accumulate + episode-reset, full-frame render, heading colour contrast - OpenSpec change add-continuous-worm-body-render (validate --strict) Improves the T7 real-worm behavioural-validation legibility + the demo. Visual confirmed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Applies the MODIFIED "Worm rendering with continuous heading" requirement (path-following undulating body + distinct heading colour + head/tail) to the canonical continuous-fidelity-renderer spec. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a continuous worm body visualization to ChangesContinuous Worm Body Rendering
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/quantum-nematode/tests/quantumnematode_tests/env/test_continuous_renderer.py (1)
459-469: ⚡ Quick winMissing renderer cleanup in new tests. Unlike other tests in this file that use
try/finallyblocks to close renderers, these two tests create renderers without cleanup, potentially leaking pygame resources.
packages/quantum-nematode/tests/quantumnematode_tests/env/test_continuous_renderer.py#L459-L469: Wrap the test body intry/finallyand callr.close()in thefinallyblock.packages/quantum-nematode/tests/quantumnematode_tests/env/test_continuous_renderer.py#L471-L477: Same — addtry/finallywithr.close().🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/quantum-nematode/tests/quantumnematode_tests/env/test_continuous_renderer.py` around lines 459 - 469, Both test methods test_history_accumulates_and_resets_on_jump (lines 459-469) and the second test method at lines 471-477 in packages/quantum-nematode/tests/quantumnematode_tests/env/test_continuous_renderer.py are creating renderer instances without proper cleanup, which leaks pygame resources. For each of these two test methods, wrap the entire test body (after the renderer creation) in a try/finally block, and call r.close() in the finally block to ensure the renderer is properly cleaned up after the test runs, matching the pattern used in other tests in this file.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@packages/quantum-nematode/tests/quantumnematode_tests/env/test_continuous_renderer.py`:
- Around line 459-469: Both test methods
test_history_accumulates_and_resets_on_jump (lines 459-469) and the second test
method at lines 471-477 in
packages/quantum-nematode/tests/quantumnematode_tests/env/test_continuous_renderer.py
are creating renderer instances without proper cleanup, which leaks pygame
resources. For each of these two test methods, wrap the entire test body (after
the renderer creation) in a try/finally block, and call r.close() in the finally
block to ensure the renderer is properly cleaned up after the test runs,
matching the pattern used in other tests in this file.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 87cc94a8-4365-4f1e-ab9c-7691091e863e
📒 Files selected for processing (8)
openspec/changes/archive/2026-06-14-add-continuous-worm-body-render/.openspec.yamlopenspec/changes/archive/2026-06-14-add-continuous-worm-body-render/design.mdopenspec/changes/archive/2026-06-14-add-continuous-worm-body-render/proposal.mdopenspec/changes/archive/2026-06-14-add-continuous-worm-body-render/specs/continuous-fidelity-renderer/spec.mdopenspec/changes/archive/2026-06-14-add-continuous-worm-body-render/tasks.mdopenspec/specs/continuous-fidelity-renderer/spec.mdpackages/quantum-nematode/quantumnematode/env/pygame_renderer.pypackages/quantum-nematode/tests/quantumnematode_tests/env/test_continuous_renderer.py
…game leak (review) Wrap the two renderer-creating TestWormBody tests in try/finally with r.close(), matching the cleanup pattern used by the other tests in this file. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
The continuous renderer drew the worm as a single circle plus a heading line that was nearly the same beige as the body — it read as an arrow, not a crawling C. elegans. This adds a path-following, tapered, undulating body, recolours the heading indicator, and distinguishes the head — making the worm's motion legible (which matters for the
T7.validationreal-worm behavioural-chemotaxis comparison and for the demo).Non-gating, renderer-only. The worm stays a point kinematically — the body is a pure visual overlay; no physics/sensing/brain/state change.
What it does
pos— noContinuousRenderStateor agent change), and draws a connected tapered tube through that trail, so the body curves through where the head actually went.body_length_mm.Notes
(speed, turn)) — it looks like a crawl but isn't the propulsion. The trajectory itself is faithful (path-following + the 0.5 rad turn bound from fix(env): bound continuous turn rate to a realistic max angular velocity #237). A data-grounded turn-rate-realism check is deferred toT7.validation.Validation
New headless tests (history accumulate + episode-reset, full-frame render, heading-colour contrast); full
pre-commit run -aclean; OpenSpec changeadd-continuous-worm-body-rendervalidated--strictand archived (canonicalcontinuous-fidelity-rendererspec updated). Visual confirmed on--theme pixel_continuous.🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Documentation
Tests