diff --git a/xiangqi-engine.user.js b/xiangqi-engine.user.js index 532d216..9d91b05 100644 --- a/xiangqi-engine.user.js +++ b/xiangqi-engine.user.js @@ -2,7 +2,7 @@ // @name Xiangqi.com 本地皮卡鱼引擎对接 // @name:en Xiangqi.com Local Pikafish Engine // @namespace awesome-xiangqi -// @version 1.4.1 +// @version 1.5.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.4.1"; + const VERSION = "1.5.0"; const PATCH_MARK = Symbol.for("xiangqi.pikafish.ws.patched"); const uW = typeof unsafeWindow !== "undefined" ? unsafeWindow : window; @@ -48,6 +48,7 @@ const cfg = { enabled: storage.get("pf_enabled", "0") === "1", + useCloud: storage.get("pf_usecloud", "1") === "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), @@ -60,6 +61,7 @@ function saveCfg() { storage.set("pf_enabled", cfg.enabled ? "1" : "0"); + storage.set("pf_usecloud", cfg.useCloud ? "1" : "0"); storage.set("pf_movetime", cfg.movetime); storage.set("pf_depth", cfg.depth); storage.set("pf_firstdelay", cfg.firstDelay); @@ -195,7 +197,7 @@ let liveWS = null; - async function engineBestmove({ moves, fen, movetime, depth, signal }) { + async function engineBestmove({ moves, fen, movetime, depth, useCloud, signal }) { const timeoutMs = Math.max(15000, movetime * 4 + 2000); const ctrl = new AbortController(); const timer = setTimeout( @@ -216,6 +218,7 @@ fen: fen || undefined, movetime, depth: depth > 0 ? depth : undefined, + cloud: useCloud !== false, }), signal: ctrl.signal, }); @@ -296,6 +299,7 @@ fen: G.fen, movetime: cfg.movetime, depth: cfg.depth, + useCloud: cfg.useCloud, }); if (reqId !== G.reqId) return; if (G.over) throw new Error("对局已结束"); @@ -494,6 +498,7 @@