A tetris solver on top of samtay/tetris.
It got me a 10_000_000 score until I was no longer interested in waiting.
Bruteforces (see more: Solve.hs) all two next moves with the scoring function that
- penalizes each occupied block on the screen,
- penalizes each free block with occupied blocks above it,
- weighs each block according to its height in the game (high is bad),
- scores by (scoreAfterTwoMoves, scoreAfterFirstMove), which is important.
- Left/right rotation buttons
- Save-game implemented (
~/.local/share/tetris/saved.json) - Has an autosuggest feature (and solve)
- Pause has the board visible behind "Paused"
nix build github:siers/tetris/solverThe default game is run by simply executing the tetris command.
If the unicode characters look a bit
wonky in your terminal, you can also run
tetris --ascii-only # uses [] as preview cell
# or
tetris --preview-chars 'XX' # uses custom characters as preview cellIf you want to skip the level prompt, you can start the game immediately via
tetris --level nLastly, to see the current high score, you can run tetris --high-score.
And of course, see tetris --help for help.
Enter the development shell with nix develop.
Format the source with fourmolu --indentation 2 **/*.hs -i.