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

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

No files matched your search

+16 -4
View File
@@ -2,7 +2,7 @@
// @name Xiangqi.com 本地皮卡鱼引擎对接
// @name:en Xiangqi.com Local Pikafish Engine
// @namespace awesome-xiangqi
// @version 1.5.0
// @version 1.6.0
// @description 在 play.xiangqi.com 对局中调用本地皮卡鱼引擎(http://127.0.0.1:9377)自动/手动走子
// @description:en Hook the site WebSocket and let a local Pikafish engine play for you
// @match https://play.xiangqi.com/*
@@ -16,7 +16,7 @@
const ENGINE_URL = "http://127.0.0.1:9377";
const NS = "42/xiangqi,";
const FIRST_MOVE_EXTRA_SEC = 5;
const VERSION = "1.5.0";
const VERSION = "1.6.0";
const PATCH_MARK = Symbol.for("xiangqi.pikafish.ws.patched");
const uW = typeof unsafeWindow !== "undefined" ? unsafeWindow : window;
@@ -49,6 +49,7 @@
const cfg = {
enabled: storage.get("pf_enabled", "0") === "1",
useCloud: storage.get("pf_usecloud", "1") === "1",
cloudAlways: storage.get("pf_cloudalways", "0") === "1",
movetime: Math.max(50, +storage.get("pf_movetime", 800) || 800),
depth: Math.max(0, +storage.get("pf_depth", 0) || 0),
firstDelay: Math.max(0, +storage.get("pf_firstdelay", 0) || 0),
@@ -62,6 +63,7 @@
function saveCfg() {
storage.set("pf_enabled", cfg.enabled ? "1" : "0");
storage.set("pf_usecloud", cfg.useCloud ? "1" : "0");
storage.set("pf_cloudalways", cfg.cloudAlways ? "1" : "0");
storage.set("pf_movetime", cfg.movetime);
storage.set("pf_depth", cfg.depth);
storage.set("pf_firstdelay", cfg.firstDelay);
@@ -197,7 +199,7 @@
let liveWS = null;
async function engineBestmove({ moves, fen, movetime, depth, useCloud, signal }) {
async function engineBestmove({ moves, fen, movetime, depth, useCloud, cloudAlways, signal }) {
const timeoutMs = Math.max(15000, movetime * 4 + 2000);
const ctrl = new AbortController();
const timer = setTimeout(
@@ -219,6 +221,7 @@
movetime,
depth: depth > 0 ? depth : undefined,
cloud: useCloud !== false,
cloud_always: !!cloudAlways,
}),
signal: ctrl.signal,
});
@@ -300,6 +303,7 @@
movetime: cfg.movetime,
depth: cfg.depth,
useCloud: cfg.useCloud,
cloudAlways: cfg.cloudAlways,
});
if (reqId !== G.reqId) return;
if (G.over) throw new Error("对局已结束");
@@ -498,7 +502,8 @@
<div class="title"><span>🐴 皮卡鱼</span><span class="dot" id="pf-dot" style="background:#666"></span></div>
<div class="row"><label><input type="checkbox" id="pf-enabled"> 自动走子</label>
<span id="pf-side-hint"></span></div>
<div class="row"><label><input type="checkbox" id="pf-cloud"> 使用云库</label></div>
<div class="row"><label><input type="checkbox" id="pf-cloud"> 使用云库</label>
<label><input type="checkbox" id="pf-cloudalways"> 全程</label></div>
<div class="row"><span>每步用时(ms)</span><input type="number" id="pf-mt" min="50" step="50"></div>
<div class="row"><span>深度(0=用时间)</span><input type="number" id="pf-depth" min="0" max="40" step="1"></div>
<div class="row"><span>首步延迟(秒+5)</span><input type="number" id="pf-delay" min="0" max="120" step="1"></div>
@@ -532,6 +537,13 @@
if (cfg.enabled) scheduleTurn(0);
});
const caCb = panel.querySelector("#pf-cloudalways");
caCb.checked = cfg.cloudAlways;
caCb.addEventListener("change", () => {
cfg.cloudAlways = caCb.checked;
saveCfg();
});
const mt = panel.querySelector("#pf-mt");
mt.value = cfg.movetime;
mt.addEventListener("change", () => {