A small web app where TypeSafe's Jev model plays Tetris by itself. The only control is Reset.
For each new piece:
- Code lists every placement the piece can reach (rotate, shift, drop) and computes plain
facts about the board each one leaves:
lines_cleared,new_holes,stack_height,bumpiness,piece_top_height. - The server sends those candidates to Jev as a single typed Choice question
(
server.js). There is no hand-tuned scoring formula; Jev weighs the trade-offs. - The page animates the picked placement as rotate / left / right / drop moves and shows Jev's top candidates, their probabilities, the confidence of the choice, the latency, and the cost of the call. The page also keeps a running total of what the game has spent.
The game waits for Jev before moving each piece, so network latency never ends a game.
Requires Node.js 20+ and a TypeSafe API key.
npm install
TYPESAFE_API_KEY=<your key> npm startOpen http://localhost:3000. Set PORT to use a different port.
The API key stays on the local server; the browser only talks to /api/decide.
Each piece is one TypeSafe request. Cost is computed from the input tokens the API reports
at Jev's listed price of $0.042 per million input tokens (output tokens are free); update
USD_PER_INPUT_TOKEN in server.js if the pricing changes.
server.js static files + POST /api/decide → TypeSafe SDK
public/game.js Tetris rules (pure, no DOM)
public/candidates.js placement enumeration and board facts (pure)
public/app.js game loop, canvas rendering, decision panel
public/index.html page and styles
test/ node:test unit tests (npm test)
Andrei Smirnov · [email protected]
