# The AI Engine

AI Partyworld's edge isn't retrieval over a source text — there is no RAG and no original-novel lookup here. Our edge is the engine that makes AI agents play social deduction like scheming humans: a **deterministic director**, **two-stage agents**, **distilled memory cards**, a **persona FSM**, and **god's-eye replay**.

## Deterministic Director

A pure-Python state machine is the god of the table. It holds the single source of truth — who is who, the current phase, the vote tally — and it makes every ruling. The LLMs only produce *intentions*; the director adjudicates them.

This means the rules cannot be broken: an AI can lie about its role, but it cannot actually change the state machine. And information is filtered by identity — each seat only ever receives what its role is entitled to know.

## Two-Stage Agents

Every AI turn happens in two stages:

1. **Private thinking** — the agent decides its strategy: whether to lie, whether to fake-claim a role, who to frame.
2. **Public performance** — it turns that strategy into a natural statement at the table.

Because of this split, the AI will boldly fake-claim the Seer, frame an innocent, or play a "reverse-hook" gambit. Its scheming feels deliberate, not mechanical.

## Distilled Memory Cards

The AI never reads the raw transcript. Instead, the director hands each agent a structured, **fixed-length memory card** distilling what that seat is allowed to know. Two consequences:

- **Cost stays roughly constant** per turn, no matter how long the match runs.
- The wolves' private channel is **physically isolated** from the good side's information — a good-aligned agent simply never receives the wolf chatter.

## Persona FSM

Each AI seat runs a visible personality — the **brute (莽夫)**, the **old fox (老狐狸)**, the **saint (圣母)**, the **logician (逻辑帝)**. These personas are tells you can exploit: a brute over-commits, a fox waits, a saint defends too readily. Reading the persona is part of reading the table.

## God's-Eye Recap

When the match ends, the AI hands you a god's-eye **recap** — the match MVP, your grade and a per-player read, the turning point — and lets you trade a few rounds of banter with the table. The private truth the director kept walled off during play is opened up only once the game is decided.

## Why This Is Not RAG

There is no original novel, no vector index, no retrieval over a source text. The agents reason over the live game state the director gives them — nothing else. The intelligence is in the architecture: a god that can't be fooled, agents that think before they speak, and memory that's distilled rather than recalled verbatim.

## Why Outcomes Vary

LLM output is non-deterministic, so the same situation can play out differently from match to match. That's by design — it's what makes every game replayable and worth reading the room for.
