A genetic algorithm that finds a matrix multiplication network capable of playing Tetris with super human capabilities. This is done by finding a local maxima in a specified heuristic domain of Tetris. The "AI" is created through simulating games and generational breeding of players. The best player from each generation lives on and breeds with the others, and crossbreeding random players is used for the chance of creating better traits.
tetris.mov
This means the first players will fail right away when the program starts.
creating.mov
This is because the neural nets are initialized with random numbers. Failure causes simulated games and generational breeding to be ran in the background until a player can play the game to the specified score. The simulation and breeding are done using parallel computation, so it is resource heavy and will use nearly 100% of your CPU.
- The best player from the last generation is kept and added to the next generation.
- The best player breeds with 5 of the other players, and their children live on.
- Random players then breed and their children live on in the next generation.
- This process is continued until a player can reach the specified score!
The neural nets are made with koma which is a scientific computing environment for Kotlin.
The visuals are created using Processing. A beta version is included in this repo, because the older stable versions do not play nicely with Apple Silicon.
- run the following commands within Windows PowerShell
- make sure you have the java development kit installed on your machine and the JAVA_HOME enviroment variable set
- download Chocolately (a package manager for Windows)
- use Chocolately to install Gradle (allows you to build jar files)
- run:
choco install gradle
- run:
- download this repository or run:
git clone https://github.com/kevinpbaker/TetrisAI.git
- navigate to downloaded folder in the powershell by running:
cd INSERT_DIRECTORY_PATH_WHERE_YOU_SAVED_REPO_HERE
- run:
gradle build
- run:
java -jar .\build\libs\TetrisAI-1.0.jar