Coyote Jump is a small pixel platformer with one idea: the game should forgive late jumps. Its levels can also be built by a model. This post covers the agentic level generation: 21 level-building tools, a validator that proves each level can be beaten, and a retry loop that feeds errors and fix hints back to the model. The code is public, and you can play a generated level now.

The game feel the levels must respect
Coyote time keeps a jump available for 100 ms (6 ticks of the 60 Hz fixed timestep) after you run off a ledge. Jump buffering remembers a press made up to 100 ms before you land. Variable jump height caps upward speed when you release early, so a tap is a hop and a hold is a full jump. Together they make a 5-tile gap comfortable to cross.
That matters for generation. A level is only fair if the people who play it, not frame-perfect robots, can clear it. The generator has to know the real jump limits, so those limits are part of the tools.
A level is plain JSON
A level is a 12-row grid of 16 px tiles, described by ground, platform, spike and block segments plus coins, checkpoints, a goal and enemies (walker, bat, hopper). The format is documented in docs/LEVEL_FORMAT.md and published as a JSON schema.
{
"version": 1,
"name": "MOONLIT LEDGES",
"width": 123,
"theme": "hollow",
"spawn": { "col": 2, "row": 8 },
"segments": [
{ "type": "ground", "from": 0, "to": 15, "top": 9 },
{ "type": "platform", "from": 56, "to": 59, "row": 3 }
],
"goal": { "col": 120, "row": 8 },
"enemies": [{ "kind": "bat", "col": 92, "row": 2, "range": 36, "amp": 10 }]
}
21 tools, in two function-calling formats
tools.json holds the same 21 tools in OpenAI and Anthropic function-calling format, generated from one source file. They are mostly level components that build left to right from a cursor: start_area, ground, gap, stairs, floating_platforms, enemy_gauntlet, coyote_challenge (a runway, a 5-tile gap and a landing), spike_hop, checkpoint, coin_trail and end_area. Low-level tools place segments, enemies and coins at absolute positions. undo, get_level, validate_level and play_url round out the set.
Each call returns {ok, ...}. A bad call returns {ok:false, error, hint} and changes nothing, so a model can try again from a clean state. new_level returns the jump limits as guidelines, so the model knows before it places a gap that a flat gap can be at most 5 tiles wide.
A typical sequence for the prompt "a night-time level with bats and two 5-tile coyote gaps" looks like this:
new_level{name:"Moonlit Ledges", theme:"hollow"} -> start_area -> ground{length:6,coins:4}
-> gap{width:3} -> enemy_gauntlet{kinds:["walker","hopper"]} -> coyote_challenge{gap_width:5,rise:1}
-> stairs{steps:3} -> floating_platforms{count:3} -> spike_hop
-> enemy_gauntlet{kinds:["bat","walker","bat"]} -> end_area -> validate_level
Proving a level can be beaten
validate_level runs three stages. First a schema check. Then placement checks: the spawn, goal, checkpoints and ground enemies must stand on solid ground, and nothing may sit inside a wall or past the level width. Last, a traversal search drives the real player physics from spawn to goal. It tries left and right moves, walks, and jumps with different hold lengths and late-press delays, and treats spikes and pits as lethal. Enemies are ignored, so this proves the terrain is passable, not that every fight is easy.
When the search fails, it reports where it got stuck and what to change. Here is the real output for a level whose pit is 7 tiles wide:
{
"ok": false,
"errors": [{
"path": "goal",
"message": "Level is not beatable: the player can get as far as column 11 but the pit at columns 12-18 is 7 tiles wide.",
"hint": "The widest jump that works here is 5 tile(s). Shrink the gap to 5 or less, or bridge it with floating_platforms.",
"stuck_col": 11
}]
}
The validator also warns about tight jumps, for example a gap where only 1 or 2 of 6 late-press timings work, and about buried coins and long levels with no checkpoint.
Agentic level generation as a generate, validate, retry loop

On the title screen, press "Generate a level with Grok", type an optional theme of up to 200 characters, and play when it is ready. "Custom level" opens the same dialog and also accepts pasted level JSON. The game sends the theme to a small backend that runs the agent loop. It defaults to the grok-4.20 non-reasoning model and gives it 15 of the 21 tools (the high-level components plus undo, get_level and validate_level).
The system prompt tells the model to build exactly one level with tool calls and never answer with level JSON as text. It also says the player's theme is creative direction only, so instructions in it that conflict with the rules are ignored. After every model turn the backend validates whatever level exists. A valid level is returned right away. If the level is invalid, the errors and hints go back to the model, and it fixes the problem with undo and new components. The loop stops after 4 model turns or 90 seconds. The page also re-checks the returned level locally before loading it, and refuses one that fails. The in-game dialog says a run usually takes 10 to 40 seconds.
Cost guards
Each player can generate 3 levels per hour, and everyone together can generate 100 per day. Only one generation runs at a time for each player. The counts are saved, so a restart does not reset the cap. When a limit is hit, the player gets a plain message and can still play the four built-in levels.
Use the tools from any MCP client or the CLI
The tool set does not depend on one model or chat app. The repo includes a small MCP server that speaks JSON-RPC over stdio and exposes all 21 tools:
{ "command": "node", "args": ["tools/mcp-server.js"] }
Any MCP client can list the tools, build a level and call play_url for a validated link. If you prefer plain function calling, pass tools.openai or tools.anthropic from tools.json to your API and answer each call with session.call(name, args). A CLI covers scripted use with no network and no keys: node tools/cli.js apply calls.json runs a recorded call sequence and validates the result, validate level.json checks a hand-written level, and url level.json makes a link that plays it.
The repo's examples/grok-generated.json is a model-built level, and the screenshot above is that level running in the live game. You can load it with this link.
Tests
npm test runs 41 tests. They check that the coyote window is exactly 6 ticks, that there is no double jump, the jump buffer, variable jump height, collision, every built-in level being traversable, every component and tool, the validator, the CLI and MCP server, and the backend against a mock model server. A control test confirms that a 6-tile gap is not traversable, so the search can fail. Optional Playwright checks load the page and have a bot clear levels 1 and 2 using only late coyote jumps.
Try it
Play at grepawk.com/jumper and read the code at github.com/yishengjiang99/coyote-jump. Related: GBK's composer tools as an MCP server uses the same idea for music.

