DanKS README

项目的 README,来自 github.com/Calix-L/DanKS。合并为一个 markdown 文件:README.md。

English | 简体中文

Kingsoft AI Product Center

DanKS: State-of-the-art GuanDan AI

Three complete generations of code
PPO learning · V3Pro decision refinement · Two generations of KSPlay GuanDan Service

CI GitHub stars Apache-2.0

Play online ↗ · Architecture · Web services · Dataset · Get started · Research

Not just a stronger move. A better plan for the rest of the hand.

GuanDan is a game of partnership, hidden information, and long-term control. The cheapest card to play now may break your best combination; a pass may give your teammate the lead.

DanKS learns to choose with the rest of the hand in mind. Developed by the Kingsoft AI Product Center, it brings structure-aware retrieval and PPO policy learning together—and now pairs the AI codebase with two generations of an open-source web game service. Study the agent, train a policy, build your own table, or simply sit down and play.

DanKS: GuanDan AI from research to a playable browser table

Online demo

Take your seat. Challenge DanKS. No installation required.

Open the online table →

One human player, one AI teammate, and two AI opponents. Play through your browser with a Chinese or English interface.

Watch a short gameplay preview

Animated gameplay preview of the GuanDan online demo
Full-size table preview · Social preview

How DanKS thinks

Preserve useful options. Learn when to use them.

Information state, structured candidate retrieval, Actor-Critic selection, and PPO self-play

  1. Understand the position. Encode the visible hand, public history, legal actions, and team context.
  2. Look beyond the current play. Apply candidate actions and examine the combinations left in the residual hand.
  3. Choose from a compact, meaningful set. Rank structured candidates with a state- and candidate-conditioned Actor-Critic.
  4. Learn from what happens next. PPO and GAE connect a decision to its later consequences.

Retrieval identifies useful options; the learned policy decides which option fits the moment.

Playing a low card, playing a joker, and passing preserve different future options
Same hand. Three choices. Different futures. Click to explore the decision example.

Three generations. One evolving idea.

AI generation Focus Explore
V1 Structural retrieval and a NumPy candidate selector Retrieval ranker
V2 Expanded candidate generation and an ONNX selector Action generator
V3 Memory-aware neural selection, team-belief features, and PPO learning Policy network · PPO training
V3Pro V3 inference refinement: asset protection, equivalent-play rules, and verified endgame search Policy · Integration guide

V3Pro extends V3 as the separate DanKSPro package. It refines inference without replacing the network or retraining it. Endgame refinement covers admitted positions with at most 16 remaining cards across the table; for 11–16 cards, hidden-card allocations are additionally capped at 128.

KSPlay GuanDan Service

The AI is only half the experience. Now the table is open source, too.

Both Service generations include the browser frontend, room backend, GuanDan referee, full source-built hand arrangement, and a standard external AI interface.

Explore Service V1 → · Explore Service V2 →

The service versions describe the web platform, independently of the AI generations. Both run locally with example rule-based bots; connect your own model through the HTTP AI interface. Trained weights and private AI serving infrastructure are not included.

Build on it

Your idea Start here
Redesign the table or card interactions V2 frontend
Extend rooms, game flow, or realtime updates V2 backend
Customize hand arrangement Go arranger
Connect a new AI AI request/response contract
Find the right module to change Service development guide

Human GuanDan data

Study complete matches, not just isolated moves.

The public KSCB GuanDan dataset, maintained in CardKS, contains 899 complete promotion matches, 10,218 rounds, and 840,194 decision points. Ordered round events make it useful for studying human decisions, partnership play, and hand structure over time.

Explore the data → · Source format →

The datasets/ directory links to the original release and provides download and reading examples. Data stays in CardKS; DanKS does not duplicate it. These are match records, not precomputed PPO inputs.

Get started

Play your own local table

Use Python 3.12 and Go 1.23+. From a POSIX shell:

git clone https://github.com/Calix-L/DanKS.git
cd DanKS/services/v2
python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
python scripts/build_arranger.py
python run.py

Open http://127.0.0.1:8000/solo, create a table, and click Ready. Three example bots fill the other seats. Ctrl+C stops the service.

