Skip to content 跳到正文
JW.

Multi-agent game · local experiment 多 Agent 博弈 · 本地实验

Texas-Poker-Agents Texas-Poker-Agents

A complete, locally runnable multiplayer LLM poker system and a testbed for behavior in imperfect-information games.

一个完整、可本地运行的多人 LLM 德州扑克系统,也可以作为研究不完美信息博弈中模型行为的实验环境。

Status 状态 Public repository · actively evolving 公开仓库 · 仍在迭代
Built with 主要技术 Node.js · SSE · JSONL · OpenAI-compatible APIs

这不是一个“让 LLM 打扑克”的单点 demo

真正让我感兴趣的是不完美信息:一个座位不应该看到别人的手牌、未来公共牌或服务端调试信息。只要这条边界没守住,后面的策略分析都没有意义。

所以模型不负责发牌和计分。它只收到该座位的可见状态,返回一次动作建议。

规则引擎说了算,模型不能改牌局

Node 服务端负责洗牌、发牌、合法动作、盲注、边池、all-in、摊牌和比赛推进。页面支持一名真人和多个 LLM 座位,每个座位可以单独设置模型和牌风 prompt。

模型返回非法 JSON、超出筹码的下注或不可用动作时,服务端会标出 fallback,并选择 check / fold 托管,不让整桌卡死。

rules engine → seat-visible state → LLM proposal → legality check → game state

每手牌都要留下能看的记录

所有事件会追加写入 data/sessions/*.jsonl,也能从页面导出 JSON。房主可以在牌后打开 god view,看暗牌、简短 reasoning summary、fallback 和 hand reflection。

引擎测试覆盖牌型、边池、run-it 多次结算、heads-up 行动顺序、盲注翻倍、table-talk 暗牌过滤和筹码守恒。

对 Agent 行为的信任,应该从信息边界、合法性检查和日志开始,而不是从一段看起来聪明的推理开始。

本地开桌

项目只依赖 Node.js 20+ 和内置模块,不需要数据库。没有 API key 时 LLM 座位仍可参与流程,但会使用服务端 fallback。

npm start # open http://127.0.0.1:3000 npm run check

More than a one-shot “LLM plays poker” demo

The interesting part is imperfect information. A seat must not see another player's cards, future community cards, or server-only debug state. If that boundary fails, any strategy analysis afterward is meaningless.

The model therefore owns neither the deck nor the score. It receives a seat-visible state and returns one proposed action.

The rules engine is authoritative

The Node server owns shuffling, dealing, legal actions, blinds, side pots, all-ins, showdown, and match flow. One human can share the table with several LLM seats, each with its own model and style prompt.

If a model returns broken JSON, an impossible bet, or an illegal action, the server marks the fallback and chooses check or fold instead of freezing the table.

rules engine → seat-visible state → LLM proposal → legality check → game state

Every hand leaves a useful trail

Events append to data/sessions/*.jsonl and can also be exported from the page. After a hand, the host can open a god view for hole cards, short reasoning summaries, fallbacks, and hand reflections.

Engine tests cover hand ranking, side pots, run-it-multiple-times settlement, heads-up action order, blind increases, table-talk filtering, and chip conservation.

Trust in an agent should begin with information boundaries, legality checks, and logs, not with a convincing paragraph of reasoning.

Start a local table

The project needs Node.js 20+ and uses only built-in modules, with no database. Without an API key, LLM seats still participate through the server fallback.

npm start # open http://127.0.0.1:3000 npm run check