commit 6efe39f4df77be4a438d956fcbd95f2f401f54d4
parent 8dd7988310718f814aa96b5206b913e4b94b6491
Author: Brian Graham <brian@buildingbetterteams.de>
Date: Tue, 7 Apr 2026 20:57:40 +0200
Fix falling piece detector: faster polling, longer settle time
- 5 frames at 200ms (was 3 at 800ms) for faster piece detection
- 1.5s post-trigger wait (was 300ms) to let overlays dismiss and
first piece spawn before checking for downward movement
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tasks/tetris/eval/gameplay-bot/calibrate.ts b/tasks/tetris/eval/gameplay-bot/calibrate.ts
@@ -158,7 +158,7 @@ async function measureGridConfidence(
}
/**
- * Detect a falling piece by taking 3 screenshots ~800ms apart and looking
+ * Detect a falling piece by taking 5 screenshots ~200ms apart and looking
* for a cluster of colored pixels that moved downward between frames.
*
* This works for canvas, DOM, SVG, WebGL -- any rendering approach.
@@ -173,8 +173,8 @@ async function measureGridConfidence(
async function detectFallingPiece(page: Page): Promise<boolean> {
const SAMPLE_COLS = 20;
const SAMPLE_ROWS = 40;
- const SCREENSHOTS = 3;
- const INTERVAL_MS = 800;
+ const SCREENSHOTS = 5;
+ const INTERVAL_MS = 200;
// Minimum downward shift in sample-grid rows to count as "falling"
const MIN_DOWN_SHIFT = 1;
// Cluster size bounds (roughly a tetromino: 3-6 sample points)
@@ -489,8 +489,8 @@ async function detectStartMechanism(page: Page): Promise<StartMechanism> {
for (const trigger of triggers) {
try {
await trigger.action();
- // Give the game a moment to react before checking for a falling piece
- await page.waitForTimeout(300);
+ // Wait for overlay to dismiss and first piece to start falling
+ await page.waitForTimeout(1500);
if (await detectFallingPiece(page)) {
return trigger.name;
@@ -574,7 +574,7 @@ async function recalibrateWithRetry(
for (const attempt of attempts) {
try {
await attempt.action();
- await page.waitForTimeout(500);
+ await page.waitForTimeout(1500);
// Use falling piece detector instead of screenshot comparison
if (startMechanism === "unknown") {