On Windows PowerShell, create the environment with py -3.12 -m venv .venv and activate it with .venv\Scripts\Activate.ps1. To use the original table, choose services/v1 instead.

Explore the AI

In a separate Python 3.11+ environment, run from the repository root:

python3.11 -m venv .venv-ai
source .venv-ai/bin/activate
python -m pip install -e . -e versions/v3 -e versions/v3pro
python -m pip install torch==2.8.0
python examples/retrieval_quickstart.py --version v3
python examples/v3_model_smoke.py
python examples/v3pro_smoke.py

The examples exercise retrieval, network inference, and V3Pro integration using synthetic inputs; model smoke runs use random initialization. For CPU/CUDA/NPU setup, V1/V2 installation, and PPO learner commands, follow the developer guide. For optional Linux/macOS C++ retrieval acceleration, run danks-build-native in your V3 environment.

Inside the repository

DanKS/
├── versions/           # AI: V1, V2, V3, and the V3Pro extension
├── services/
│   ├── v1/             # KSPlay GuanDan Service · original table
│   └── v2/             # KSPlay GuanDan Service · redesigned table
├── guandan/engine/     # Shared AI-side GuanDan rules engine
├── examples/           # Executable engine, retrieval, model, and PPO examples
├── datasets/           # Public GuanDan data links and reading guide
├── assets/             # Brand, gameplay preview, and architecture illustrations
└── .github/            # Contribution and developer guides, CI

Each Service is independently runnable and keeps its own rules and hand-arrangement modules. The AI generations remain separate packages; use a dedicated environment for each generation.

Join the project

Build a new agent. Create a better table. Explore a new idea in partnership play.

Contributions to algorithms, UI, portability, and documentation are welcome. Start with the contribution guide or open an issue.

Repositories: GitHub · AtomGit mirror
Research: CardKS
License: Apache-2.0 · Notices

Star history

DanKS star history

DanKS (Calix-L/DanKS)

正在搜索数据库…

这是什么?DanKS 是一个旨在精通掼蛋(GuanDan)的 AI 智能体,掼蛋是一种四人、基于搭档配合的中国牌类游戏。该项目由金山 AI 产品中心开发。
这是一个能玩的应用,还是一个研究代码库?它是一个研究代码库,不是打包好的应用:包含智能体三代完整、可安装的版本(V1、V2、V3),外加一个浏览器演示,无需任何本地配置就能与机器人对战。
怎么让它跑起来?用 'python -m pip install -e .[dev]' 安装共享规则引擎,然后安装一个世代包,例如 'versions/v3';V3 还要选择匹配的 PyTorch 构建(CPU、CUDA 或 Ascend NPU)。
三代之间可以互相替换吗?不能——V1(NumPy 选择器)、V2(ONNX 选择器)和 V3(PPO 策略)各有自己的包、Python 版本要求和检查点格式,因此每一代都需要各自专用的虚拟环境。
可选的 C++ 加速在 Windows 上也能用吗?不能——优化过的 C++ 检索内核只能在带 C++17 工具链的 Linux 和 macOS 上构建;在 Windows 上会自动回退到纯 Python 实现。
DanKS 为什么保留三个独立世代,而不是只用一个模型?每一代都标志着一个重大算法进步——V1 的结构化候选检索、V2 的基于学习的 ONNX 选择,以及 V3 带团队信念建模、感知内存的 PPO 策略——分开保留是为了让演进脉络易于阅读、运行和比较。
不安装任何东西能试用 DanKS 吗?可以。有一个在线演示,一个真人座位对三个机器人座位,无需本地配置,提供中文和英文界面。
DanKS 是怎么决定出哪张牌的?它先对游戏状态进行编码,检索一组数量有限、结构多样的候选出牌,然后用一个通过自我对弈和 PPO 训练的共享 actor-critic 网络为它们打分。
DanKS 对阵其他掼蛋机器人有多强?在完整的升级赛(promotion-match)协议下,其报告结果显示它领先于基于学习和基于规则的各类掼蛋基线。
作者
Calix-L
大小
23.2 MB
星标
834
时长
3个月
提交 · 90 天