Your game is playable. Is it ready to train an agent?
Turning a game into an RL environment requires explicit observations, action-driven transitions, verifiable rewards, and an evaluation distribution of unseen levels; runnable source code and gameplay videos establish only part of that contract.
On this page
A person can launch a game, move around, and reach the finish. A training script may struggle even to start a clean new episode. Repeated learning requires a known starting point, interpretable action effects, explainable rewards, and a reason for every episode ending. The playable game is a starting point; these testable agreements make it an experimental environment.
Is the agent making the game or playing it?
Game-creation traces record a model interpreting requirements, writing code, and debugging. Gameplay trajectories record a player or policy observing, acting, and receiving rewards inside the game. Both may concern the same project, but they serve different learning objectives. A complete development trace does not automatically become gameplay training data, and source code does not automatically expose a training interface.
Consider a custom teaching example: collect a key, open a door, and reach an exit in a grid. There are five actions: turn left, turn right, move forward, pick up, and open. First establish whether this task can be repeated reliably; then investigate how a model might learn it. No training experiment has been conducted for this example, and it is not an exact reproduction of MiniGrid.
Separate the world, the model's input, and the display
The internal state includes the map, key location, and door lock. The agent's observation might contain only nearby cells, orientation, and whether it carries the key. Supplying the hidden map or a shortest route changes the task's difficulty. Store diagnostic information separately rather than automatically appending it to the model's prompt.
| Interface | Teaching example's contract | What to check |
|---|---|---|
| reset | Clear the previous episode and start from the level configuration | Does it actually reset the key, door lock, and step counter? |
| step(action) | Advance one defined logical step per action | What happens when moving into a wall or opening a locked door without a key? |
| observation | Local map, orientation, and key-possession flag | Does training expose the same information as evaluation? |
Gymnasium's reset returns the initial observation and info; step returns the next observation, reward, terminated, truncated, and info.[1] This specifies an interface, not a quality certification. A real-time game must also define how many frames or how much simulation time an action lasts. Otherwise the same action may have different effects on faster and slower machines.
Field names can mislead too. In MiniGrid v2.3.1's DoorKey documentation, each cell in image encodes an object, a color, and a state; it is not an ordinary RGB pixel.[3] “Images are included” therefore needs clarification: are they renderings for a person, or the actual observations delivered to the model? Those inputs can test different capabilities.
Stopping at step 200 does not necessarily mean failure
In this example, reaching the exit terminates the task and sets terminated. The game itself has no rule that declares failure after 200 steps. If the collector stops an unfinished attempt at step 200 to control sampling costs, that is an external cutoff, recorded as truncated. Both end the current sample, but they have different implications for future value.
Gymnasium explains why an external truncation should not automatically be treated as a true terminal state: some value-learning algorithms would incorrectly discard rewards that could still follow.[2] If a countdown is part of the game's rules, include remaining time in the corresponding state definition and specify whether the agent can observe it. Finite-horizon Markov modeling needs time information, but adding a timer does not make a local map a fully observed state. Do not collapse every timeout into one category, or substitute the next episode's initial observation for the previous episode's final observation.
Look for reward loopholes before admiring the score
For the teaching example, we assign +1 on first reaching the exit, zero on other steps, and end the episode at success. This is a simple task definition, not an optimal reward recommendation for every game. If an additional reward is given for issuing an open action without checking whether the door changes state, a policy might repeat that action at the doorway, increasing its score without completing the task.
| Check | Expected outcome |
|---|---|
| Try opening the door without the key | The door stays locked; no success reward |
| Keep opening a door that is already open | No repeated credit and no false task success |
| Follow a manually verified feasible route to the exit | Receive the success reward and terminate only upon reaching the exit |
| Reset to the same level configuration after an episode and repeat the route | Do not inherit the key, door state, or accumulated score |
Trace these checks to state transitions and reward calculations, not just a final score. With deterministic rules, this example should reproduce results given the same version, random seed, and action sequence. Physical simulations or networked games must also document uncontrolled randomness and acceptable deviations. A seed alone does not guarantee reproducibility.
Remembering a map is not the same as learning the task
Procgen varies the number of training levels within an environment and evaluates on unseen levels, demonstrating that good training performance can coexist with poor generalization.[4] This makes the level distribution part of the experiment. It does not establish transfer to arbitrary new games or a universal minimum number of levels for every project.
For the door example, vary the key, walls, and exit, check that generated maps are solvable, and separate training, tuning, and final holdout levels. Fix the generator version, difficulty, and interaction budget. Besides separating seeds, check for duplicate layouts: different seeds may still generate the same problem. Do not revise the holdout while inspecting its scores.
Changing textures mainly tests visual variation; changing routes tests layout adaptation; changing lock rules defines a different task again. Report success, return, and truncation rates separately for training and unseen levels. If a model only reproduces a memorized route faster, that is not evidence of general planning ability.
Keep operational readiness separate from learning results
The first layer is a runnable package: source revision, assets and dependencies, engine version, and startup instructions. The second is the experimental contract: observations, actions, timing, reset behavior, rewards, ending rules, level generation, and split configuration. The third is execution evidence: check logs, representative trajectories, anomalies, and measurements of repeated resets and sampling speed.
A fixed script that completes a feasible task, followed by random-action checks for errors, only establishes that the environment can be operated and inspected. Demonstrating useful learning additionally requires a fixed algorithm and sampling budget, comparisons with baselines such as a random policy, held-out-level results, and variability across training runs. A working interface, a reliable environment, and a more capable model are three distinct conclusions. State which one the evidence supports.
