Game Too Slow? What to Tell AI to Get It Smooth
If your game is too slow, tell your AI exactly when it happens, and have it measure before it changes anything. "Make it faster" invites guessing, while "it drops to 21 frames a second after two minutes" points straight at the cause.
How do you know how slow it is?
Games draw one picture after another, and each picture is called a frame. At 60 frames a second, the game has about 16.7 milliseconds for each one. If a frame takes longer, the game stutters.
You can see this yourself. In Chrome, open the developer tools, go to the Rendering tab and tick Frame rendering stats. A small box in the top corner of the page now shows your frame rate as you play.
Write down three things: the rate at the start, the rate at its worst, and what was happening at that moment.
What does the pattern tell you?
When the game gets slow says more than how slow it gets.
| What you notice | Common cause | What to tell your AI |
|---|---|---|
| Slow from the first second | Pictures far larger than they appear, or heavy effects on everything | "List the largest pictures and how big they appear on screen." |
| Slows when the screen fills up | Every object checks every other object | "Count how many checks happen in one frame when the screen is full." |
| Gets slower the longer you play | Things get created and never removed | "Count all objects every 30 seconds and show me what grows." |
| Fine on a laptop, bad on a phone | The phone has less power for the same work | "Measure with a slowed-down device setting." |
What does a good diagnosis look like?
Say you are making Beetle Swarm, an invented shooter. It starts at 60 frames a second and falls to 21 after two minutes.
If you say "make it faster", your AI may shrink the pictures and remove the explosions. The game gets uglier, and two minutes in, it is slow again.
If you say what you measured, your AI counts the objects. Enemies stay level, but shell casings climb to 4,000. They leave the screen and are never removed, so the game keeps moving and checking every one of them. One small change removes them when they leave, and the rate stays at 60 with the explosions intact.
The usual culprits are on MDN's list of ways to speed up a canvas, the area where many web games draw: blur shadows, drawing text, scaling pictures as they are drawn, and heavy physics libraries. Your AI knows these. What it does not have is your measurement. If a speed fix breaks something else, go on to my game keeps breaking.
Paste this to your AI
My game is too slow. Do not change anything yet.
What I measured: [rate at the start], falling to [worst rate].
When it happens: [one sentence].
1. Draw one frame of the game as a Mermaid diagram: everything it does in order, such as updating, checking collisions and drawing. Next to each step, put the time it should take, out of about 16.7 milliseconds in total.
2. Measure what each step really takes in the slow moment. How you do that is up to you. Show me the step where the real time leaves the drawing. If you could not measure, say so, and tell me what I can do to get the figure. Do not guess a cause and present it as found.
3. Tell me how many objects exist at the start and at the slow moment.
4. Suggest one change, aimed at that step. Make it after I agree, and give me the before and after figures. Keep every effect unless I agree to remove it.
Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP
How to check it worked
- Measure again the same way. Same place, same moment, same machine. You want a number, not a feeling.
- Play twice as long as before. Slowdowns that build up need time to show themselves.
- Fill the screen on purpose. Find the worst case you can make.
- Compare how it looks. If effects vanished without your say, ask for them back.
- Try a phone or an old laptop. A fast computer hides a lot.