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 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

01

Player Input

The player says something. The engine picks up what they said and why it matters.

02

State Evaluation

Current state, score, and transition rules are checked to decide what happens next.

03

Dialogue Generation

The NPC responds in character, pulling from its current state and conversation history.

04

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.

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.

Chat System 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. ...

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
  • 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.