TetrisBench strategy track: submit one JS placement-scoring function body; graded by mean raw game score over 20 fixed public seeds x 500 pieces in a separate verifier.
harbor run -t ykhli/tetrisbench-strategyharbor download ykhli/tetrisbench-strategyWrite ONE JavaScript scoring function that plays Tetris, iterate on it against the practice harness, and leave your final version at:
/app/score.js
/app/score.js must contain ONLY the BODY of this function (no function
wrapper, no imports, no markdown fences):
function scorePlacement(board, metrics, linesCleared, landingHeight, pieceType) {
// your code here
return score; // a finite number; higher is better
}
The harness wraps your body in the signature above and calls it once per candidate placement. The placement with the highest score is played; ties go to the first maximum in enumeration order (rotation count, then horizontal target).
Constraints: the body must be <= 65536 bytes, deterministic and pure compute. It
runs inside a QuickJS WASM sandbox - no filesystem, network, Node APIs, or imports.
Do not rely on Date, Math.random, or any ambient global beyond standard JS
built-ins; nondeterministic APIs are unavailable.
Resource limits are part of the task: each scoring call has 16 MiB of QuickJS memory, 128 KiB of stack, at most 2,000 QuickJS interrupt checks, and a 250 ms wall-clock guard. The complete evaluation has a 900-second ceiling on a 1-vCPU, 2-GiB verifier. Any failure invalidates the whole policy. The per-call guard is not an average-compute allowance: there can be hundreds of thousands of calls. Keep scoring inexpensive and use the practice harness to check runtime. Borderline policies can time out differently on different hardware; this preview is validated on Linux amd64 with the pinned Node 24.21.0 image.
board (post-placement, post-line-clear): 20 arrays (rows, top to bottom) of 10
integers each; 0 = empty cell, non-zero = occupied.metrics (object, computed from board):
heights: array of 10 - per-column height of the highest occupied cell (0 if empty)aggregateHeight: sum of heightsmaxHeight: maximum of heightsholes: empty cells with at least one occupied cell above them in the same columnbumpiness: sum of |heights[i] - heights[i+1]| for i in 0..8rowTransitions: filled/empty transitions within each row, counting both walls as filledcolumnTransitions: filled/empty transitions within each column, counting top/bottom edges as filledwells: sum over columns of max(0, min(height of left neighbor, height of right neighbor) - heights[col]); the out-of-board neighbor height counts as the board height (20)linesCleared: lines cleared by THIS placement (0-4)landingHeight: height of the placed piece's vertical center above the bottom,
i.e. 20 - (dropRow + pieceHeight / 2)pieceType: one of "I", "O", "T", "S", "Z", "J", "L"10 x 20 board, seven tetrominoes drawn i.i.d. uniformly (NOT seven-bag). Each piece spawns at the top; legal placements are spawn-rotation + horizontal shift + hard drop that the real engine can reach (no tucks, holds, or soft drop). A blocked spawn ends the game; otherwise each game ends after 500 pieces.
Scoring per clear: single 100, double 300, triple 500, Tetris 800, multiplied by the current level. Level starts at 1 and increases by 1 for every 10 cumulative lines.
The practice harness (fixed practice seeds, different from the fixed evaluation suite) is installed at /app/benchmark:
cd /app/benchmark
node scripts/evaluate.mjs --policy /app/score.js # practice seeds, 500 pieces each
node scripts/evaluate.mjs --policy /app/score.js --trace # per-placement detail
It prints one JSON result: { "ok": ..., "perSeed": [...], "aggregate": { "meanScore": ... } }
and exits 0 when the policy is valid, 2 when it is not (syntax error, non-number
return, timeout, or resource-limit hit - any failure zeroes the policy).
Iterate as much as you want during your 900-second budget. Only the final
/app/score.js is graded.
After your time budget, a separate clean verifier container re-runs the game engine against 20 fixed public evaluation seeds x 500 pieces with your final /app/score.js as the placement scorer. The benchmark score is the mean raw game score across those seeds (standard line scoring, not normalized). A missing, oversized, or failing policy scores 0. Grading is trustworthy because the separate container re-executes the pinned engine itself from your submitted artifact; the seeds are fixed and public, and the practice image simply omits the protocol file to keep the practice loop focused. Difference from the website's live mode: there is no opponent, no 120-second clock, and no mid-game strategy rewriting - one final artifact is graded offline.
A simple weighted-feature heuristic body (safe, public, mediocre):
return 1.0 * linesCleared
- 0.5 * metrics.aggregateHeight
- 1.5 * metrics.holes
- 0.4 * metrics.bumpiness
- 0.6 * metrics.maxHeight
- 0.2 * landingHeight;
Task metadata pins engine SHA-256 ee627f8fbc5674c261437e13878ee2862680fc4b8ba205ceb84345938bb71c19; grading replays the identical engine build.