AI CHOREOGRAPHY / THE AI / LEVEL 2 OF 5
Never trust
the answer.
The prompt asks politely for eight poses within reach, but an AI does not always obey. It may return six poses, a hand two metres away, three squats in a row, or a title full of symbols. So before anything reaches the coach, validateCoachReply checks the reply: wrong structure is rejected, numbers out of range are pulled back in. This page runs it on any reply you write.
An AI reply
edit it, or pick a casevalidateCoachReply
What the AI asked for
What the coach will dance
The real code
coachAI.jsTwo kinds of problem, two reactions. A broken structure throws an error: the scene catches it and keeps the previous routine (level 3). A value that is merely too big is clamped with limit, because the rest of the answer is still useful. The ranges are the same as in the prompt.
What you should be able to explain
- Reject or repair. Missing poses or a hand that is not three numbers cannot be fixed safely, so the whole reply is rejected. A number out of range can be fixed by clamping it, so it is.
- Safety is the game's job. The prompt asks for comfortable moves; the validator guarantees them. A player in a headset cannot see the room, so a pose must never send a hand far behind or overhead.
- Only known fields survive. The cleaned pose is rebuilt from
a,b,squatandsway. Anything else the AI adds is dropped, so nothing unexpected reaches the shared state. - The title is cleaned too. It is drawn with the scene's line font, which has only plain letters and digits, and it is shown on both headsets.
Exercises: ① Pick "a hand out of reach": which numbers changed, and to what? ② Change one pose's a to [0.2, 0.3]. Why is that rejected instead of repaired? ③ Pick "three squats": which squats are kept?