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 like trust, suspicion, and hostility. Each state has its own dialogue patterns, evaluation rules, and transition logic.
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.
Dynamic persona generation
Give the engine a character concept and it builds out a full persona: backstory, motivations, conversational voice, and state machine logic.
Relational memory
Characters remember what happened. Past interactions shape future encounters, so NPCs feel like they were actually there for the previous conversation.
How it works
Player Input
The player says something. The engine picks up what they said and why it matters.
State Evaluation
Current state, score, and transition rules are checked to decide what happens next.
Dialogue Generation
The NPC responds in character, pulling from its current state and conversation history.
Memory Update
The conversation gets summarized and written to character memory for next time.
Player Input
The player says something. The engine picks up what they said and why it matters.
State Evaluation
Current state, score, and transition rules are checked to decide what happens next.
Dialogue Generation
The NPC responds in character, pulling from its current state and conversation history.
Memory Update
The conversation gets summarized and written to character memory for next time.
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 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
- Standalone tool or project integration
- Character systems, not one-off chatbot gimmicks
Build characters that
shape the story.
Start defining relational NPCs for your world.

