commit 53c719fefdf6f437deb0b34eb1b8dbff56d06643
parent 7ec3ff4435d0c822bb73dc7b4689cc4908ca9883
Author: Brian Graham <brian@buildingbetterteams.de>
Date: Thu, 9 Apr 2026 11:20:13 +0200
Add grid re-sampling after game start detection
If initial calibration finds no grid (renderer: unknown), re-calibrate
after the game starts. Games that create DOM cells dynamically via JS
(innerHTML on render loop) have 0 children at page load but 200 after
starting. Records grid_detected_at: "initial" vs "after_start" in report.
Known issue: e2e04e75 game has startBtn button but bot falsely detects
start via Space (something changed but game didn't actually start).
Needs stronger start verification in next session.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/tasks/tetris/eval/gameplay-bot/index.ts b/tasks/tetris/eval/gameplay-bot/index.ts
@@ -175,6 +175,7 @@ test.describe("Tetris Gameplay Bot", () => {
implementation: {
renderer: calibration.renderer,
grid_detected: calibration.gridDetected,
+ grid_detected_at: (calibration as any).grid_detected_at || "initial",
grid_bounds: calibration.gridBounds,
controls: calibration.controls as unknown as Record<string, string>,
start_mechanism: calibration.startMechanism,
diff --git a/tasks/tetris/eval/gameplay-bot/tests.ts b/tasks/tetris/eval/gameplay-bot/tests.ts
@@ -147,6 +147,21 @@ export async function runAllTests(
);
}
+ // Re-sample calibration after start: the game may have created DOM
+ // elements (grid cells, score displays) that didn't exist on page load
+ const initialGridDetected = cal.gridDetected;
+ if (gameStarted && !cal.gridDetected) {
+ try {
+ await page.waitForTimeout(500); // Let game render after start
+ const recal = await calibrate(page);
+ if (recal.gridDetected) {
+ // Grid appeared after start -- upgrade calibration
+ cal = recal;
+ (cal as any).grid_detected_at = "after_start";
+ }
+ } catch { /* keep original calibration */ }
+ }
+
// ---- Phase 3: Basic mechanics -- ONLY if game started ----
let mechanicsWork = false;
if (gameStarted && cal.gridDetected) {