Skip to content

About

Tetris that plays itself: TypeSafe's Jev model picks every placement with one typed Choice call, with live probabilities, latency, and cost.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Jev plays Tetris

A small web app where TypeSafe's Jev model plays Tetris by itself. The only control is Reset.

Jev playing Tetris: the board, and Jev's decision panel with latency, confidence, cost, and top candidates

How it works

For each new piece:

  1. 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.
  2. 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.
  3. 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.

Run it

Requires Node.js 20+ and a TypeSafe API key.

npm install
TYPESAFE_API_KEY=<your key> npm start

Open 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.

Layout

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)

Author

Andrei Smirnov · [email protected]

License

MIT

About

Tetris that plays itself: TypeSafe's Jev model picks every placement with one typed Choice call, with live probabilities, latency, and cost.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages