AI CHOREOGRAPHY / THE AI / LEVEL 1 OF 5
Ask for data,
not code.
The AI knows nothing about this game. So the scene never sends just your idea: it wraps it in a message that explains the job, the coordinate system, the safe ranges and the exact JSON shape of the answer. The AI replies with numbers, never code, and the numbers are in the same form as the game's built-in poses. This page builds that message with the scene's own coachAI.js.
What is sent to the AI
built by the real functions, liveTry it
Your movement idea
For a reply, the input is not text: it is the poses you recorded with your body (level 4), written as the same numbers. Three recorded poses are used here.
How a hand is written
[0.25, -0.55, 0.05] = hand 25 cm out, 55 cm below the head, 5 cm forward: arms hanging by the sides.
What travels to the server
The two prompts
coachAI.jsBoth prompts share the rules (the ranges match the limits used in level 2) and end with an example of the exact JSON shape. Your idea is inserted with JSON.stringify, so quotes or line breaks in it cannot break the message.
Asking for JSON
aiquery.js (the course's starter kit)askAIJson adds one more instruction, sends the text to /api/aiquery on the course server, and turns the answer into an object with JSON.parse, even if the AI wrapped it in a markdown code block. The server adds the OpenAI key from .env, so the key is never in the web page.
What you should be able to explain
- The AI has no context. Everything it needs, including what a pose is and how big a body is, must be in the message.
- Data, not code. The answer is a title and a list of poses. The game already knows how to perform poses, so the AI only decides what to dance, never how. The course's
askSceneCoderasks for code instead, and that code can fail to run. - The same form as the game's own data. AI poses use the coordinates of the built-in routines and the recorded poses, so all three can be mixed, scored and shared in the same way.
- The key stays on the server. The browser calls the course server; only the server knows the OpenAI key. Anyone can read a web page's code, so a key in the page would be public.
Exercises: ① Type an idea with quotation marks in it and find how it appears in the message. ② Which sentence keeps the routine loopable? ③ Why does the prompt give an example answer instead of only describing the format?