An LLM-driven multi-agent social deduction simulator inspired by The Traitors, built to explore how LLM agents exhibit deception, social deduction, belief formation, and decision-making in a competitive environment.
The project combines a deterministic game engine with persona-driven LLM agents, memory and belief tracking, structured experiment logging, batch simulations, and a web-based replay viewer for analysing agent behaviour.
Awarded 2nd place in the MSc category at the national BCS Lovelace Colloquium 2026 for an academic poster based on this project.
- LLM-driven agents — autonomous players participate in discussions, form suspicions, vote, and make strategic decisions.
- Faithful and Traitor roles — agents have different objectives and access to information depending on their role.
- Persona-driven behaviour — individual personas influence how agents communicate and interact with other players.
- Memory and belief tracking — agents maintain private rolling memories and update their suspicions of other players throughout the game.
- Deterministic game engine — game rules and state transitions are reproducible using fixed seeds, while LLM outputs influence discussion, voting, and Traitor decisions.
- Batch simulations — run individual games or batches across multiple seeds and experimental conditions.
- Structured logging — conversations, decisions, votes, game events, and outcomes are recorded for later analysis.
- Replay viewer — inspect completed simulations through a web interface showing how each game progressed.
- Experiment analysis — evaluate agent behaviour using metrics covering voting accuracy, deception, belief-action alignment, Traitor coordination, accusations, and defence.
- Python — simulation engine, agent logic, experiment orchestration, and analysis
- OpenAI & Anthropic APIs — LLM-powered agent behaviour and decision-making
- React — replay viewer frontend
- FastAPI — backend API for simulation replays
- JSONL — structured game event logging
- Python 3.11+
- Node.js 18+
- OpenAI or Anthropic API key
pip install -e .[dev]Create .env from .env.example and set your LLM provider and credentials:
LLM_PROVIDER=openai
OPENAI_API_KEY=your_key_herepython -m traitors_ai.runner run-one --seed 1 --condition baseline_memoryRun a batch of games:
python -m traitors_ai.runner run-batch --seeds 1..10 --condition baseline_memory --outdir resultsStart the backend:
cd backend
pip install -r requirements.txt
python -m uvicorn app:app --reload --port 8000Start the frontend:
cd frontend
npm install
npm startOpen http://localhost:3000.
pytestExperiment 1 evaluates whether persona-driven LLM agents with memory and belief tracking exhibit meaningful social deduction and deception behaviours.
Condition: baseline_memory
- Persona conditioning enabled
- Private rolling memory summary enabled
- Suspicion / belief update enabled each round
Default parameters: 9 players, 2 Traitors, 30 maximum rounds, 1 discussion turn.
Run a single game:
python -m traitors_ai.runner experiment-1-run-one --seed 1 --outdir results/Run a batch across seeds 1–20:
python -m traitors_ai.runner experiment-1-run-batch --seeds 1..20 --outdir results/Override the model and temperature:
python -m traitors_ai.runner experiment-1-run-batch \
--seeds 1..50 \
--model-name gpt-4o \
--temperature 0.7 \
--outdir results/Add --fail-fast to abort the batch on the first failed game.
Each experiment produces structured per-game, per-round, and per-agent data alongside the complete event logs and aggregate summaries.
| Metric | Description |
|---|---|
banishment_accuracy |
Fraction of banished players who were Traitors (1.0 = perfect) |
deception_success_rate |
Fraction of rounds with at least one Traitor alive where the banished player was Faithful |
belief_action_alignment_top1 |
Fraction of votes where the target matched the voter's single most-suspicious player |
belief_action_alignment_top2 |
Same as above, but considering the voter's top two most-suspicious players |
suspicion_gap |
Mean suspicion towards Traitors minus mean suspicion towards Faithfuls, measured for Faithful agents |
traitor_vote_agreement_rate |
Fraction of voting rounds where all alive Traitors voted for the same target |
murder_vote_agreement_rate |
Fraction of murder rounds where all alive Traitors chose the same target |
accusation_rate |
Fraction of public messages containing a player reference and accusation keyword |
defence_rate |
Fraction of public messages containing a player reference and defence keyword |
Accusation rate — a message is counted if it mentions another player (P<n>) and contains one of:
suspect, suspicious, traitor, lying, liar, untrustworthy
Defence rate — a message is counted if it mentions another player and contains one of:
trust, innocent, faithful, defend, clear, vouch, agree with
Install the analysis dependencies:
pip install -e .[analysis]Run post-hoc analysis for an experiment:
python -m traitors_ai.analysis analyse-experiment-1 \
--run-dir results/experiment_1_baseline_behaviour/run_<id>/Optional analysis settings include SVG export, raw-log analysis, and configurable figure resolution:
python -m traitors_ai.analysis analyse-experiment-1 \
--run-dir results/experiment_1_baseline_behaviour/run_<id>/ \
--export-svg \
--include-raw-log-pass \
--dpi 200Analysis produces tables, figures, text summaries, and diagnostics for each experimental run.
-
fig_1_win_rate_by_role— Overall game outcome
Shows the proportion of games won by Faithful agents compared with Traitor agents. -
fig_2_traitors_remaining_by_round— Traitor survival over rounds
Shows the mean percentage of each game's original Traitors still alive at the start of each round, indicating how long Traitors remain undetected. -
fig_3_voting_accuracy_by_round— Detection over time
Shows the fraction of banishment votes targeting an actual Traitor in each round, allowing changes in detection performance throughout the game to be analysed.
The underlying data for each figure is also exported as CSV for further analysis.
