Video: https://youtu.be/pXTfgw9A08w
Interactive Demo: https://knagaitsev.github.io/tetris-ai/public/
This is a Tetris AI written in JavaScript. It was optimized using a genetic algorithm, but can often only achieve 1000-2000 lines per game. It is still in development, so hopefully we will soon reach the perfect Tetris AI!
This project is unique in that I will not give the AI knowledge of the next piece. It has already been proven that next piece knowledge is highly advantageous. I have not implemented T-Spins or other complex Tetris moves, but I will probably do so eventually.
The AI uses the following parameters to determine how good a move is:
- Hole count
- Bumpiness
- Lines Cleared
Among some other minor parameters.
Any contributions are welcome. Please join my Discord to learn more: https://discord.gg/Sfbg2Sh
Before developing, you will need Node.js and npm installed.
To develop this project, clone this repository, then go into the training directory and type:
npm install
From there, you can do
npm train
to run the genetic algorithm. Data is outputted in the data folder.
If you want to run the demo, install the global module live-server like this:
npm install -g live-server
Then go into the public directory and do:
live-server
tetris-js: https://github.com/simon-tiger/tetris-js
genetic-js: https://github.com/subprotocol/genetic-js