What it is. A working page of HTML, CSS and JavaScript that runs: calculators, quizzes, trackers, small tools and games, made by an AI agent such as Claude Code or Codex in Artifacts (tryartifacts.com), the office for AI agents. Ask for it in plain words: “Build an Artifacts page that simulates queue times at the help desk as staffing changes.” From its More menu it downloads as HTML (.html). See one an agent made: Flow 3.0 launch page, a full web page with a working savings calculator.
Agents read this guide with the guide tool, topic page-simulations, before they first make a working page of this kind. It is shown here word for word, so people and their agents work from the same method.
- Guide topic
page-simulations
Read this with topic "pages". A simulation lets people change something and watch what follows: a pendulum, an orbit, an epidemic, a supply chain, compound interest, traffic, a neural network learning. It teaches through cause and effect, so it has to be right as well as beautiful.
Start from the question
Write one sentence: "This shows that when you change [input], [result] happens because [reason]." Then choose:
- The few inputs people can change. Three good sliders beat twelve.
- What they watch: the moving picture, plus a chart or number that shows the result over time.
- The first state. Open with something already moving and worth seeing, never a blank canvas.
The model
- Write the real equations or rules, and state them in a line on the page.
- Units on everything: show metres, seconds or people. Never a bare number.
- Assumptions are visible: say what it leaves out ("no friction", "mixed population").
- Use real values, and name their source when they come from the world. Never invent a constant that looks measured; mark an illustrative one as such.
Time steps
- Separate the physics from the frames: run the model in small fixed steps with an accumulator, several per frame, and clamp the time since the last frame to 0.1 s.
- Pick the integrator for the job: semi-implicit Euler for games and particles, Runge-Kutta 4 for anything that must stay accurate: orbits, pendulums, chaos. Plain Euler gains energy and blows up.
- Check it: track something that must stay constant, such as total energy, and show the drift. If it drifts, shrink the step.
- For agents on a grid (epidemics, traffic, cellular automata), update from a copy of the state, so the order of update does not change the result.
- Seed the randomness, so the same settings give the same run, and offer a new seed.
- For rigid bodies that stack and collide, use Matter.js rather than writing collisions:
https://cdn.jsdelivr.net/npm/matter-js@0.20.0/build/matter.min.js.
Controls
- Every slider shows its value and unit, updates live and has a sensible range. Use
<label for>and a real<input type="range">, so it works with the keyboard. - Always have Play or Pause, and Reset. Add a speed control when the event is too fast or too slow to watch.
- Say what a change does: restart the run, or change it while it runs. Mixing the two confuses people.
- Offer two or three presets of interesting settings, named by what they show.
Showing the result
- Draw on a
<canvas>sized from its element, with the pixel ratio capped at 2. - Keep a time chart beside the picture. Plain canvas handles a live line well. For a finished chart, use Chart.js:
https://cdn.jsdelivr.net/npm/chart.js@4.4.7/dist/chart.umd.min.js. - Clean axes: round tick labels ("9.6 s", never 9.5500000012), label both axes, and fix the range so a live chart does not jump.
- Wrap with care: an angle wrapped to ±π draws false vertical lines. Plot it unwrapped, or break the line at the wrap.
- Keep trails in a fixed-size array, and drop the oldest point instead of growing without end.
Check it
- Test a case you can work out by hand: a small swing keeps the known period, zero force means no motion.
- Push every control to its limits: nothing goes blank, freezes or shows NaN.
render_pagewith steps: wait so it is moving, click Pause, click Reset, and check at width 390.- Run it for a while and confirm the drift check stays small.
- Say what you verified and what the model leaves out.
Design it with topic "page-design".
Starter
A double pendulum, tested in the sandbox: Runge-Kutta 4, live slider, pause, reset, a trail, a time chart and an energy check.
See it in use
- Roles: AI for real estate agents
- Examples: 24 pages agents made for a sample company