Deterministic 2D + low-poly 3D · written in Bend · MIT
The game engine built for AI agents
Efail is a deterministic 2D and low-poly 3D game engine built for AI agents. A game is one file of pure functions. The engine owns the window, the clock, input, replays and screenshots, so an agent only writes the game, then checks it headless: state as text, frames as PNGs, the same result on every run.
Reading this as an AI agent? Skip the HTML.
/llms.txt is the index,
/index.md is this page as Markdown, and
/llms-full.txt is the complete 2D and 3D documentation in one file.
Requesting / with Accept: text/markdown returns Markdown too.
Why an engine for agents?
Agents making games today spend most of their effort on the layer around the game: choosing a stack, wiring a renderer and input, building ways to see and test what they made, and fighting an editor GUI. Efail makes all of those choices up front, so the agent only writes the game.
One file of pure functions
A game is
game.bend:init,step,drawandshow. No game loop, no renderer, no input handling.Headless and deterministic
efail simruns any number of ticks with scripted keys in milliseconds and prints the state. The same seed and keys always give the same result.Agents can see the game
efail shotsaves any frame as a PNG.efail filmputs a whole animation in one labelled grid. The engine writes the pixels itself.Human bugs replay exactly
efail runrecords what the player did.efail replayreruns it headless, tick for tick.Proven rules
Through Bend's laws, a game states facts like “game over waits for Space” and
efail checkproves them for every input.One page of docs per mode
AGENTS.md covers 2D and AGENTS3D.md covers 3D. Each fits in a single context window.
How it works: the whole contract
Your game defines a state type and four pure functions. Efail calls step 60 times a second,
draws whatever draw returns, and prints show when running headless.
There is no IO, no clock and no randomness except what you derive from the seed. That is what makes every run reproducible, and what lets an agent trust a text line as much as a screenshot.
The API is small: rectangles, circles, text and text-art sprites; keyboard and mouse; seeded random;
collision helpers; and retro sounds described as data, which efail sim prints on the tick they start.
import Base
import ./efail/efail.bend as E
type State is Data: # your state
...
def init(seed: U32) -> State: # the first state
def step(+input: E.Input, s: State) -> State: # one tick; 60 a second
def draw(s: State) -> List<E.Shape>: # what to show
def show(s: State) -> String: # one line for efail sim
scene instead of shapes from draw.The loop an agent works in
Edit, check, simulate, look. Every command is a one-liner whose output is text or a PNG.
| Command | What it does | Output an agent reads |
|---|---|---|
efail check | Type-checks the game, checks the contract and proves its laws | Errors as text |
efail sim | Runs headless with scripted input | One show(state) line per sampled tick, plus each sound |
efail shot | Runs, then saves one frame | build/shot.png |
efail film | Saves frames every N ticks in one image | build/film.png, each frame labelled with its tick |
efail run | A human plays in a window | build/last.replay |
efail replay | Reruns exactly what the human just did, headless | The same state lines the human produced |
efail web | Builds the game as one self-contained web page | build/game.html |
$ efail sim --ticks 300 --every 60
tick 0: play x=150 blocks=0 score=0
tick 60: play x=150 blocks=2 score=60
tick 120: play x=150 blocks=4 score=120
tick 141: sound slide 440>60 400ms square
tick 141: sound beep 90 250ms noise
tick 180: over score=142 best=142
tick 240: over score=142 best=142
tick 300: over score=142 best=142
# keys.txt: a tick, then the keys held from that tick on
seed 42
0
30 right
90 right space
120
150 @100,60 # move the mouse pointer
160 mouse_left # click
end 300
efail film --ticks 150 --every 30: one PNG, six frames, each labelled with its tick. It matches the text output above tick for tick. Swipe sideways to see every frame.Rules you can prove, not just test
Because a game is pure functions in Bend, it can state facts about its own rules as laws,
and efail check proves them for every possible input, not only the ones a test happened to try.
The Dodge example proves that its game-over screen stays exactly as it is until Space goes down, and that Space starts a fresh round that keeps the best score.
# LAW: the game-over screen waits for Space.
law over_waits:
for +input: E.Input
for score: U32
for seed: U32
for best: U32
{E.pressed(input, E.space()) == False{} : Bool} ->
{Game.step(input, Game.Over{score, seed, best})
== Game.Over{score, seed, best} : Game.State}
examples/dodge/LAWS.bend.2D and low-poly 3D
Efail 2D
Rectangles, circles, a built-in pixel font and sprites written as text, one character per pixel. Keyboard and mouse input, seeded random, collision helpers, retro sound, and export to a single web page.
Efail 3D
Colored triangle rendering with depth and clipping, transformed primitive meshes, flat lighting, cameras,
deterministic gravity, box and sphere collision, raycasts, screenshots and exact replay, through the efail3d command.




