From 454c9a6d6b699d68e7c79ed62252fb16cae8520d Mon Sep 17 00:00:00 2001 From: giteaadmin Date: Fri, 24 Apr 2026 13:42:06 +0000 Subject: [PATCH] play: throttle quiz_carry preview bot pathfinding; slower path steps in editor embed Made-with: Cursor --- www/html/Game/public/js/play.js | 18 +++++++++++++++++- www/html/Game/public/play.html | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/www/html/Game/public/js/play.js b/www/html/Game/public/js/play.js index 341cd8e..58141e4 100644 --- a/www/html/Game/public/js/play.js +++ b/www/html/Game/public/js/play.js @@ -1083,6 +1083,7 @@ balloonBossScore: 0, balloonBossBalloons: 5, balloonBossEliminated: false, + botQuizCarryPathfindAfter: performance.now() + previewBotSeq * 75 + Math.floor(Math.random() * 160), }); botIds.push(id); } @@ -1104,6 +1105,14 @@ o.ty = s.y; }); } + if (mapData.gameType === 'quiz_carry') { + const t0 = performance.now(); + [...others.keys()].filter(isPreviewBotId).forEach((bid, idx) => { + const o = others.get(bid); + if (!o) return; + o.botQuizCarryPathfindAfter = t0 + idx * 90 + Math.floor(Math.random() * 140); + }); + } if (mapData.gameType === 'gauntlet') { applyGauntletPreviewSpawnLayout(false); emitGauntletPreviewRowsToServer(); @@ -2039,6 +2048,8 @@ function stepQuizCarryPreviewBots() { if (!previewFillBots || !isQuizCarry() || !mapData || !quizCarryCurrent) return; const w = mapData.width || 20, h = mapData.height || 15; + const nowPf = performance.now(); + const pathfindMinGap = editorEmbedReturn ? 280 : 140; others.forEach((o, id) => { if (!isPreviewBotId(id)) return; if (!o.botPath || o.botPath.length === 0) { @@ -2050,6 +2061,9 @@ : Math.floor(Math.random() * Math.max(2, (quizCarryCurrent.choices || []).length)); const wantIdx = pickQuizCarryTargetOptionIndexAvoidingTaken(rawWant); if (!o.botPath || !o.botPath.length) { + if (typeof o.botQuizCarryPathfindAfter !== 'number') o.botQuizCarryPathfindAfter = 0; + if (nowPf < o.botQuizCarryPathfindAfter) return; + const jitter = (String(id).length * 31 + ((o.x | 0) ^ (o.y | 0)) * 7) % 160; if (o.quizCarryHeld == null && wantIdx != null) { const dest = pickRandomTileForQuizCarryOption(mapData, wantIdx, o); if (dest) { @@ -2063,6 +2077,7 @@ if (path && path.length > 1) o.botPath = path.slice(1); } } + o.botQuizCarryPathfindAfter = nowPf + pathfindMinGap + jitter; } else { stepPreviewBotAlongPath(o, w, h); } @@ -5805,7 +5820,8 @@ return; } const len = dist || 1; - const step = Math.min(MOVE_SPEED * 1.28, len); + const pathStepMul = (previewFillBots && editorEmbedReturn) ? 0.56 : 1; + const step = Math.min(MOVE_SPEED * 1.28 * pathStepMul, len); const nx = o.x + (dx / len) * step; const ny = o.y + (dy / len) * step; if (Math.abs(dy) > Math.abs(dx)) o.direction = dy > 0 ? 'down' : 'up'; diff --git a/www/html/Game/public/play.html b/www/html/Game/public/play.html index ef599cc..ca58e90 100644 --- a/www/html/Game/public/play.html +++ b/www/html/Game/public/play.html @@ -669,7 +669,7 @@ - +
v —