全球首个商用级棋牌AI推理API — 覆盖9种主流玩法,毫秒级响应
注册麻邻国会员后,在控制台获取你的 API Key。免费额度:100次/天。
import requests
API_KEY = "your_api_key_here"
BASE_URL = "https://api.malinguo.com/v1"
resp = requests.post(f"{BASE_URL}/predict", json={
"game": "sichuan",
"hand": ["1m","2m","3m","4p","5p","6p","7s","8s","9s","1z","1z","2z","3z"],
"discards": [],
"dora": ["5m"],
"seat_wind": "E",
"round_wind": "E"
}, headers={"Authorization": f"Bearer {API_KEY}"})
data = resp.json()
print(f"推荐打: {data['best_tile']}")
print(f"置信度: {data['confidence']:.1%}")
print(f"胜率: {data['win_rate']:.1%}")
curl -X POST https://api.malinguo.com/v1/predict \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"game": "sichuan",
"hand": ["1m","2m","3m","4p","5p","6p","7s","8s","9s","1z","1z","2z","3z"],
"discards": [],
"dora": ["5m"],
"seat_wind": "E",
"round_wind": "E"
}'
const resp = await fetch("https://api.malinguo.com/v1/predict", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
game: "sichuan",
hand: ["1m","2m","3m","4p","5p","6p","7s","8s","9s","1z","1z","2z","3z"],
discards: [],
dora: ["5m"],
seat_wind: "E",
round_wind: "E"
})
});
const data = await resp.json();
console.log(`推荐打: ${data.best_tile}, 置信度: ${data.confidence}`);
{
"best_tile": "3z",
"confidence": 0.87,
"win_rate": 0.42,
"alternatives": [
{"tile": "2z", "probability": 0.09},
{"tile": "1z", "probability": 0.03}
],
"explanation": "3z是孤立字牌,与手牌无搭子关系。手牌主力为万子和筒子,优先清理字牌。",
"tags": ["孤张", "效率"],
"shanten": 1,
"latency_ms": 12
}
根据当前手牌状态,返回AI推荐的最佳出牌。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
game | string | ✓ | 玩法:sichuan changsha guangdong hongzhong riichi taiwan doudizhu guandan texas |
hand | string[] | ✓ | 手牌数组,如 ["1m","2m","3m"] |
discards | string[] | 已出的牌(用于推断安全牌) | |
dora | string[] | 宝牌指示器(日麻/台湾麻将) | |
seat_wind | string | 自风:E/S/W/N | |
round_wind | string | 场风 | |
melds | object[] | 已副露的面子 | |
missing_suit | string | 四川麻将定缺花色:m/p/s |
评估指定模型在给定对手下的胜率。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
game | string | ✓ | 玩法类型 |
model | string | 模型版本(默认latest) | |
opponent | string | random/greedy(默认random) | |
episodes | int | 评估局数(默认100,最大500) |
返回所有可用模型及其最新胜率指标。
{
"models": [
{
"game": "changsha",
"version": "evo-gen3",
"vs_random": 0.43,
"vs_greedy": 0.20,
"updated_at": "2026-03-16"
},
...
]
}
对指定出牌生成策略解释文本(中文)。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
game | string | ✓ | 玩法类型 |
hand | string[] | ✓ | 手牌 |
tile | string | ✓ | 要解释的出牌 |
confidence | float | 置信度(0-1) | |
win_rate | float | 当前胜率(0-1) |
| 花色 | 编码 | 示例 |
|---|---|---|
| 万子 | 1m ~ 9m | 一万=1m, 九万=9m |
| 筒子 | 1p ~ 9p | 一筒=1p |
| 条子 | 1s ~ 9s | 一条=1s |
| 风牌 | E S W N | 东=E |
| 三元牌 | Z F B | 中=Z, 发=F, 白=B |
| 编码 | 示例 |
|---|---|
{rank}{suit} | Ah=黑桃A, Kd=方块K, Tc=梅花10 |
花色: h=红心 d=方块 c=梅花 s=黑桃 | |
大小王: JK jk | 掼蛋/斗地主用 |
| HTTP | 代码 | 说明 |
|---|---|---|
| 400 | invalid_hand | 手牌格式错误或数量不对 |
| 400 | unsupported_game | 不支持的玩法 |
| 401 | unauthorized | API Key无效或过期 |
| 429 | rate_limited | 超过每日配额,请升级套餐 |
| 500 | model_error | 模型推理异常(请重试) |
# pip install malinguo
from malinguo import MalinguoClient
client = MalinguoClient(api_key="your_key")
# 推荐出牌
advice = client.predict(
game="sichuan",
hand=["1m","2m","3m","4p","5p","6p","7s","8s","9s","1z","1z","2z","3z"],
missing_suit="s"
)
print(advice.best_tile) # "3z"
print(advice.confidence) # 0.87
print(advice.explanation) # "3z是孤立字牌..."
print(advice.alternatives) # [{"tile":"2z","probability":0.09}, ...]
# 查看所有模型
models = client.list_models()
for m in models:
print(f"{m.game}: vs_random={m.vs_random:.0%}")
| 玩法 | API代码 | 状态 | 最新vs random胜率 |
|---|---|---|---|
| 长沙麻将 | changsha | ✅ 可用 | 43% |
| 四川麻将 | sichuan | ✅ 可用 | 29% |
| 广东麻将 | guangdong | ✅ 可用 | 22% |
| 红中麻将 | hongzhong | ✅ 可用 | 8% |
| 日本麻将 | riichi | ✅ 可用 | 17% |
| 台湾麻将 | taiwan | ✅ 可用 | 10% |
| 斗地主 | doudizhu | 🔄 训练中 | - |
| 掼蛋 | guandan | 🔄 训练中 | - |
| 德州扑克 | texas | 🔄 训练中 | - |
© 2026 麻邻国 AI · 首页 · AI教练 · dev@malinguo.com