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, китайской карточной игры на четырёх игроков, где партнёры играют парами; разработан центром ИИ-продуктов Kingsoft.
Это играбельное приложение или исследовательская кодовая база?Это исследовательская кодовая база, а не упакованное приложение: три полных устанавливаемых поколения агента (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++-ядра поиска собираются только на Linux и macOS с тулчейном C++17; на Windows автоматически используется запасная чистая реализация на Python.
Почему в DanKS три отдельных поколения, а не одна модель?Каждое поколение отмечает крупный алгоритмический шаг — структурный поиск кандидатов в V1, обучаемый выбор на ONNX в V2 и PPO-политику с учётом памяти и моделированием командных убеждений в V3, — и их держат раздельно, чтобы эту прогрессию было легко читать, запускать и сравнивать.
Можно попробовать DanKS, ничего не устанавливая?Да, есть онлайн-демо: одно место за человеком против трёх мест за ботами, без локальной настройки, с интерфейсами на китайском и английском.
Как DanKS решает, какую карту сыграть?Он кодирует состояние игры, извлекает ограниченный набор структурно разнообразных вариантов хода, а затем оценивает их общей сетью actor-critic, обученной через self-play и PPO.
Насколько силён DanKS против других ботов в GuanDan?Автор сообщает о лидирующих результатах против базовых ботов GuanDan — как обучаемых, так и построенных на правилах — по полному протоколу матчей на повышение.
Автор
Calix-L
Размер
23.2 MB
Звёзды
834
Возраст
3 мес
Коммиты · 90 дней