https://github.com/mitiko/tmino
Fill a grid MxN with polyminos using backtracking
https://github.com/mitiko/tmino
Last synced: 3 months ago
JSON representation
Fill a grid MxN with polyminos using backtracking
- Host: GitHub
- URL: https://github.com/mitiko/tmino
- Owner: mitiko
- Created: 2022-04-02T07:39:08.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-02T13:20:50.000Z (about 3 years ago)
- Last Synced: 2025-01-10T22:24:00.921Z (5 months ago)
- Language: Rust
- Size: 36.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

# T-mino solution finder
This project tries to fill a grid MxN with polyminos using backtracking (smart-ish bruteforce).
The algorithm is applicable to any polymino and can be modified to different shapes grids
but the base version of it uses a specific t-polymino of size 6.## How to draw the solution
If a solution is found, an image solution-.bmp will be generated where each pixel in the bitmap is a cell in the grid.
To upscale the image you can use imagemagick with `convert in.bmp -filter point -resize 1200x1200 out.jpg` and you can substitute the desired image dimensions. (Cool trick - you can get some cool blurry art if you omit -filter point).
To do it in batches you could also do `mogrify -filter point -resize 1200x1200 -format jpg *.bmp && rm *.bmp`## How to change the polymino
There's a macro parser (running compile time) to generate code for the different rotations and flips of polyminos.
You could easily change it to a different polymino as long as you put (0, 0) in the top left cell of the polymino.You should replace the sequences of cells in `try_fill`, `unfill`, and `apply_stack`.
Another function to mind is the `get_gap_index` which returns the first empty cell in the grid starting from a given position (by default the last inserted polymino).
Any function that returns an empty cell should work but different implementations will vary in speed of solver.