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
Describe your NPC
Provide a character concept, name, and scene. The engine generates a full identity and persona prompt.
Build scenarios
Add conversation scenarios with objectives and win/lose conditions. The engine generates states, transitions, and scoring logic.
Edit & test
Fine-tune states, transitions, and variables in the editor. Test conversations with the built-in preview chat.
Publish & share
Publish your NPC and share it. Players interact through a chat interface with real-time scoring and progression.
Describe your NPC
Provide a character concept, name, and scene. The engine generates a full identity and persona prompt.
Build scenarios
Add conversation scenarios with objectives and win/lose conditions. The engine generates states, transitions, and scoring logic.
Edit & test
Fine-tune states, transitions, and variables in the editor. Test conversations with the built-in preview chat.
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.
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.
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. ...
The Strongest Potions
Convince the Potion Seller to sell you his strongest potion.
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.
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.
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.
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.
The Potion Seller ends the conversation and refuses service entirely. The player is dismissed as too weak for his wares.
| From | To | Decision | Score |
|---|---|---|---|
| INITIAL | S1 | pass | 0 |
| S1 | S2 | pass | +1 |
| S1 | FAIL | reject | -1 |
| S2 | ACCEPT | pass | +1 |
| S2 | FAIL | kick_out | -2 |
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/sdkBuild characters that
shape the story.
Start defining relational NPCs for your world.

