TETERI
How TETERI is built
How the CPU Opponent Searches
Enumerate every placement, score the resulting board on four weighted features, take the best.
The computer opponent is a one-ply heuristic search. No neural network, no tree, no lookahead beyond the held piece.
The search
For the current piece and the held piece, for each of four rotations, for each column: drop the piece straight down, remove any complete rows, and score the resulting board. Roughly 80 candidates per turn, each evaluated in microseconds on a flat typed array.
The evaluation
Four features, linearly weighted:
Aggregate height — the sum of column heights. Lower is better.
Holes — empty cells with something above them. Heavily penalised, because a hole makes every row above it uncompletable.
Bumpiness — the sum of differences between adjacent column heights. Flat surfaces accept more pieces.
Well depth — how deep single-column gaps are, penalised beyond two cells.
Plus a bonus for lines cleared, an extra bonus for clearing four at once, and a sharp penalty for exceeding a height threshold.
These are close to a well-known published weighting for this problem, adjusted by playtesting.
Playing the move
The chosen placement is converted into a list of inputs — hold, rotations, moves, drop — and those are performed one at a time on a timer. That is deliberate: it makes the opponent watchable, and it means it is playing the same game you are rather than teleporting pieces.
Rotations take the shortest path around the ring, which is a small thing that makes the CPU look competent rather than robotic.
Difficulty
Not a speed multiplier. Rookie deliberately selects a worse-than-best placement about a third of the time and does not use hold. Nightmare never does either. The difference is decision quality, which is what makes lower difficulties genuinely beatable rather than merely slower.
What it cannot do
It has no multi-piece plan, so no T-spin setups and no openers. It never looks at your board. Both are real gaps, and both are where a human beats it.
Read next
- Rendering: Sprite Caches and Layer BakingDrawing four hundred glowing blocks per frame is slow. Drawing four hundred cached bitmaps is not.
- Every Sound Is Generated, Not RecordedOscillators, filtered noise and a reverb impulse built from decaying random numbers. No audio files anywhere.
- The Soundtrack Is a Sequencer, Not a FileA four-bar progression with drums, bass, arpeggio and a lead, whose tempo and arrangement climb with your level.
- Online Play With No Server At AllWebRTC connects the two browsers directly; a public relay handles only the introduction.
- Perfect Clears: Emptying the Board CompletelyClear every block on the field at once and the bonus dwarfs everything else in the scoring table.
- Six-Three Stacking and Why Some Players Prefer ItSplitting the board into two flat regions instead of one gives you somewhere to put the awkward pieces.