Craftax: The RL Benchmark That Turns a Game Into a Tensor Program
A JAX-native open-world environment that trades loops, branches, and CPU bottlenecks for masked state, vectorized logic, and absurd simulation throughput.
- Craftax’s real breakthrough is not content depth, but the decision to express a rich survival world as JAX-friendly static computation.
- Fixed-size state, boolean masks, and branchless transitions make the environment batchable at scale without falling back to a CPU simulator.
- The benchmark fills a neglected middle ground between simple fast tasks and slow sprawling ones like NetHack.
- Craftax-Classic shows that the project is also about parity and infrastructure, not just novelty.
Craftax is interesting because it proves that the hardest part of building a rich RL benchmark is not the world design, but the computation model you choose to represent it. The repo takes a survival game shape, then rebuilds it around JAX, where state is static, transitions are vectorized, and the simulator is meant to disappear into the accelerator.
The weird trick: Craftax is a game built for JAX, not for humans
Craftax is an RL environment written entirely in JAX. Craftax reimplements and significantly extends the game mechanics of Crafter, taking inspiration from roguelike games such as NetHack.
That sentence from the README is the project in miniature. Craftax is not only a benchmark with more features than Crafter. It is a benchmark whose execution model is the point.
Most game simulators are built around dynamic objects, branching control flow, and the assumption that one world state advances one step at a time on a CPU. Craftax flips that. It is designed to be compiled, transformed, and run in parallel across many environments, which makes throughput part of the benchmark rather than an afterthought.
Why RL needed this middle ground
| Benchmark | What it optimizes for | Main limitation | Best use |
|---|---|---|---|
| Minigrid | Speed and simplicity | Too shallow for open-ended planning | Fast algorithm checks |
| Procgen | Procedural variety | Still relatively bounded | Generalization tests |
| NetHack Learning Environment | Richer long-horizon tasks | Slow and operationally heavy | Deep RL research |
| Crafter | Open-ended survival mechanics | Limited complexity and content depth | Baseline benchmark |
| Craftax | Complexity plus GPU-friendly throughput | Still constrained by static-state design | Large-scale RL research |
Craftax occupies the rare overlap where the environment is complicated enough to matter and cheap enough to run in bulk. That matters because a lot of RL progress is gated by simulation cost, not just model quality.
What the full environment actually contains
The full Craftax world is not a toy. It includes nine floors, procedural generation, survival mechanics, magic, enchantments, and a boss fight. The point is long-horizon dependency chains: gather, craft, upgrade, descend, survive, repeat.
The important detail is not that the world is large. It is that the world is still regular enough to fit JAX’s rules. That constraint forces the design into arrays, masks, and pure transitions.
The real invention: fixed-size world state and masked entities
@flax.struct.dataclass
class EnvState:
player_x: jnp.ndarray
player_y: jnp.ndarray
player_hp: jnp.ndarray
inventory: jnp.ndarray
mobs_pos: jnp.ndarray
mobs_hp: jnp.ndarray
mobs_mask: jnp.ndarray
floor_id: jnp.ndarray
noise_params: jnp.ndarray
# Masks make inactive slots cheap to keep around.
active_mob_hp = jnp.where(state.mobs_mask, state.mobs_hp, 0)
In a normal engine, mobs would be a list of objects and updates would loop over the live ones. Craftax stores them as fixed-size arrays and uses masks to say which slots are active. That is the pivot that turns a game world into batchable tensor state.
How Craftax stays branchless
def add_items_from_chest(state, key):
item_id = jax.random.choice(key, chest_table)
can_add = jnp.logical_and(state.inventory_space > 0, state.chest_open)
new_item = jax.lax.select(can_add, item_id, EMPTY_ITEM)
return state.replace(inventory=add_to_inventory(state.inventory, new_item))
def craftax_step(state, action, key):
moved = do_action(state, action, key)
return moved
The exact syntax varies, but the pattern is the same. Instead of branching into separate code paths, Craftax uses JAX primitives like `select`, logical masks, and random sampling to keep the transition graph stable. That is what makes compilation and batching work.
This is why the project reads more like a functional program than a traditional engine. The simulator is still rich, but it is written in a way that the compiler can see through.
Optimistic resets are a performance philosophy
Craftax’s base environment does not eagerly reset itself when an episode ends. That sounds minor until you care about scale. In vectorized JAX workloads, automatic resets can introduce awkward control flow and unnecessary overhead, so the repo pushes reset handling into a wrapper where it can be managed in bulk.
The result is a cleaner execution story: let the episode run into a placeholder state, then reset many environments together. Convenience takes a back seat to throughput, and that is exactly the right trade-off for this kind of benchmark.
Craftax-Classic is the control group
| Version | Goal | Why it exists |
|---|---|---|
| Craftax | Full open-ended benchmark with deeper mechanics | To test complex RL in a JAX-native world |
| Craftax-Classic | JAX reimplementation of Crafter | To isolate the effect of the execution model and preserve parity |
This split is smart. It prevents the article’s central claim from collapsing into simple feature creep. Craftax-Classic says the repo is not only adding content. It is also proving that the same benchmark family can be re-expressed in a radically different computational form.
Why the benchmark is harder than it looks
The challenge is not walking around or opening chests. The challenge is the dependency chain. You mine, you craft, you upgrade, you descend, and eventually you face bottlenecks that only appear if earlier decisions were good enough.
That creates sparse reward, delayed feedback, and hierarchical planning all at once. It is the kind of task where a fast simulator matters because the agent needs enormous volume just to see enough meaningful trajectories.
What Craftax says about the future of RL infrastructure
Craftax’s real lesson is bigger than one benchmark. Environment representation is an algorithmic choice, not just an implementation detail. If you want modern accelerator hardware to matter, the world itself has to be shaped so the compiler can understand it.
That is the most interesting thing in the repo. The game is the demo, but the design principle is the product: build the environment in the same computational language as the model that will learn from it.





