全程云库模式(cloud_always) + 修正 chessdb 分数口径为行棋方视角(去掉多余翻转); 油猴 v1.6.0 加'全程'开关

This commit is contained in:
AwesomeXiangQi committed 2026-09-13 14:22:05 +08:00
1 parent 06747bf76c
commit 1ed6a176cb
3 files changed
+32 -18

No files matched your search

+8 -10
View File
@@ -67,22 +67,20 @@ class CloudBook:
self._cache[fen] = (now + CACHE_TTL, result)
return result
async def best(self, fen, moves_count=0):
"""返回 (move, score_mover, depth_note)。
async def best(self, fen, moves_count=0, any_score=False):
"""返回 (move, score_mover, note)。
云库分数为红方视角; 轮黑时取负。分数不足 min_score 时放弃(交给引擎)。
moves_count 用于开局阶段放宽采纳阈值(前 8 回合云库几乎必赢)。
实测 chessdb 的 score 就是行棋方视角(与皮卡鱼 UCI 口径一致), 不需翻转。
any_score=True(全程云库): 无条件采纳云库最佳着法。
否则: 开局(≤16步)直接采纳, 中后局要求分数 ≥ min_score。
"""
entries = await self.query_all(fen)
if not entries:
return None
side_is_red = (fen.split()[1] == 'w')
sign = 1 if side_is_red else -1
scored = [(mv, sign * sc) for mv, sc in entries]
scored.sort(key=lambda x: -x[1])
scored = sorted(entries, key=lambda x: -x[1])
mv, sc = scored[0]
# 开局阈值低(云库碾压引擎), 中后局要求云库分足够好
threshold = self.min_score if moves_count >= 16 else 0
threshold = (-10 ** 9) if any_score else (
self.min_score if moves_count >= 16 else 0)
if sc < threshold:
return None
return mv, sc, f'{len(scored)}候选'