Instructions to use justforfun0906/laya-tetris with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Laya
How to use justforfun0906/laya-tetris with Laya:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Laya Tetris
Laya (ModernBERT-large, 421M parameters) fine-tuned to play Tetris by imitating the El-Tetris heuristic bot.
Code, training details and how to run it: https://github.com/justforfun0906/Laya_tetris
Results
500-piece games, 3 games:
| Policy | Lines cleared | Tops out? | Agreement with teacher |
|---|---|---|---|
| Laya, untuned | 0 | within ~30 pieces | 11.9% |
| This model | 198 avg (197โ199) | never | 84.3% |
| Teacher (El-Tetris heuristic) | ~200 (the maximum for 500 pieces) | never | 100% |
About 170 ms per move on an Apple M2.
How it works
Each turn is a Laya choice question:
- State: the board as
#/.text rows, plus the current and next piece. - Options: the 10 most promising placements, picked by a simple rule that doesn't use
the teacher, each described like
rotation 0 column 3; clears 0, holes 0, lands at 2, max height 5, bumpiness 4.
Training used soft-label distillation (cross-entropy against softmax(teacher_scores / 2.0))
on 15,000 positions. Only the top 8 of 28 encoder layers and the decision head were updated
(124M parameters), for 1,336 steps (about 3 hours on an M2).
Usage
git clone https://github.com/justforfun0906/Laya_tetris.git && cd Laya_tetris
pip install -r requirements.txt
hf download justforfun0906/laya-tetris --local-dir runs/laya-tetris
python watch.py --model runs/laya-tetris
import laya
from tetris import Game
from laya_format import shortlist, build_question, render_state, MAX_LEN, HEAD_MAX_LEN
agent = laya.load("runs/laya-tetris")
agent.cfg["max_len"], agent.cfg["head_max_len"] = MAX_LEN, HEAD_MAX_LEN
game = Game(seed=0)
while not game.over:
questions, by_label = build_question(shortlist(game.legal()))
answer = agent.predict(render_state(game), questions)["answers"]["move"]["choice"]
game.step(by_label[answer])
print(game.lines, "lines")
Limitations
- Only evaluated on 3 games capped at 500 pieces.
- The option text includes summary numbers (holes, heights, bumpiness), so the model is not reading the raw board alone.
- It can only choose among the 10 shortlisted moves.
License
Apache-2.0, same as the base Laya model.
- Downloads last month
- 19
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐ Ask for provider support
Model tree for justforfun0906/laya-tetris
Base model
convaiinnovations/laya