foil engine
Foil Engine

foil engine

A relational character engine
for cinematic worlds.

Characters defined
by contrast

Foil Engine is a framework for building relational NPCs. Characters that change through interaction, remember what happened, and push back when the story calls for it. Not static scripts.

Player choices carry weight. The system tracks conversational state, reads intent, and shifts dialogue in real time based on where the relationship stands.

Built for cinematic game worlds, not chatbot novelty.

Core capabilities

State-driven behavior

NPCs move through defined states, each with its own dialogue patterns, evaluation rules, and transition logic. Scoring tracks player performance with numeric or pass/fail modes, driving conversations toward accept, reject, or kick-out outcomes.

Conversation-aware dialogue

Responses account for the full conversation, not just the last message. The system reads player intent, tracks score, and picks dialogue strategies based on where things stand.

AI-powered generation

Describe a character concept and the engine generates a full persona, including identity, backstory, and conversational voice. Add an objective and it builds complete scenarios with states, transitions, and scoring logic.

Multi-scenario progression

Link multiple scenarios together with unlock conditions based on outcomes or score thresholds. Pass variables between scenarios and auto-advance players through branching narrative paths.

How it works

01

Describe your NPC

Provide a character concept, name, and scene. The engine generates a full identity and persona prompt.

02

Build scenarios

Add conversation scenarios with objectives and win/lose conditions. The engine generates states, transitions, and scoring logic.

03

Edit & test

Fine-tune states, transitions, and variables in the editor. Test conversations with the built-in preview chat.

04

Publish & share

Publish your NPC and share it. Players interact through a chat interface with real-time scoring and progression.

Generated output

What the engine produces from a single character concept.

persona preview
foil-engine v1
Name

Potion Seller

A dramatic merchant who guards his strongest potions from unworthy buyers. Dismissive, theatrical, and absolutely convinced the player is too weak for his inventory.

Identity Prompt

You are the Potion Seller, a merchant of unusually strong and dangerous potions. You speak with absolute confidence and a faint sense of disbelief that anyone would question your judgment. You are dramatic, dismissive, and unwavering in your belief that most customers are too weak for your strongest potions. ...

Scenario

The Strongest Potions

Convince the Potion Seller to sell you his strongest potion.

States
INITIAL·Merchant’s Greetinginitial

The Potion Seller greets the player with confidence and immediately establishes that his potions are extremely powerful. He is willing to talk, but only if the player seems worthy.

S1·Questioning Strength

He begins testing the player’s resolve, warning that his potions are far too strong for an inexperienced traveler. He repeats this point with increasing certainty if challenged.

S2·Refusing the Request

The Potion Seller grows firmer and more incredulous. He insists the player is not strong enough and rejects any attempt to buy his strongest potions, no matter how boldly the player asks.

ACCEPT·Sale Approvedterminal

Against his better judgment, the Potion Seller agrees to sell a potion. He still warns the player of its strength, but now treats them as someone who may survive it.

FAIL·Sent Awayterminal

The Potion Seller ends the conversation and refuses service entirely. The player is dismissed as too weak for his wares.

Transitions
FromToDecisionScore
INITIALS1pass0
S1S2pass+1
S1FAILreject-1
S2ACCEPTpass+1
S2FAILkick_out-2
Variables
pass_threshold4
early_fail_bound-3
max_redirects_per_state2
For developers

Built for
game creators

Foil Engine is for developers building character-driven games. Define persona logic, test dialogue flows, and plug generated characters into your project.

  • REST API for persona generation and chat
  • State machine editor with visual diagram
  • Multi-scenario progression with unlock conditions
  • Native SDKs for Python, TypeScript, and Unity
pip install foilengine
npm install @foilengine/sdk

Build characters that
shape the story.

Start defining relational NPCs for your world.