How to edit an AI-generated game
The build runs, the character still walks through the wall, and the line that causes it sits in a file of four hundred lines that you did not write. Editing what an agent produced is a reading problem before it is a writing problem: find the file that owns the behaviour, change only that, and give the change a check that fails before it passes.

Read the project before you read the prompt
Editing starts with deciding what you are editing. A generated game is a set of files and a build, not a paragraph of code in a chat window, and every later step depends on being able to open the right file and run the build yourself. In AI in video games this is the step teams tend to skip, and skipping it is how a small fix turns into a long one.
You edit an AI-generated game in the project that produced it, not in the conversation where it was generated. The generator left you two things: a build that runs and the files behind it. The files are what you can change, and the build is how you check that you changed them correctly. In AI for game development that is the line between editing and regenerating.
That sounds obvious, and it is where most first edits go wrong. The result of a generation session reads like an answer, so the natural instinct is to scroll back, find the snippet, and paste over the file. A snippet is a slice of one file, and the behaviour you want to change may live in three more files that the snippet never mentioned. A text to game AI platform gives you the whole project instead, which is why its output is editable at all.
So the first thing to do is not to read anything. It is to make the project run yourself, from a clean checkout, with the command the project already documents. If the build does not run from the checkout, that is a different problem from the bug you came to fix, and mixing the two is how a small edit turns into a lost afternoon. An Unreal Engine 5 project gives you that command in the editor; a text to game AI platform build gives it to you in a package file. Two starting points decide this: the editor you can open, and the build you can run.
| What you have | What it actually is | What to do with it |
|---|---|---|
| The reply in the conversation | A slice of one file, with no record of the rest of the project | Do not edit from here; use it to find the file it came from |
| The project files | The only thing that ships, and the only thing you can change | Edit here, and keep every change in the project |
| The build command | How you check your own work without a second opinion | Run it before you change anything, so you know the baseline |
| A published link or a hosted preview | A frozen version of the project; edits need the source behind it | Get the source first, or accept that you cannot change this copy |
Once the build runs, one job is left in this step: find the file that owns the behaviour you want to change. Ownership is usually obvious in the file name and sometimes in a single function, but not always. Generated projects tend to put movement in one script, the shape of the level in a data file, and the rules that connect them in a third. The same three-file shape comes out of an H5 game generator more often than not.
The signal that you have found the right file is boring and reliable. Change one number in it, run the build, and watch the behaviour move. If nothing in the game changes, you have the wrong file, or the number is read from somewhere else. That test costs one build, and it saves an afternoon of editing the wrong code.
Reproduce the baseline before you touch anything, and write down what you saw. A game that already misbehaves in one way will hide a second defect, because you will attribute the symptom you notice to the change you just made. Two minutes of notes before the first edit is what lets you tell the two apart later, and in AI for game development it is also what you show the next person.
There is one case where none of this applies. If the generator gave you a single block of code to paste into a file you already had, then you are not editing a project, you are replacing one file, and there is no ownership to find. Treat that differently: keep a copy of the file you are replacing, change as little as possible inside it, and keep the checks that file already had. A text to game AI platform hands you a project, so this case is the exception rather than the rule.
With the right file open and the build running, the next thing to do is read it.
Read the file before you change the line
The file you open may be four hundred lines of code you did not write. You are not expected to understand all of it, and you do not need to. You need to find the places a behaviour can live and read those. A text to game AI platform hands you the file with the same four hundred lines in it, and the reading is the job either way.
You do not need to understand the whole file, and trying to is the slowest way to work. Generated code has a shape, and in most projects the behaviour you care about lives in one of four places: the constants, the state, the update step, and the rule that reacts to an event. An H5 game generator produces the same four places, which is why the same reading habit works on both.
Constants come first, because they are the cheapest to change and the easiest to recognise: numbers with names, a gravity value, a jump height, a scroll speed, a coin count. They sit in a block near the top or in a configuration object, and changing one of them is usually the whole fix. In an Unreal Engine 5 project that block is named, and the name is in the file you open first.
State is what the game remembers between frames: the player position, the score, whether the level is finished, which keys are down. It usually lives next to the code that changes it, and it is where a bug survives a restart, because state created once and never reset behaves correctly in a single session and wrong in the next one. That is the defect AI in video games teams tend to find last.
The update step is the loop that runs every frame: movement is applied, collisions are tested, the score is compared. This is where the timing assumptions live, and it is worth reading even when your change is only a number, because it tells you whether the code counts frames or time. An Unreal Engine 5 tick does the same job under a different name.
The event rule is the last place: what happens when you land, when you pick something up, when the level ends. It is usually a function with a name that reads like an intention, and it is where to look when the behaviour is wrong in a way you cannot describe as a number. It is also where an agent is most likely to add a second copy of itself, so read it before you ask for anything.

