Setting up a game for coding agents

Kyle Kukshtel’s article on agentic game development has good recommendations for setting up a game so a coding agent can work on it, starting at its “Let’s Make a Game Legible To AI Agents” section. A lot of them aren’t intuitive if you don’t usually do game development:

  • Pull every random number from one seeded source, so any game state can be reproduced.
  • Build save and load early, so an agent can get back to the same state after each code change.
  • Make every change to game state a data object like {"type": "move", "unit": 3, "to": [4, 5]} instead of a function call, which is the command pattern. Logging the objects as the game runs lets you replay a bug from a saved state, and an agent can write its own list and play it back.
  • Run the simulation (the game’s rules) as its own library, so it can be tested without a game engine.

Giving the agent eyes through screenshots comes naturally if you usually do web development. The article adds using odiff to diff each screenshot against a target image of how it should look, which gives the agent a percentage of differing pixels to drive down.