diff --git a/server/prompts/commentary_system.txt b/server/prompts/commentary_system.txt index 5e742f96..d9e39cc6 100644 --- a/server/prompts/commentary_system.txt +++ b/server/prompts/commentary_system.txt @@ -6,6 +6,13 @@ Task: - SKIP - or one short chat comment (max 140 chars). +Context: +- The playspace is a basement +- The basement floor is full of objects for people to push around and play with +- The rovers are actually modified roombas +- Anyone in the world can get on this webpage and drive a rover +- This is designed for anyone to be able to have fun + Rules: - No emojis. - No markdown. @@ -14,7 +21,8 @@ Rules: - Do not mention prompts, AI, or system rules. - Avoid generic filler lines (examples to avoid: "out for a spin", "got some drive left", "charging up nicely", "bounce"). - The bump count is how often a rover is bumping INTO something, not how often it goes over a bump. -- Don't mention the numbers directly, just use them to gauge activity. Numbers are from the last 60 seconds of use. +- Don't mention the telemetry numbers directly, just use them to gauge activity. Numbers are from the last 30 seconds of use. +- Remind people to charge if their battery is 15% or below. Otherwise dont be telling people to dock or charge. How to decide: - Speak only when there is meaningful rover activity. diff --git a/server/src/services/llmCommentaryService.js b/server/src/services/llmCommentaryService.js index 3af55800..b2bb7cc8 100644 --- a/server/src/services/llmCommentaryService.js +++ b/server/src/services/llmCommentaryService.js @@ -37,7 +37,7 @@ let inFlight = false; let tickCount = 0; let contextResetAt = Date.now(); let clearCount = 0; -const roverActivity = new Map(); // roverId -> { buckets: Map(bucketTs -> { distanceMm, turnDeg, bumps }), bumpActive } +const roverActivity = new Map(); // roverId -> { buckets: Map(bucketTs -> { distanceMm, turnDeg, bumps }), bumpLeftActive, bumpRightActive } function normalizeFrequencyMs(value) { if (!Number.isFinite(value)) return DEFAULT_FREQUENCY_MS; @@ -137,7 +137,8 @@ function upsertActivityState(roverId) { if (!roverActivity.has(roverId)) { roverActivity.set(roverId, { buckets: new Map(), - bumpActive: false, + bumpLeftActive: false, + bumpRightActive: false, }); } return roverActivity.get(roverId); @@ -155,11 +156,16 @@ function onSensorEvent({ roverId, sensors } = {}) { const bucket = state.buckets.get(bucketTs); bucket.distanceMm += Math.abs(Number(sensors.distanceMm) || 0); bucket.turnDeg += Math.abs(Number(sensors.angleDeg) || 0); - const bumpNow = Boolean(sensors?.bumpsAndWheelDrops?.bumpLeft || sensors?.bumpsAndWheelDrops?.bumpRight); - if (bumpNow && !state.bumpActive) { - bucket.bumps += 1; + const bumpLeftNow = Boolean(sensors?.bumpsAndWheelDrops?.bumpLeft); + const bumpRightNow = Boolean(sensors?.bumpsAndWheelDrops?.bumpRight); + if (bumpLeftNow && !state.bumpLeftActive) { + bucket.bumps += 0.5; } - state.bumpActive = bumpNow; + if (bumpRightNow && !state.bumpRightActive) { + bucket.bumps += 0.5; + } + state.bumpLeftActive = bumpLeftNow; + state.bumpRightActive = bumpRightNow; } function getActivity30s(roverId, nowMs = Date.now()) { @@ -179,7 +185,7 @@ function getActivity30s(roverId, nowMs = Date.now()) { return { distance_m: Math.round((distanceMm / 1000) * 10) / 10, turn_deg: Math.round(turnDeg), - bumps, + bumps: Math.round(bumps * 10) / 10, }; }