Skip to content

hojmax/Tetris-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Tetris Bot

πŸ“ Description

This project is an implementation of a bot which can play automatically by performing tetrises1. The bot looks recursively n moves into the future, evaluates the board, and chooses the move which leads to the board state with the best score. This is achieved by bruteforcing combinations of pieces in the queue not resulting in holes. This includes swapping pieces in and out of the hold queue.

πŸ–₯ Live Demo

You can view the project here.

🚧 Limitations

It is to be mentioned that this bot fails on the first move approximately 6.7% of the time. This is due to the fact that any combinations of the s and z piece in the first 2 positions of the queue, or the s, z, and o piece in the first 3 positions, will not leave any moves resulting in no holes2. There is a very simple way of handling this exception which I employed in a previous version of the Tetris bot. You can place the troubling piece left-most and rotate it in such a manor that the resulting holes always land in the empty column. This can be used to not only the resolve the starting exception, but also prolong the point of no valid moves. This is currently not implemented.

πŸ„β€β™‚οΈ Usage

As this project is built using vanilla javascript, all you need is to open index.html in your browser. Press SPACE for placing pieces one at a time, and R for repeated placements. Note that the bot only places a piece if there is an avalaible move that results in no holes and respects the height limit. Refresh the page in case it gets stuck.

Footnotes

  1. A 'tetris' refers to clearing 4 lines simultaneously. This can only be done by dropping an i piece. ↩

  2. If you are unfamiliar with the piece names (i.e. s, z and so on), you can read here. ↩

About

Automatic playing using the Tetris-clear strategy

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published