feat: Agent movement + autonomous behavior system (#67, #68) #71

Merged
perplexity merged 1 commits from feat/agent-behaviors into main 2026-03-19 20:30:25 -04:00
Owner

Summary

Agents are alive. They wander the world, ponder, inspect objects, converse with each other, and place artifacts. No more static orbs.

What changed

Movement system (agents.js, +121 lines)

  • moveTo(target, speed, onArrive) — smooth interpolation toward target
  • Per-frame position updates with delta-based stepping
  • Ring spins faster during movement (visual cue)
  • Connection lines update per-frame to follow agents
  • moveAgentTo(), stopAgentMovement(), isAgentMoving() exports

Behavior system (behaviors.js, 414 lines)

Per-agent state machine with weighted personality:

Behavior Duration What happens
idle 5-15s Standing still, gentle pulse
wander 8-20s Roaming to random world point
ponder 6-12s Stopped, emits a thoughtful bark
inspect 4-8s Moves to nearby point, examines
converse 8-15s Two agents approach each other, connection pulses
place 3-6s Creates a small artifact (scene_add)
return_home variable Returns to spawn position

Personality weights:

  • Timmy: ponders most, converses often
  • Kimi: inspects most (scout)
  • Claude: converses most (senior engineer)
  • Replit: builds most (lead architect)
  • Perplexity: inspects and converses evenly

WS message types (3 new)

  • agent_move — backend-driven movement
  • agent_stop — cancel movement
  • agent_behavior — override autonomous loop (backend takes control)

When a backend sends agent_behavior, the autonomous loop yields for that agent until the override duration expires.

Protocol docs

~80 lines added to PROTOCOL.md covering all three message types and the behavior state table.

Testing

  • 87/87 smoke tests pass
  • Zero runtime errors in Playwright (27+ seconds observed)
  • 24 FPS maintained — no regression
  • Vite build: 82KB app + 487KB Three.js (within budget)
  • Agents visibly wander, ponder, converse, and place artifacts within 10s of page load
  • Connection lines dynamically stretch to follow moving agents
  • Barks fire contextually (different lines for ponder vs inspect vs converse)

Refs

  • Closes #67 (movement system)
  • Closes #68 (behavior system)
  • Foundation for #69 (cognitive bridge) and #70 (WS gateway)
## Summary Agents are alive. They wander the world, ponder, inspect objects, converse with each other, and place artifacts. No more static orbs. ## What changed ### Movement system (`agents.js`, +121 lines) - `moveTo(target, speed, onArrive)` — smooth interpolation toward target - Per-frame position updates with delta-based stepping - Ring spins faster during movement (visual cue) - Connection lines update per-frame to follow agents - `moveAgentTo()`, `stopAgentMovement()`, `isAgentMoving()` exports ### Behavior system (`behaviors.js`, 414 lines) Per-agent state machine with weighted personality: | Behavior | Duration | What happens | |----------|----------|--------------| | `idle` | 5-15s | Standing still, gentle pulse | | `wander` | 8-20s | Roaming to random world point | | `ponder` | 6-12s | Stopped, emits a thoughtful bark | | `inspect` | 4-8s | Moves to nearby point, examines | | `converse` | 8-15s | Two agents approach each other, connection pulses | | `place` | 3-6s | Creates a small artifact (scene_add) | | `return_home` | variable | Returns to spawn position | Personality weights: - **Timmy**: ponders most, converses often - **Kimi**: inspects most (scout) - **Claude**: converses most (senior engineer) - **Replit**: builds most (lead architect) - **Perplexity**: inspects and converses evenly ### WS message types (3 new) - `agent_move` — backend-driven movement - `agent_stop` — cancel movement - `agent_behavior` — override autonomous loop (backend takes control) When a backend sends `agent_behavior`, the autonomous loop yields for that agent until the override duration expires. ### Protocol docs ~80 lines added to PROTOCOL.md covering all three message types and the behavior state table. ## Testing - ✅ 87/87 smoke tests pass - ✅ Zero runtime errors in Playwright (27+ seconds observed) - ✅ 24 FPS maintained — no regression - ✅ Vite build: 82KB app + 487KB Three.js (within budget) - ✅ Agents visibly wander, ponder, converse, and place artifacts within 10s of page load - ✅ Connection lines dynamically stretch to follow moving agents - ✅ Barks fire contextually (different lines for ponder vs inspect vs converse) ## Refs - Closes #67 (movement system) - Closes #68 (behavior system) - Foundation for #69 (cognitive bridge) and #70 (WS gateway)
perplexity added 1 commit 2026-03-19 20:24:45 -04:00
Movement system (agents.js):
- moveTo(target, speed, onArrive) with per-frame interpolation
- stopMoving(), isMoving getter, homePosition tracking
- Ring spins faster during movement (visual feedback)
- Connection lines update per-frame to follow moving agents
- Exports: moveAgentTo, stopAgentMovement, isAgentMoving
- updateAgents now receives delta for time-based interpolation

Behavior system (behaviors.js, 414 lines):
- Per-agent state machine: idle, wander, ponder, inspect, converse,
  place, return_home
- Personality weights per agent (Timmy ponders more, Kimi inspects
  more, Claude converses more, Replit builds more)
- Converse: two agents approach each other, connection line pulses
- Place: agent creates small artifacts via scene_add (capped at 5/agent)
- Contextual barks for each behavior
- WS override: agent_behavior message pauses autonomous loop
- Throttled decision-making (0.5s interval, not per-frame)

WS handlers (websocket.js):
- agent_move: backend-driven movement
- agent_stop: cancel movement
- agent_behavior: override autonomous loop via custom event dispatch

Integration (main.js):
- initBehaviors() after initSceneObjects()
- updateBehaviors(delta) in render loop
- disposeBehaviors() in teardown
- updateAgents(now, delta) — passes delta for movement interpolation

Protocol (PROTOCOL.md):
- agent_move, agent_stop, agent_behavior specs with JSON examples
- Autonomous behavior state table with durations

Refs #67, #68
perplexity merged commit 80c65ab7f3 into main 2026-03-19 20:30:25 -04:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: perplexity/the-matrix#71