How an AI agent builds a game with Efail
Efail works with any coding agent that can run shell commands and read text files and images, including Claude Code and Codex. There is no plugin, MCP server or editor integration to set up: the agent uses the same command line a person would.
Read one page.
AGENTS.mdholds the whole 2D contract, the API, the input-file format and the rules of the Bend language that matter. It is short enough to read in full before writing a line.Write the game. The agent edits
game.bend: a state type and the pure functionsinit,step,drawandshow.Check it.
efail checktype-checks the file, checks the contract and proves any laws. Errors come back as text the agent can act on.Play it without a screen. The agent writes a short input script (which keys go down on which tick), runs
efail sim, and reads the state line by line: position, score, game over.Look at it.
efail shotsaves a frame andefail filmsaves a strip of frames as one PNG, so the agent can see layout, colors and motion for itself.Hand it to a person.
efail runopens a window and records the session. If the player hits a bug,efail replayreproduces it exactly, with no bug report to interpret.Share it.
efail webturns a 2D game into one HTML file that plays in any browser.
Efail compared with editor-based game engines
Engines such as Unity, Godot and Unreal are built around a visual editor and aim at large commercial games. Efail is not trying to replace them. It is a small, code-only engine for games an AI agent can write and verify on its own.
| Editor-based engine | Efail | |
|---|---|---|
| Making a game | Scenes, assets and settings arranged in a visual editor | One text file of pure functions |
| Testing it | Usually a person plays it in a window | A command prints the state as text or saves a PNG, with no display needed |
| Reproducing a bug | Follow written steps and hope it happens again | Replay the recorded input: the same ticks, states and pixels |
| Same input, same result | Often depends on frame timing and the machine | Always, by design |
| Checking the rules | Tests that try some cases | Laws proven for every input |
| What to read first | A large manual and editor tutorials | One page per mode |
| Best suited to | Large 2D and 3D games made by teams | Small 2D games and low-poly 3D games made by agents |
The ideas behind Efail
- Agent-native game engine
- An engine designed for an AI agent as its main user. Every feature can be driven from the command line and checked as text or an image, because an agent cannot click through an editor or watch a window.
- Deterministic
- The same seed and the same input produce the same states and the same pixels on every run. Efail games are pure functions with no clock and no hidden randomness, so nothing can differ between runs.
- Headless
- Running without a window or a display. Efail simulates and renders on a server with no screen.
- Replay
- A plain-text record of which keys were held on which tick. Because the engine is deterministic, a replay is a complete, exact reproduction of a play session.
- Law
- A fact about a game's rules, written in Bend and proven by
efail check, for example “the game-over screen waits for Space”. - Tick
- One call to
step. Efail runs 60 ticks a second, and every command counts time in ticks, not seconds.
Play it here
This is the Dodge example, built with efail web: one HTML file running the game's own functions.
Click the game, then use the arrow keys or A/D to move and Space to retry.
Hold the buttons under the game to move, and tap Retry after a game over.
Quick start
Efail is at v0 and runs on Linux (X11 or XWayland). It needs Bend 2 and clang.
Note: the source repository is temporarily private while the next version is built. It will be back; these steps apply once it is.
Install Bend, then get Efail and put it on your path.
curl -fsSL https://bend-lang.com/install.sh | sh git clone https://github.com/typenx/efail && cd efail export PATH="$PWD/bin:$PATH"Create a game and check it headless.
efail new mygame && cd mygame efail check efail sim --ticks 300 --every 60 # state as text efail shot --ticks 120 # build/shot.pngPoint your agent at
AGENTS.mdin the game folder and tell it what to build. Play the result withefail run(Esc quits).For 3D, use
efail3dthe same way.efail3d new my3dgame && cd my3dgame efail3d check efail3d shot --ticks 120
Frequently asked questions
- What is Efail?
- Efail is a deterministic 2D and low-poly 3D game engine built for AI agents, written in the Bend programming language. A game is one file,
game.bend, made of pure functions (init,step,drawandshow). Efail handles the window, the clock, input, replays, screenshots and headless runs. - Why is Efail a good game engine for AI coding agents?
- Agents usually spend most of their effort on the layer around a game: choosing a stack, wiring a renderer and input, and finding a way to see and test what they made. Efail makes those choices up front. Everything an agent needs to check is text or a PNG, every run is deterministic, there is no editor GUI, and the whole 2D API fits in one page of docs (AGENTS.md).
- How does an AI agent test an Efail game without a screen?
- The agent writes a plain-text input file (a tick number followed by the keys held from that tick), then runs
efail simto print the game state as one line of text per sampled tick,efail shotto save a frame as a PNG, orefail filmto save a labelled grid of frames in one PNG. The same seed and input always give the same states and the same pixels. - Can Claude Code or Codex make a game with Efail?
- Yes. Efail works with any coding agent that can run shell commands and read text files and images, including Claude Code and Codex. There is no plugin, MCP server or editor integration to set up: the agent reads
AGENTS.md, editsgame.bendand uses the sameefailcommands a person would. - What is a deterministic game engine?
- A deterministic game engine gives exactly the same result every time it is run with the same starting seed and the same input. In Efail that covers both the game state and the pixels on screen, which is why a recorded replay reproduces a bug exactly and why an agent can trust a test it ran once.
- What is a headless game engine?
- A headless game engine can run a game without opening a window or needing a display. Efail runs any number of ticks headless with
efail sim, printing the state as text, and renders screenshots withefail shotandefail film, so an agent on a server with no screen can build and check a whole game. - How is Efail different from Unity, Godot or Unreal?
- Those engines are built around a visual editor and aim at large commercial games. Efail has no editor: a game is one text file, every check is a command whose output is text or a PNG, and every run is deterministic. Efail aims at small 2D games and low-poly 3D games that an AI agent can write and verify on its own.
- Is Efail an AI game generator?
- No. Efail does not generate games and contains no AI model. It is the engine an AI coding agent writes a game for, designed so the agent can test and see its own work.
- What kinds of games can you make with Efail?
- Small 2D games such as arcade, puzzle, platform and mouse-driven games, drawn with shapes, a pixel font and text-art sprites with retro sound, and low-poly 3D games with cameras, flat lighting and basic physics.
- What language are Efail games written in?
- Efail games are written in Bend, a Python-shaped, strictly typed functional language. The engine itself is also written in Bend. Game functions are pure: no IO, no clock and no randomness except what is derived from the seed.
- Does Efail support 3D games?
- Yes. The
efail3dcommand provides a low-poly 3D mode with colored triangle rendering, depth, clipping, transformed primitive meshes, flat lighting, cameras, deterministic gravity, box and sphere collision, raycasts, screenshots and exact replay. Textures, imported models, skeletal animation, shadows and rigid-body joints are outside the first 3D release. - Can Efail games run in a web browser?
- Yes, for 2D games.
efail webwritesbuild/game.html, one self-contained file that runs the game's own functions compiled to JavaScript, with the same 60 ticks a second, keys, pixels and sounds as the native window. Its Save replay button downloads a replay thatefail simcan rerun headless. - What platforms does Efail run on?
- Efail is at v0 and runs on Linux (X11 or XWayland). Headless commands such as
efail simandefail shotneed no display. 2D games can also be exported to a single web page that runs in any modern browser. - Is Efail free and open source?
- Yes. Efail is free and released under the MIT license.
- How do you pronounce Efail and what does it mean?
- Efail is Welsh for “smithy” and is said EV-ile.