Closing the Loop: Turning Semantics into Mechanics
Bridging the gap between LLM semantic output and hard-coded game mechanics using a Command Registry.
Talk is cheap. In a systemic RPG, if I insult a guard, I don’t just want a dynamically generated, angry response. I want him to physically arrest me, or at least kick me out of the tavern.
The biggest challenge with AI dialogue is giving it “teeth.” If the AI generates text but the game world doesn’t change, the illusion shatters.
The Menu-Driven Player
In NarrativeSim, the player does not type free-text to NPCs. Player agency is menu-driven.
When an event happens—say, the player is caught stealing—our IActionProvider dynamically populates the player’s UI with contextual choices: [Apologize], [Bribe (50g)], or [Flee].
This grounds the player’s inputs in the mechanical reality of the game. But what happens after the player clicks a choice?
The Semantic Command Registry
When the player clicks [Bribe (50g)], DDv2 evaluates the interaction against the NPC’s traits (e.g., is this guard corrupt or honorable?).
We force the LLM to output its response not just as text, but as strict JSON containing an array of commands.
{
"internal_thought": "The player is offering gold. I am underpaid and my 'corrupt' tag is active. I will accept the bribe.",
"actorID": "npc-kael",
"dialogueLine": "Just this once. But if I catch your hands near the merchant's cart again, you're going in the cage.",
"topic_uris": [],
"commands": [
{
"command": "transfer_gold",
"amount": 50,
"from": "player",
"to": "npc-kael"
},
{
"command": "modify_tension",
"amount": -0.2
},
{
"command": "clear_active_situation"
}
]
}
The Physics of Conversation
Our CommandRegistry catches that JSON object. Because these commands are strongly typed, the engine executes them flawlessly.
- 50 gold is mechanically deducted from the player and added to Kael’s inventory.
- The RelationshipManager lowers the tension between them.
- The SituationDirector clears the “Confrontation” override.
Instantly, Kael’s underlying NAAS evaluation changes. Because the confrontation is cleared and his tension dropped, his controller stops targeting the player, he turns around, and he physically walks back to his patrol route.
We have completely bridged the gap between dialogue and mechanics. The LLM translates the social consequence, and the ECS turns it back into physics.