Tetromino solver written in Javascript.
A Teromino puzzle is a grid which you solve by fitting Tetris pieces with no gaps.
──┬── ║
║ ╵ ╔═╝
║ ║ ║ ┃
║ ║ ━━┫
║ ╚══ ┃
Short answer: check out problem.js for a working example.
Longer answer:
-
Create a
Board
var b = new Tetra.Board(4,7);
-
Create a
Solver
, passing theBoard
and anArray
of the availablePieces
.var solver = new Tetra.Solver(b, [ Tetra.pieces.stick, Tetra.pieces.tee, Tetra.pieces.square, Tetra.pieces.zigR, Tetra.pieces.tee, Tetra.pieces.bentL, Tetra.pieces.stick, Tetra.pieces.square, ]);
-
Solve it!
solver.solve();
-
After a (hopefully miniscule) time, you get something like:
Solved! X X E E X X E E + + + @ * + @ @ * O @ % * O % % * O O % leftovers: [ 'stick' ]
I wrote this because I thought it would be faster and more fun than actually solving the mandatory puzzles in that game that time. At least one of those predictions came true.