| Where it lives | What it holds | What it looks like when it is wrong |
|---|---|---|
| The constants | Named numbers that set the feel of the game | The game is too fast, too slow, too floaty, or the wrong amount of something |
| The state | What the game remembers between frames and between runs | It works once, then the second session starts in the wrong place |
| The update step | The per-frame order of movement, collision and scoring | The behaviour differs between devices, or depends on when the check ran |
| The event rule | What happens on landing, on pickup, on the end of the level | One situation goes wrong and nothing else does |
A five-minute pass over a file you did not write looks like this: find the entry point, skim the constants, find the variables that change, find the loop, and read the one function your bug lives in. The rest of the file is context you may never need, and reading it end to end is the mistake that makes generated code feel expensive to touch. Five minutes is also the budget an AI in video games team usually gives you.
The signal that you have read enough is that you can name the line your change belongs on and say what the value means there. You do not need to understand the whole function to change one number in it, but you do need to know what the number means, or you are replacing a wrong number with a different wrong number. That is the standard an H5 game generator does not meet, because it hands you behaviour you never wrote.
Some files are genuinely hard to read, and that is information about the project rather than about you. A file that mixes the rules with the drawing and the input handling is a file where every change carries risk, no matter what produced it. When that is the file your bug lives in, the honest options are to make the change carefully with a check behind it, or to move the behaviour into its own file first. Both cost more than the first edit would have, and both cost less than the fourth broken change.
From here the remaining questions are about the size of the change and the check that keeps it honest.
Nothing about that changes when the project is large. An Unreal Engine 5 codebase with a thousand files is edited much the same way as a browser build with ten, and the tool that reads it fastest is the one you point at the right file first.
Change one thing and keep the diff readable
The size of the diff is the thing you control. A diff you can read end to end is a diff you can approve; a diff you cannot is a change you are trusting rather than checking. That rule is the same whether the project came from an H5 game generator or from an engine you have been working in for a year.
Change one behaviour per edit, and keep the diff small enough to read in one sitting. The reason is not tidiness. A diff is the only record of what changed in your project, and a diff you cannot read is a change you are accepting on trust, which is the exact position you were trying to get out of when you decided to edit it yourself. AI in video games teams tend to get this one right early, because a live title does not let you guess.
There is a practical size limit. When the diff is a screen or two, you can check every line against what you asked for, and you will notice the line that does not belong. When the diff is a hundred lines spread over four files, you stop checking and start skimming, and a reviewer who is skimming approves whatever looks tidy. An Unreal Engine 5 build makes the temptation worse, because the build itself takes long enough to encourage a skim.
One behaviour · one or two files · every line has a reason you can name · you can say what each hunk was for
Several behaviours in one edit · files you did not expect to change · hunks you cannot attribute · a rewrite wearing a fix’s clothes
Order your edits by how far they reach. A number is the cheapest: jump height, coin count, a speed value, a colour. A behaviour change is next: what happens when you land, whether the door opens, how the score updates. A resource or path change comes after that, because a wrong path breaks the build in ways that look like a logic bug. A mechanic is the most expensive of all, because it touches the code, the level data and the checks at once.
Most of the time the first three cover what you came to do. The temptation to change a mechanic while you are in there is the one to resist, because the mechanic change is the one you will not be able to review properly in the same sitting.
Sometimes a single change genuinely lives in several places. A constant copied into three files is the usual case, and the fix is to give it one home before you change it: move it into the configuration the project already reads, point the three call sites at it, verify the build, and only then change the value. The next edit to that number is a one-line diff, and the ones after it stay that way. This is the habit that makes AI for game development cheap rather than expensive.
Two rules decide whether an edit is ready to keep. The diff shows only the behaviour you asked for, and you can explain every line in it. If either one fails, the edit is not finished, no matter how the game looks afterwards.
An Unreal Engine 5 project is no exception: the diff is larger, the build is slower, and the same three rules hold — one behaviour, one file, one check. An agent that rewrites the whole project shows you a larger diff than the one you asked for, and a larger diff is harder to review.
A small diff tells you what changed. It does not tell you whether the change was right, and that takes the next step.
Give every change a check that fails before it passes
A change without a check has no definition of done. The check is what separates a fix you verified from a fix you believe in, and the order matters: a check that has never failed is not yet a check.
Every change gets one check, and you watch it fail before you watch it pass. If you write the check after the fix, you have written it from the shape of the fix, and it will agree with whatever the fix does. If you write it first, it states what you expected, and the moment it goes green you know the change did what you wanted rather than what you wanted it to do. In AI in video games this is the habit that keeps a live title shippable.
The check does not have to be a test framework. For a jump height it can be three lines: start the build, hold the jump key, and measure the height of the apex against a frame you captured before the change. What matters is that someone else can run it and get the same answer, and that the answer is a number or a state rather than a feeling. In an Unreal Engine 5 project the editor gives you the same three lines for free.
An assertion
The check runs inside the build. A number that has to hold after the change: the score resets on a new run, the coin count never goes negative, the level ends on the flag. Fast to run and easy to trust, and easy to forget exists once you stop adding them.
A scripted move
The check drives the game. A recorded sequence of inputs or a script that presses the keys, followed by a value it prints. Use it when the behaviour only shows up in motion, and it is the one that catches timing and collision errors. It is also the check an H5 game generator gives you most easily, because the whole game runs from a link.
A before-and-after pair
The check is a comparison: two captures of the same frame, one before the change and one after. The weakest of the three and the one that catches the most, because it also catches the change you did not mean to make.
Make the check specific to the behaviour. The most common mistake is a check that is too broad: the build starts, the game loads, the score is a number. All of that can hold while the thing you changed is broken. The check has to name the behaviour you touched, and it has to fail when that behaviour is wrong.
The signal that a check is too weak is that it was green before your change as well. If the check passed beforehand, it was not measuring the behaviour you changed, and it will not tell you when you break it either.
Some changes have no automatic check. Art, level layout and sound need a human look, and the honest version of a check there is a repeatable step: the same route through the level, the same frame, the same comparison every time, written down so the next person does what you did. A screenshot with no route behind it is not a check, because the next person will not reach the same frame. An H5 game generator makes the route easy to write down, which is one more reason its output is editable.
Keep the check in the project rather than in your head, and keep it next to the behaviour it watches. A check that lives in a message thread or in a file called notes is a check that stops existing the moment you need it. The second benefit shows up later: a check is the only thing that tells you whether the next change broke the last one. Without it, every change carries fresh risk and the project gets slower as it grows. In AI for video games that slowdown is what a patch queue turns into.
When the check itself turns out to be wrong, fix the check before you trust the fix. A test written by the same agent that wrote the code can agree with the code rather than with the behaviour, and it will pass forever while the game is broken. In AI for game development that is a routine failure, not an exception, and it is one of the four reasons the next change needs a check of its own.
In AI in video games this is where a lot of the cost sits. The agent that wrote the code also wrote the check, so the check agrees with the code, and the two are wrong together until a person reads them apart.
Checks watch behaviour, and behaviours come in two kinds that should never be edited together.
Change the rules and the content separately
A generated project usually separates what the game does from what the game contains, often in a data file next to the code. Edit the two separately, and you keep the diff small and the failures diagnosable. A text to game AI platform is an H5 game generator that keeps that split by default, which is the part worth having. The same kind of project splits the same way: content in one file, rules in another.
Split the changes by kind: the rules that decide what happens, and the content that fills them in. A jump height and the number of platforms are different kinds of change, and they belong in different files even when the generator put them in the same one. In AI in video games the split is also what lets two people work on the same title in the same week.
The reason to split them is what a failure looks like. When a rule is wrong, the game misbehaves in a way you can describe, and you look for it in the code. When content is wrong, the game looks wrong in one place, and you look for it in the data. Merged together, a content mistake looks like a rule mistake, and you spend an hour in the wrong file.
How the game behaves: movement, collision, scoring, the ending. They belong in the code, they break everything at once, so they need the check from the previous section and they need the diff kept small.
What the game contains: levels, positions, names, counts, art. They belong in the data, they break one thing at a time, and they are cheap to change and cheap to undo.
A text to game AI platform hands you a project with the same split, and the same temptation: the level file is easy to edit and the rule file is easy to rewrite. An H5 game generator gives you the same split, and keeping the two apart is what stops a content pass from turning into a rewrite.
Content is where most of the work of a first game is, and it is the cheaper half. The cost of adding a level is data. The cost of adding a mechanic is code, checks, and a rebuild of everything around it. When you are choosing between adding content and adding a mechanic, content is almost always the better trade, and it is the trade that keeps the diff small enough to review.
The signal that a change landed in the wrong file is that you touched a value and nothing happened. It means the number you changed is not the one the game reads, which usually means there is a second home for it. A second home is worth removing while you are there, because every later edit inherits the confusion.
The exception is a project that put everything in one file, which many generated projects do for a good reason: there is nothing to install and nothing to configure. Splitting that file is a refactor, and a refactor changes no behaviour of its own. Give it its own diff and its own check, separate from the change that motivated it, so that when something breaks you know which half did it.
Keep the split visible in the project rather than only in your head. When the rules and the content live in different files, anyone who opens the project can see which is which, including the agent you ask for the next change. When they live in one file, every future request has to name the place, and one missed word turns a content edit into a rule edit.
Once you know which file and which kind of change, the next question is who makes the change.
Ask for the edit, not the rewrite
An agent that has read the project can make the edit faster than you can, but only inside a scope you set. The wording of the request decides whether you get a diff you can review or a file you have to read again from scratch.
Ask for the change, not the rewrite, and say where the change is allowed to happen. Improve the jump invites a rewrite of the movement script. Change the jump height in one named file, leave everything else alone, and show me the diff produces an edit you can read.
Change the jump height in src/player.js from 3 to 4.2.
Do not change any other file. Do not refactor the movement code.
Keep the existing check for the jump apex and make sure it still passes.
Show me the diff before you save.Four things in that request do work. The file removes the guesswork about where the change belongs, which is the guesswork you just did by hand. The exclusion is what keeps the diff from growing into a rewrite of the file you pointed at. The check asks the agent to keep the thing that already worked. The diff turns the result into something you review instead of something you accept. The same four work in an Unreal Engine 5 project.
The signal that a request was too loose is a diff that touches files you did not name. It is not automatically wrong, but you did not ask for it, so it needs its own review. The usual cause is a request that described a symptom instead of a behaviour, which left the agent to guess where the behaviour lives, and it guessed by changing more than one thing.

