Skip to content

Commit 191f637

Browse files
committed
feat: add chinese readme
1 parent e819ac3 commit 191f637

File tree

2 files changed

+210
-1
lines changed

2 files changed

+210
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# LieGraph – An AI Agent-Driven "Who Is Spy" Game
2+
[English Version](README.md) | [中文版本](README_zh.md)
3+
4+
![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg) ![uv](https://img.shields.io/badge/uv-ready-5A45FF.svg) ![CI Friendly](https://img.shields.io/badge/ci-friendly-success.svg) ![License](https://img.shields.io/badge/license-MIT-black.svg)
25

36
LieGraph is a multi-agent implementation of the popular social deduction game "Who Is spy," built with LangGraph. It features AI agents that can reason, strategize, and interact in natural language to find the spy among them.
47

@@ -199,4 +202,4 @@ Contributions are welcome! Please:
199202

200203
## 📄 License
201204

202-
MIT License
205+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

README_zh.md

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
# LieGraph – AI 智能体驱动的 "谁是卧底" 游戏
2+
3+
[English Version](README.md) | [中文版本](README_zh.md)
4+
5+
![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg) ![uv](https://img.shields.io/badge/uv-ready-5A45FF.svg) ![CI Friendly](https://img.shields.io/badge/ci-friendly-success.svg) ![License](https://img.shields.io/badge/license-MIT-black.svg)
6+
7+
LieGraph 是基于 LangGraph 构建的流行社交推理游戏 "谁是卧底" 的多智能体实现。它具备能够推理、制定策略并以自然语言互动的 AI 智能体,用于在玩家中找出卧底。
8+
9+
![LieGraph UI 截图](ui-web/frontend/demo/chinese-demo.png?raw=true)
10+
11+
## ✨ 功能特性
12+
13+
- **自主 AI 智能体:** 具有独特个性和战略思维能力的 AI 玩家
14+
- **动态身份推理:** 智能体持续分析对话历史和投票模式来推断自己和他人的身份
15+
- **自然语言交互:** 智能体在整个游戏中以自然语言进行交流和推理
16+
- **概率信念系统:** 具有自我信念置信度和怀疑矩阵的复杂信念追踪系统
17+
- **战略推理:** 高级的虚张声势检测、联盟形成和长期规划
18+
19+
## 🚀 快速开始
20+
21+
### 环境要求
22+
23+
- Python 3.12+
24+
- Node.js 16+
25+
- `uv` (推荐用于 Python 包管理)
26+
27+
### 环境变量
28+
29+
在根目录创建 `.env` 文件并配置您的 LLM:
30+
31+
```bash
32+
touch .env
33+
```
34+
35+
**OpenAI 配置示例:**
36+
```
37+
LLM_PROVIDER=openai
38+
OPENAI_API_KEY="your_openai_api_key_here"
39+
OPENAI_MODEL="gpt-4o-mini"
40+
```
41+
42+
**DeepSeek 配置示例:**
43+
```
44+
LLM_PROVIDER=deepseek
45+
DEEPSEEK_API_KEY="your_deepseek_api_key_here"
46+
DEEPSEEK_MODEL="deepseek-chat"
47+
```
48+
49+
### 安装与运行
50+
51+
1. **克隆并设置:**
52+
```bash
53+
git clone https://github.com/leslieo2/LieGraph.git
54+
cd LieGraph
55+
```
56+
57+
2. **安装依赖:**
58+
```bash
59+
# 如需安装 uv
60+
curl -LsSf https://astral.sh/uv/install.sh | sh
61+
uv sync
62+
63+
# 安装 UI 依赖
64+
cd ui-web/frontend
65+
npm install
66+
```
67+
68+
3. **启动服务:**
69+
```bash
70+
# 后端 (从项目根目录)
71+
langgraph dev --config langgraph.json --port 8124 --allow-blocking
72+
73+
# 前端 (从 ui-web/frontend 目录)
74+
npm start
75+
```
76+
77+
打开 `http://localhost:3000` 开始游戏。
78+
79+
## 🎮 工作原理
80+
81+
### 游戏流程
82+
83+
游戏由 LangGraph 的 `StateGraph` 编排,管理完整的游戏生命周期:
84+
85+
1. **设置:** 主持智能体分配角色(平民/卧底)和对应词语
86+
2. **发言阶段:** 玩家轮流使用基于 LLM 的推理描述他们的词语
87+
3. **身份推理:** 智能体分析对话模式来推断角色
88+
4. **投票阶段:** 所有玩家基于累积证据同时投票
89+
5. **结果:** 得票最多的玩家被淘汰
90+
6. **胜利条件:** 卧底被投出时游戏结束(平民胜利)或卧底人数超过平民时(卧底胜利)
91+
92+
### AI 智能体架构
93+
94+
每个 AI 玩家维护一个不断发展的 "思维模式",具备复杂的推理能力:
95+
96+
- **动态身份推理:**
97+
- 通过词语描述和投票模式进行自我身份分析
98+
- 其他玩家分析,追踪发言模式和策略行为
99+
- 实时对话历史处理以检测不一致性
100+
101+
- **概率信念系统:**
102+
- 基于累积证据的自我信念置信度
103+
- 追踪对其他玩家概率信念的怀疑矩阵
104+
- 系统记录可疑行为的证据
105+
106+
- **战略推理:**
107+
- 虚张声势检测和反虚张声势策略
108+
- 联盟形成和背叛预防
109+
- 基于不断发展的身份信念进行长期规划
110+
111+
```mermaid
112+
graph TD
113+
START[START] --> HS[host_setup]
114+
HS --> HSS[host_stage_switch]
115+
116+
HSS -->|speaking| SpeechNodes
117+
subgraph SpeechNodes [发言阶段]
118+
direction LR
119+
PS[player_speech_N]
120+
end
121+
SpeechNodes --> HSS
122+
123+
HSS -->|voting| VoteNodes
124+
subgraph VoteNodes [投票阶段 - 并发]
125+
direction LR
126+
PV[player_vote_N]
127+
end
128+
129+
VoteNodes --> CVT[check_votes_and_transition]
130+
131+
CVT -->|votes ready| HR[host_result]
132+
CVT -->|waiting| __continue__
133+
134+
HR -->|continue| HSS
135+
HR -->|end| END[END]
136+
137+
classDef hostNode fill:#e1f5fe
138+
classDef playerNode fill:#f3e5f5
139+
classDef transitionNode fill:#e8f5e8
140+
141+
class HS,HSS,HR hostNode
142+
class PS,PV playerNode
143+
class CVT transitionNode
144+
```
145+
146+
## ⚙️ 配置
147+
148+
通过编辑 `config.yaml` 自定义游戏:
149+
150+
```yaml
151+
game:
152+
player_count: 6
153+
vocabulary:
154+
- ["Shakespeare", "Dumas"]
155+
- ["太阳", "月亮"]
156+
player_names:
157+
- "Alice"
158+
- "Bob"
159+
# ...
160+
```
161+
162+
## 🛠️ 开发
163+
164+
### 项目结构
165+
```
166+
LieGraph/
167+
├── src/
168+
│ ├── game/
169+
│ │ ├── graph.py # 主 LangGraph 工作流
170+
│ │ ├── state.py # 游戏状态定义
171+
│ │ ├── nodes/ # 图节点实现
172+
│ │ ├── rules.py # 游戏逻辑和胜利条件
173+
│ │ └── llm_strategy.py # AI 推理和发言生成
174+
├── tests/ # Pytest 测试套件
175+
├── ui-web/frontend/ # React 网页界面
176+
└── config.yaml # 游戏配置
177+
```
178+
179+
### 系统架构
180+
181+
有关详细的架构信息、组件设计和集成模式,请参阅 [ARCHITECTURE.md](ARCHITECTURE.md)。
182+
183+
### 运行测试
184+
```bash
185+
python -m pytest tests/ -v
186+
```
187+
188+
## 🗺️ 路线图
189+
190+
- [ ] 增强 AI 策略和长期记忆
191+
- [ ] 游戏回放和分析功能
192+
- [ ] 支持更复杂的游戏模式
193+
- [ ] LLM 基准测试能力,用于评估不同模型
194+
195+
## 🤝 贡献
196+
197+
欢迎贡献!请:
198+
199+
1. Fork 仓库
200+
2. 创建功能分支
201+
3. 进行更改并添加测试
202+
4. 提交 pull request
203+
204+
## 📄 许可证
205+
206+
本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件。

0 commit comments

Comments
 (0)