Skip to content

Commit f02823f

Browse files
authored
feat: Social Deduction Game demo (#36)
* feat: scaffold social deduction game — config, template, README Add the supporting files for the Undercover/Spy Words social deduction game demo: Ollama config, description-phase prompt template, and README with hypothesis, game mechanics, and setup instructions. * feat: social deduction game — core game logic and .nlogox model Implement the full Undercover/Spy Words social deduction game with: - Circle layout for N players (4-8), one randomly assigned as spy - Description phase using llm:chat-with-template for word clues - Voting phase using llm:choose for constrained spy identification - Elimination with tie-breaking, win condition checks - 15 word pairs across 3 difficulty tiers - Cumulative stats tracking across games (detection rate, wins) - Vote plot and detection rate plot - Word leak protection and LLM error fallbacks * fix: nlogox widget attributes and template variable format - Add disableUntilTicks to buttons (required attribute) - Add fontSize to monitors (required attribute) - Fix plot attributes to camelCase (xMin/xMax/yMin/yMax/autoPlotX/autoPlotY) - Fix llm:chat-with-template to use nested [key value] pairs - Use llama3.2:3b model name in config * feat: visual polish — noir theme, distinct colors, vote arrows, phase indicator - Fix player visibility: radius 10, -90° offset (12 o'clock start), size 4.0 - Distinct player colors: 8-color palette with base-color variable - Dark noir background: charcoal gradient + dark red circular table - Vote arrows: directed links from voter to target in voter's color - Center phase indicator: shows round, phase, elimination, and win state - Spy reveal: size 5.0, bright red, all words shown on reveal - Eliminated players: muted color (base-color - 4) instead of gray - Correct link shape XML for NetLogo 7.0.3 format * refactor: extract vote prompt to YAML template, use base-color in plot - Add vote-template.yaml with system/template structure matching description template - Replace inline vote prompt with llm:chat-with-template call - Validate LLM response against alive player names, fallback to llm:choose - Update Votes Per Round plot to use per-player base-color instead of red/sky - Update info tab to reflect template-based voting * fix: rewrite prompts for better gameplay — concrete clues, no self-votes Description template: - Demand distinguishing clues: "something TRUE about your word that would NOT be true for a similar word" - Ban vague phrases and "I notice" narration style - Add good vs bad clue examples for calibration - Enforce one sentence under 20 words Vote template: - Add explicit self-vote prevention: "You CANNOT vote for {player_name}" - Reinforce constraint in both system prompt and template - Guide analytical comparison of clues Voting code: - Separate template vote and llm:choose fallback into independent carefully blocks - Prevent cascading errors when template returns self-vote * fix: enforce unique indirect clues, raise temperature for variety - Rewrite description template: demand indirect associations, ban obvious properties - Add good/bad clue examples for calibration - Explicitly label transcript as "DO NOT repeat any of these" - Ban common openings ("Best enjoyed", "Often enjoyed") - Bump temperature to 0.8 in config for more diverse outputs
1 parent 146d64f commit f02823f

6 files changed

Lines changed: 772 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ commands/
5050
config.txt
5151
config-*.txt
5252
!demos/provider-sensitivity/config-multi-provider.txt
53+
!demos/social-deduction-game/config.txt
5354
*.env
5455
*.env.*
5556
*.secrets*
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Social Deduction Game (Undercover / Spy Words)
2+
3+
## Hypothesis
4+
5+
LLM agents will correctly identify spies at below-chance accuracy because they struggle to integrate cross-round description patterns into coherent suspicion, while LLM spies will be caught faster than chance because they produce descriptions that are subtly misaligned with the majority word.
6+
7+
## Source
8+
9+
Inspired by LLMArena (ACL 2024) — social deduction games as an evaluation framework for LLM reasoning and theory of mind.
10+
11+
## Game Mechanics
12+
13+
1. **Setup**: N players arranged in a circle. One is randomly assigned the "spy word"; the rest share the "regular word". Words are similar but distinct (e.g., apple vs pear).
14+
2. **Description Phase**: Each alive player describes their word in 1-2 sentences without saying it.
15+
3. **Voting Phase**: Each alive player votes for who they think is the spy based on descriptions.
16+
4. **Elimination**: The player with the most votes is eliminated.
17+
5. **Win Condition**: Regulars win if the spy is eliminated. The spy wins if only 2 players remain or max rounds are reached.
18+
19+
## Word Pairs (3 difficulty tiers)
20+
21+
| Difficulty | Regular Word | Spy Word |
22+
|-----------|-------------|----------|
23+
| High (hard to detect) | apple/guitar/coffee/pillow/ocean | pear/ukulele/tea/cushion/lake |
24+
| Medium | bicycle/painting/castle/penguin/candle | motorcycle/photograph/mansion/duck/flashlight |
25+
| Low (easy to detect) | airplane/forest/piano/book/snowflake | submarine/desert/drums/television/raindrop |
26+
27+
## Files
28+
29+
| File | Purpose |
30+
|------|---------|
31+
| `social-deduction-game.nlogox` | Main NetLogo model |
32+
| `config.txt` | LLM provider configuration (default: Ollama) |
33+
| `description-template.yaml` | Prompt template for description phase |
34+
| `README.md` | This file |
35+
36+
## Setup
37+
38+
1. Install the LLM extension (see main repo README)
39+
2. Configure `config.txt` with your preferred provider
40+
3. Open `social-deduction-game.nlogox` in NetLogo 7.0.3+
41+
4. Click **Setup** to initialize players
42+
5. Click **Go** to run the full game, or **Step** for one round at a time
43+
44+
## Interface Controls
45+
46+
- **num-players**: Number of players (4-8, default 6)
47+
- **max-rounds**: Maximum rounds before spy wins (3-10, default 6)
48+
- **difficulty-level**: Word pair similarity ("low"/"medium"/"high")
49+
- **show-descriptions?**: Display description speech bubbles
50+
- **show-votes?**: Display vote targets
51+
- **auto-reveal?**: Reveal spy identity when game ends
52+
53+
## Expected Results
54+
55+
- **Detection rate**: Expected below 1/N chance (where N = number of players)
56+
- **Spy survival**: Spy descriptions tend to be subtly "off", leading to faster-than-chance detection in some rounds, but overall detection accuracy remains low because regulars struggle to synthesize cross-round patterns
57+
- **Difficulty effect**: Higher difficulty (more similar words) should decrease detection rate
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
provider=ollama
2+
model=llama3.2:3b
3+
temperature=0.4
4+
max_tokens=80
5+
timeout_seconds=30
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
system: |
2+
You are {player_name} in a social deduction game called Undercover.
3+
Several players each have a secret word. Most share the SAME word, but one player (the spy) has a DIFFERENT but similar word.
4+
Each round you give a clue about your word. After clues, players vote to eliminate the suspected spy.
5+
6+
CRITICAL RULES:
7+
- Your clue must be DIFFERENT from every clue already given. Read the previous clues carefully and say something NEW.
8+
- Be INDIRECT — describe a memory, association, or situation involving your word, NOT its obvious properties
9+
- Do NOT describe what it looks/tastes/smells like directly
10+
- Do NOT say the word itself
11+
- Write exactly ONE sentence, under 20 words
12+
- Do NOT start with "Best enjoyed" or "Often enjoyed" or "My word"
13+
14+
GOOD CLUE EXAMPLES (indirect, subtle):
15+
- "Some people collect fancy versions of these from around the world."
16+
- "You might see one of these at a birthday party or during a power outage."
17+
18+
BAD CLUE EXAMPLES (too obvious, reveals the word):
19+
- "It is brewed in a pot every morning" — too obvious
20+
- "It has a warm glow and a wick" — basically says the word
21+
22+
template: |
23+
Your secret word is: {my_word}
24+
Round {round_number}.
25+
26+
Previous clues from all players (DO NOT repeat any of these):
27+
{transcript}
28+
29+
Think of a unique angle or personal association with your word that nobody has mentioned yet. Write ONE indirect, subtle clue under 20 words.

0 commit comments

Comments
 (0)