When you hand a change to an agent, you need to know enough to judge the answer. That is the real limit on delegation here. If you cannot say what the correct result looks like, you cannot tell a correct diff from a confident one, and the speed you bought is paid for with the review you skipped.
There are two ways to hand the work over, and the difference is where you put the effort. Handing over the behaviour makes the agent read, decide and write, and you review the result. Handing over the exact line, the exact value and the exact check makes the agent write, and you review a diff of a few lines. The second is faster when you already know where the change goes, which is the situation you are in after the first three sections of this page.
Paste the failing output into the request when you have it. A check that fails with a number in it tells the agent more than a description of the symptom, and it removes a whole turn of the agent guessing what you meant. In AI in video games the failing output is usually the most valuable line in the whole request, because it is the only part of the bug that is not a guess.
What an agent should not decide is the design. If the change alters how the game plays, write the behaviour out first, in one or two lines, and let the agent implement that. The judgement about what the game should do needs a person, and it is the part that is expensive to get wrong in code. In AI in video games that judgement is the last thing to automate, and the first thing to lose.
All of this assumes the change was small and checked. Some generated code passes those tests and is still wrong in ways that never show up on screen.
Hunt the defects that still look right
Generated code fails in a small number of recurring ways, and they share a property: the screen looks correct. You find them with specific checks rather than with a second look. The list is the one an AI in video games team keeps beside the build, because these failures are not about the model: they come from how the project is put together, which is why the list stays short.
A build that runs proves the main path works. It says nothing about the edges of the map, the state after a restart, the unit a value is measured in, or whether the configuration file is even the one the code reads. These are the defects that survive a play session, because the session never visits them.
| The defect | What you see | The check that finds it |
|---|---|---|
| The edges are not handled | Nothing, until the character walks out of the level | Walk into each of the four edges and confirm the game stops it |
| State survives a restart | The score or position from the last run | Reload the page and confirm the game starts from zero |
| A value is in the wrong unit | The game looks slightly slow, or slightly floaty | Change the value by a known amount and compare against a frame you already have |
| The configuration is never read | Nothing; the setting simply does nothing | Change the setting and confirm the behaviour moves |
| Time is counted in frames | Fine on your machine, different on another | Run the same input on a second device and compare |
The first one is the most common, because a generated level usually has a boundary the code never asked about. The second is the most annoying, because it only shows up when the player comes back. The third and the fourth look identical from the outside, and both fall to a check that changes one value and watches the game respond. In AI in video games these five rows are the ones that usually decide whether a live title survives its next patch.
The last row is the one that only shows up on hardware you do not own. Code that counts frames behaves differently on a screen that refreshes faster, and code that reads the clock differently still. If the game ships to devices you cannot test on, that is a risk you accept on purpose rather than discover from a report.
When you cannot reproduce a bug, treat that as information rather than as failure. A defect you cannot trigger is often a defect that has not been reached yet, and the path you failed to trigger is the thing to write down, because the next person will hit it too. In AI in video games that note is the difference between a bug report and a fix.
The signal that a defect class applies to your project is simple: write the check before you find a bug of that kind. A checklist you have already run once is worth more than a long list of things that might be wrong, because it becomes a routine that survives the next change. In AI in video games the routine is usually cheaper than the fix.
These are categories, not verdicts. Nothing here says your generated game has any of them. They are the recurring shapes, and writing them down is what turns them into a couple of minutes of checking instead of a rediscovery from a bug report.
None of this is specific to one generator. It is the list an AI in video games team keeps next to the build, and the reason it works is that every row is a check somebody can run in a minute.
When you find one, fix it the way you fixed the original: one behaviour, one file, one check. A defect found late is still a small edit as long as you treat it as a behaviour and not as a rewrite of the area around it.
These seven sections are the edit loop. The questions that come up most often are below.
