Skip to content

knagaitsev/tetris-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Video: https://youtu.be/pXTfgw9A08w

Interactive Demo: https://knagaitsev.github.io/tetris-ai/public/

Tetris AI

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.

alt text

Screenshots:

alt text

Contributing

Any contributions are welcome. Please join my Discord to learn more: https://discord.gg/Sfbg2Sh

Development & Training

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.

Running Demo Locally

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

Sources that I built off of

tetris-js: https://github.com/simon-tiger/tetris-js

genetic-js: https://github.com/subprotocol/genetic-js