Writing / Kalix, part 6 of 8

Type What Your Hero Does: A Model Reads It, the Rules Decide

Most games that let you fight with words either give you a menu or let a language model narrate whatever it likes. I wanted to try the space between: you type what your hero does, in your own words, and the game takes it seriously without letting the model decide the outcome.

The rule I set on November 26 was a strict split.

  • The model only translates. It turns a sentence into a plan made of actions from a fixed list: move, strike, throw, take, shove and so on, each with a target.
  • The rules decide. A deterministic simulation checks the plan, prices it in stamina, and works out what happens. The model never says whether something worked.
  • The log is the truth. A fight is saved as the plans, not the model’s words, so it replays exactly without the model.

The Boiler Room

The test is one small room: two heroes, Ash and Bren, against a brute and a skirmisher. The room has a brazier of hot coals, a spill of oil, an oil barrel, a water trough, a crate hanging from a winch, a steam valve, a torch and a flask of oil.

The first version had no graphics at all. Measured that day with three models running on a local server: the largest, a 30-billion-parameter Qwen3 model, took about one second per action and turned down all ten nonsense lines it was given. The split held in every run. Nothing a model produced led to an outcome the rules do not allow. The worst cases were a wasted turn, or an ordinary action swapped in for an impossible one: “I pull out my shotgun” became a thrown oil flask. And the fights replayed exactly from their logs.

The best moment was a line straight from the research notes I started from: “run to the brazier and kick it at the brute”. It became one shove. The coals spilled, reached the oil, lit it, burst the barrel next to it, and the brute burned twice as fast because he was soaked in oil. No rule describes that combination. Each rule is small, and they met.

One finding changed the design straight away: models are bad at distance. Asked to work out whether a target was in reach, all three got it wrong often, and the largest refused reasonable actions after doing the arithmetic badly. So the game stopped showing the model any distances. A character now walks to what they named on their own, and the rules handle reach.

On screen, and the first verdict

The next day the room got a view: grey shapes in the engine (see part 1), labels on everything, and the plans written on the floor.

A small walled room seen from above at an angle, with coloured capsules for the heroes and foes and labelled props: brazier, oil barrel, trough, winch, hanging crate, steam valve. Health bars sit at the top left. On the floor, two cyan markers read: ash, between bren and brute, and bren, away from brute. At the bottom, the plans: ash will throw oil_flask between bren and brute, 3 stamina, 1442 ms; bren will move away from brute, 2 stamina, 1877 ms. Press Enter to play the round.
Both heroes' plans for the round, read from plain sentences, with the places they name marked on the floor. The times are how long the model took to read each line. Click it for full size.

On a fixed set of test lines, the largest model now accepted all 27 reasonable actions, matched the expected plan exactly on 24, and turned down all 14 nonsense lines, in about 0.8 seconds each.

Playing it found more than the test set did. A hero tipped the brazier at a foe standing next to his ally and set the ally on fire too. Water thrown on that fire left steam, which blinded both of them, and they both missed. Nobody wrote those outcomes. I played it on November 27 and the verdict was short: this is fun, and planning a clever move felt better than plain hitting.

Vague words and one question

People do not talk in targets. They say “throw the flask between them” or “go for whoever is weakest”. The next version let a plan name places in words, between two things, beside one, away from another, and pick targets by description, such as the nearest foe. The rules work out the exact spot when the action happens.

When a line is too vague, the game asks one question and waits for one answer.

The room after round one. The brute stands in a patch of fire and is marked burning and oiled. The story at the bottom reads: burn on brute is x2 because of oiled; brute loses 12 hp to burn, 58 left; bren will strike nearest_foe. Then, in orange: ash, where exactly? Name the thing or the spot you mean.
Ash's line named no place, so the game asked instead of guessing. Bren's plan, "strike the nearest foe", is already set. This was captured before a small fix: the question appeared three times, and the line at the very bottom no longer repeats it.

The cost showed up in the numbers. Only the largest of the three models could handle the bigger list of words; the two smaller ones got worse than before. A line took about 1.35 seconds to read, so the game lets you type the next hero’s line while the last one is being read. And a typo is simply refused: “go for whoever is weakets” was turned down as not an action.

Freedom, measured

I wrote down three things the game has to deliver. Freedom: your equipment, skills, items, the room, where the enemies stand and even the fire, oil and water on the floor can all be used to win. Memory: enemies remember and change. Excitement: even an ordinary action is worth watching.

To measure freedom, a list of sixty things a person might try, ten for each of those six kinds, was written before anything new was built, and a test scores them without a model. The game started at 25 of 60.

The next version moved every action into a data file. The engine no longer knows what a “headbutt” is; a designer adds it to the file, built from a small set of parts such as move, push, hit and hold, and the running game picks it up the next round (part 2 shows this). Heroes got gear and skills: Bren carries a hammer and shield, Ash a chain. The score went to 57 of 60.

The room after round one. Labels show what each character holds: ash with a chain, bren with a hammer and shield, the brute with a maul. The story reads: ash throws dagger at skirmisher; skirmisher takes 8; brute is now shaken (bellow); brute strike fails, still 0.2 m short of ash.
Gear is a thing in a hand: the labels show who holds what. Ash threw a dagger at the skirmisher for 8 damage, and it now lies at the skirmisher's feet.

Then the agent measured whether any of it mattered, by playing twelve fixed ways of fighting twenty times each, with no model involved. The answer was no.

  • Punching the nearest foe wins every fight, 20 of 20, in three rounds, losing 22 of the heroes’ 95 health points.
  • Using the room is worse than punching. Tipping the brazier into the oil and dropping the crate leaves the heroes with 47 health, against 73 for punching.
  • One pair of skills is too strong. Ash’s feint and Bren’s hammer blow multiply together to 84 damage in one blow, against a brute with 70.

A big enough menu could ship this game as it stands. What the words add is that a designer can lengthen the menu while the game runs. That is useful. It is not the same as the player being free. A follow-up experiment asked the model to build new actions out of the parts when a player’s words fit none; on lines it had not seen, one result in seven was sensible. The agent’s recommendation was not to build it.

I have not played the freedom update myself yet. The balance problem is a design problem, not an engine one, and it is next on the game’s list.

Why the next version is in Unity

On November 27 I decided where this game should live: as a miniature on a real table, seen through mixed-reality glasses, with the room in grey shapes at about an eighth of life size. You look at a piece, say what the hero does, and pinch to commit. Meta has glasses coming that are built around exactly that kind of input: eyes, hands and voice, no controllers.

The agent checked how far Kalix was from that. A trimmed version of the engine’s game runtime does build for Android, the system the glasses run: the build went from 952 libraries with three failures to 610 that compile, and it packages into an app. It has never been started on a device. Everything else, showing the real room through the glasses, finding and anchoring to a table, hand and eye input, turning speech into text, a simulator for testing on a PC and the store build, would have had to be built in Kalix. Meta’s Unity tools already provide nearly all of it, and Meta’s voice toolkit only exists for Unity and Unreal.

So on November 28 the mixed-reality prototype moved to Unity. The plan keeps the game’s rules in Rust, about 5,900 lines that use one small engine library and nothing from its renderer or editor. Unity will call them through a small C interface and draw the result. One check ties the two together: a fight recorded from Unity must replay exactly through the Rust command-line version. That work has only just been handed over.

What Kalix gave this project is worth naming: an agent that could build, play and test the game through the editor, every file in plain text, and fights that replay exactly. Those still matter. For a device prototype on someone else’s platform, they matter less than having the platform’s own tools.