Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Statecraft

A state layer for world models. Your rules stay in code. The model renders them.

Built at World Models Mini Build (Hyderabad), on Reactor's reactor/lingbot-world-2.


The problem

World models generate environments you can move through in real time. What they don't give you is consequence. Drive off a cliff, come back, and nothing happened. There's no score, no damage, no progression — a beautiful place where nothing you do matters.

That isn't a memory problem. LingBot World 2 has visual memory: minute-scale contextual consistency, and it's genuinely good. The gap is that there is no number you can read. The model can't tell you your speed, your engine temperature, or that you've crashed twice. Frames go out; nothing comes back but pixels.

So the quantities have to live somewhere else.

The idea

Keep the game in ordinary Python. A few variables, a few rules, a compiler that turns the current values into a sentence. Send the sentence. The model draws it.

input → STATE (python) → RULES (python) → PROMPT COMPILER → set_prompt → frames

This is the update/render split every game engine has: the simulation is authoritative, the renderer paints what's true. Statecraft supplies the half world models don't have.

One design rule, and everything follows from it: every rule fires from something we already know — commands we sent, time elapsed, our own state. Nothing is ever read back out of the pixels.

What it is / isn't

It is It isn't
A rules engine beside a world model A game engine — no physics, collision, entities, assets
Deterministic, inspectable state A model, a fine-tune, or a wrapper on model internals
A prompt compiler driven by that state Spatial — it never knows where anything is
The update half of a game loop A prompt scheduler — rules read and constrain each other

Honest limits: the renderer is generative rather than deterministic, so it interprets state rather than projecting it. Same state gives you a consistent picture, not an identical one. There is no scene graph and no object permanence beyond what the model's own visual memory provides.

Demo

An endless driving run. Speed, distance, engine heat, hazards, crashes.

  • Hold throttle and heat climbs. Cross a threshold and the engine forces you to slow — the world vents steam because a rule said so, not because anyone typed it.
  • Sustained speed earns a boost; the world streaks.
  • Hazards open a timed window. Swerve or take the hit. A hit zeroes your speed, and it stays zeroed.
  • Distance milestones advance the world through noon → dusk → night storm.

A live HUD shows every variable. The proof is watching the numbers move with hands off the keyboard, and the world answering.

The racing game is the test case, not the product.

Running it

pip install reactor-sdk opencv-python numpy
export REACTOR_API_KEY=...    # https://www.reactor.inc/account/api-keys
python statecraft.py

w throttle · a/d swerve · q quit

Tunables (tick rate, prompt settle interval, hazard window) are in one block at the top of statecraft.py. They're calibrated to observed chunk-boundary latency — commands land at chunk boundaries, so the effective tick is seconds, not milliseconds. Every mechanic is designed around that constraint rather than fighting it.

Design notes

Slot-based prompt compilation. Lighting is rebuilt, not appended, because a trailing night clause may not override a leading clear noon.

Clauses are empirical. Roughly half of any set of candidate prompt clauses won't render distinguishably. Test each one in the playground, score it, and delete the rule along with the clause that lost. Don't defend a clause that doesn't show up.

No LLM at runtime. Deliberate. Agent-driven prompt steering is a different (and already well-explored) approach; keeping the runtime deterministic is what makes the state inspectable and the run reproducible.

What's next

Rules are hand-written Python today. They're also just data — variables, conditions, clauses. The next step is a declarative schema, and then an LLM that emits one from a description:

"a submarine running low on oxygen while something follows it"

The engine loads the rulebook and runs it. The model authors once, at design time, and never steers at runtime — so you get games from a sentence without giving up determinism.

Further out: a manufactured sensor loop (running a detector over outgoing frames to feed a noisy reading back into state), replay determinism, and shared-state multiplayer.

Credits

Built on Reactor and Robbyant's LingBot-World 2.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages