EFAIL

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, draw and show. No game loop, no renderer, no input handling.

  • Headless and deterministic

    efail sim runs 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 shot saves any frame as a PNG. efail film puts a whole animation in one labelled grid. The engine writes the pixels itself.

  • Human bugs replay exactly

    efail run records what the player did. efail replay reruns it headless, tick for tick.

  • Proven rules

    Through Bend's laws, a game states facts like “game over waits for Space” and efail check proves 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
The contract every Efail 2D game implements. A 3D game returns a scene from 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.

CommandWhat it doesOutput an agent reads
efail checkType-checks the game, checks the contract and proves its lawsErrors as text
efail simRuns headless with scripted inputOne show(state) line per sampled tick, plus each sound
efail shotRuns, then saves one framebuild/shot.png
efail filmSaves frames every N ticks in one imagebuild/film.png, each frame labelled with its tick
efail runA human plays in a windowbuild/last.replay
efail replayReruns exactly what the human just did, headlessThe same state lines the human produced
efail webBuilds the game as one self-contained web pagebuild/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
Real output from the Dodge example with no keys pressed: the player is hit at tick 141 and the game-over sounds start on that tick.
# 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
Input scripts and recorded replays share one plain-text format, so an agent can write, read and edit them.
Film strip from efail film: six frames of the Dodge game at ticks 0, 30, 60, 90, 120 and 150. Orange blocks fall toward a green player; the last frame shows GAME OVER with a score of 142.
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}
From 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.

2D guide (AGENTS.md)

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.

3D guide (AGENTS3D.md)

Dodge, an Efail 2D example game: orange blocks fall toward a green paddle on a navy background, score 130.
Dodge: a complete game with proven laws
Efail sprites example: a pixel-art character, trees and a purple gem on a green field, drawn from text sprites.
Sprites written as text
Pop, an Efail mouse example: a red target on a navy background with hit and miss counters.
Pop: mouse input
Runner3D, an Efail 3D example: a green low-poly runner in a corridor with blue walls, rendered with flat lighting.
Runner3D: low-poly 3D

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.

  1. Read one page. AGENTS.md holds 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.

  2. Write the game. The agent edits game.bend: a state type and the pure functions init, step, draw and show.

  3. Check it. efail check type-checks the file, checks the contract and proves any laws. Errors come back as text the agent can act on.

  4. 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.

  5. Look at it. efail shot saves a frame and efail film saves a strip of frames as one PNG, so the agent can see layout, colors and motion for itself.

  6. Hand it to a person. efail run opens a window and records the session. If the player hits a bug, efail replay reproduces it exactly, with no bug report to interpret.

  7. Share it. efail web turns 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 engineEfail
Making a gameScenes, assets and settings arranged in a visual editorOne text file of pure functions
Testing itUsually a person plays it in a windowA command prints the state as text or saves a PNG, with no display needed
Reproducing a bugFollow written steps and hope it happens againReplay the recorded input: the same ticks, states and pixels
Same input, same resultOften depends on frame timing and the machineAlways, by design
Checking the rulesTests that try some casesLaws proven for every input
What to read firstA large manual and editor tutorialsOne page per mode
Best suited toLarge 2D and 3D games made by teamsSmall 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.

Open the game on its own page

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.

  1. 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"
  2. 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.png
  3. Point your agent at AGENTS.md in the game folder and tell it what to build. Play the result with efail run (Esc quits).

  4. For 3D, use efail3d the 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, draw and show). 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 sim to print the game state as one line of text per sampled tick, efail shot to save a frame as a PNG, or efail film to 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, edits game.bend and uses the same efail commands 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 with efail shot and efail 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 efail3d command 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 web writes build/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 that efail sim can rerun headless.
What platforms does Efail run on?
Efail is at v0 and runs on Linux (X11 or XWayland). Headless commands such as efail sim and efail shot need 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.